Class: Maropost::Contact
- Inherits:
-
Object
- Object
- Maropost::Contact
- Defined in:
- lib/maropost/contact.rb
Constant Summary collapse
- ATTRIBUTES =
%i[ allow_emails id email phone_number cell_phone_number lists errors ].freeze
- LISTS =
%i[ ama_rewards ama_membership ama_insurance ama_travel ama_new_member_series ama_fleet_safety ovrr_personal ovrr_business ovrr_associate ama_vr_reminder ama_vr_reminder_email ama_vr_reminder_sms ama_vr_reminder_autocall ].freeze
Instance Method Summary collapse
- #allow_emails? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Contact
constructor
A new instance of Contact.
- #list_parameters ⇒ Object
- #subscribed_to_any_lists? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Contact
Returns a new instance of Contact.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/maropost/contact.rb', line 32 def initialize(opts = {}) data = opts.with_indifferent_access self.id = data[:id] self.email = data[:email] self.phone_number = data[:phone] self.cell_phone_number = data[:cell_phone_number] self.allow_emails = data.fetch(:allow_emails) { !DoNotMailList.exists?(self) } self.errors = [] self.lists = {} initialize_lists(data) end |
Instance Method Details
#allow_emails? ⇒ Boolean
44 45 46 |
# File 'lib/maropost/contact.rb', line 44 def allow_emails? allow_emails end |
#list_parameters ⇒ Object
52 53 54 |
# File 'lib/maropost/contact.rb', line 52 def list_parameters { cell_phone_number: cell_phone_number }.merge(lists) end |
#subscribed_to_any_lists? ⇒ Boolean
48 49 50 |
# File 'lib/maropost/contact.rb', line 48 def subscribed_to_any_lists? lists.values.any? { |v| v == '1' } end |