Class: Togglehq::Notify::Preferences
- Inherits:
-
Object
- Object
- Togglehq::Notify::Preferences
- Defined in:
- lib/togglehq/notify/preferences.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
Class Method Summary collapse
-
.all ⇒ Object
Gets all available notification categories and their associated preferences for the current app.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Preferences
constructor
A new instance of Preferences.
Constructor Details
#initialize(params = {}) ⇒ Preferences
Returns a new instance of Preferences.
8 9 10 |
# File 'lib/togglehq/notify/preferences.rb', line 8 def initialize(params = {}) @categories = params[:categories] end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
6 7 8 |
# File 'lib/togglehq/notify/preferences.rb', line 6 def categories @categories end |
Class Method Details
.all ⇒ Object
Gets all available notification categories and their associated preferences for the current app
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/togglehq/notify/preferences.rb', line 14 def self.all response = Togglehq::Request.new("/preferences").get! if response.status == 200 json = JSON.parse(response.body) preferences = Togglehq::Notify::Preferences.new(categories: json) return preferences else raise "Unexpected error getting app preferences" end end |