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.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/magicbell/user.rb', line 10 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.
7 8 9 |
# File 'lib/magicbell/user.rb', line 7 def email @email end |
#preferences ⇒ Object
Returns the value of attribute preferences.
8 9 10 |
# File 'lib/magicbell/user.rb', line 8 def preferences @preferences end |
Instance Method Details
#hmac_signature ⇒ Object
26 27 28 |
# File 'lib/magicbell/user.rb', line 26 def hmac_signature MagicBell::HMAC.calculate @email end |
#notification_preferences ⇒ Object
30 31 32 33 |
# File 'lib/magicbell/user.rb', line 30 def notification_preferences response = @conn.get "/notification_preferences.json" JSON.parse(response.body)["notification_preferences"] end |
#notification_preferences=(preferences) ⇒ Object
35 36 37 38 |
# File 'lib/magicbell/user.rb', line 35 def notification_preferences=(preferences) @conn.put "/notification_preferences.json", {notification_preferences: preferences} end |
#notifications ⇒ Object
21 22 23 24 |
# File 'lib/magicbell/user.rb', line 21 def notifications response = @conn.get "/notifications.json" JSON.parse(response.body)["notifications"] end |