Class: CampactUserService::Account
- Inherits:
-
Object
- Object
- CampactUserService::Account
- Defined in:
- lib/campact_user_service/account.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #address ⇒ Object
- #allow_prefill? ⇒ Boolean
- #donor_info ⇒ Object
- #email ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(client, user_id) ⇒ Account
constructor
A new instance of Account.
- #name ⇒ Object
- #preferences ⇒ Object
- #subscribed_to_newsletter? ⇒ Boolean
Constructor Details
#initialize(client, user_id) ⇒ Account
Returns a new instance of Account.
5 6 7 8 |
# File 'lib/campact_user_service/account.rb', line 5 def initialize(client, user_id) @client = client @user_id = user_id end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
3 4 5 |
# File 'lib/campact_user_service/account.rb', line 3 def client @client end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
3 4 5 |
# File 'lib/campact_user_service/account.rb', line 3 def user_id @user_id end |
Instance Method Details
#address ⇒ Object
32 33 34 |
# File 'lib/campact_user_service/account.rb', line 32 def address account['postaladdress'] end |
#allow_prefill? ⇒ Boolean
19 20 21 22 |
# File 'lib/campact_user_service/account.rb', line 19 def allow_prefill? prefill = account.dig('preferences', 'prefill_forms') prefill.to_s == 'allowed' end |
#donor_info ⇒ Object
40 41 42 |
# File 'lib/campact_user_service/account.rb', line 40 def donor_info account['donorclass'] end |
#email ⇒ Object
28 29 30 |
# File 'lib/campact_user_service/account.rb', line 28 def email account.dig('emailaddress', 'emailaddress') end |
#exists? ⇒ Boolean
10 11 12 |
# File 'lib/campact_user_service/account.rb', line 10 def exists? account && account["id"] end |
#name ⇒ Object
24 25 26 |
# File 'lib/campact_user_service/account.rb', line 24 def name account['name'] end |
#preferences ⇒ Object
36 37 38 |
# File 'lib/campact_user_service/account.rb', line 36 def preferences account['preferences'] end |
#subscribed_to_newsletter? ⇒ Boolean
14 15 16 17 |
# File 'lib/campact_user_service/account.rb', line 14 def subscriptions = account.dig('emailaddress', 'subscriptions') || [] subscriptions.any? {|s| s['type'] == 'newsletter' } end |