Class: Maropost::Contact

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (Boolean)


44
45
46
# File 'lib/maropost/contact.rb', line 44

def allow_emails?
  allow_emails
end

#list_parametersObject



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

Returns:

  • (Boolean)


48
49
50
# File 'lib/maropost/contact.rb', line 48

def subscribed_to_any_lists?
  lists.values.any? { |v| v == '1' }
end