Class: MagicBell::User
- Inherits:
-
Object
- Object
- MagicBell::User
- Defined in:
- lib/magicbell/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#preferences ⇒ Object
Returns the value of attribute preferences.
Instance Method Summary collapse
- #hmac_signature ⇒ Object
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
- #notification_preferences ⇒ Object
- #notification_preferences=(preferences) ⇒ Object
- #notifications ⇒ Object
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/magicbell/user.rb', line 9 def initialize(attributes) @attributes = attributes @email = @attributes[:email] @conn = Faraday.new({ url: MagicBell.api_host, headers: MagicBell.project_specific_headers.merge( 'X-MAGICBELL-USER-EMAIL' => @email ) }) end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/magicbell/user.rb', line 6 def email @email end |
#preferences ⇒ Object
Returns the value of attribute preferences.
7 8 9 |
# File 'lib/magicbell/user.rb', line 7 def preferences @preferences end |
Instance Method Details
#hmac_signature ⇒ Object
25 26 27 |
# File 'lib/magicbell/user.rb', line 25 def hmac_signature MagicBell::HMAC.calculate @email end |
#notification_preferences ⇒ Object
29 30 31 32 |
# File 'lib/magicbell/user.rb', line 29 def notification_preferences response = @conn.get "/notification_preferences.json" JSON.parse(response.body)["notification_preferences"] end |
#notification_preferences=(preferences) ⇒ Object
34 35 36 37 |
# File 'lib/magicbell/user.rb', line 34 def notification_preferences=(preferences) @conn.put "/notification_preferences.json", {notification_preferences: preferences} end |
#notifications ⇒ Object
20 21 22 23 |
# File 'lib/magicbell/user.rb', line 20 def notifications response = @conn.get "/notifications.json" JSON.parse(response.body)["notifications"] end |