Sha256: 8ec8d0dbeb6f018c3c2e7dac798344b42ca8f83fc1c150df09518abbccc02fda
Contents?: true
Size: 937 Bytes
Versions: 2
Compression:
Stored size: 937 Bytes
Contents
module CampactUserService class Account attr_reader :client, :user_id def initialize(client, user_id) @client = client @user_id = user_id end def exists? account && !account["id"].nil? end def subscribed_to_newsletter? subscriptions = account.dig('emailaddress', 'subscriptions') || [] subscriptions.any? {|s| s['type'] == 'newsletter' } end def allow_prefill? prefill = account.dig('preferences', 'prefill_forms') prefill.to_s == 'allowed' end def name account['name'] end def email account.dig('emailaddress', 'emailaddress') end def address account['postaladdress'] end def preferences account['preferences'] end private def account escaped_user_id = CGI.escape(user_id) @account_info ||= (client.get_request("v1/accounts/#{escaped_user_id}") || {}) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
campact_user_service-3.0.1 | lib/campact_user_service/account.rb |
campact_user_service-3.0.0 | lib/campact_user_service/account.rb |