Class: Workarea::Listrak::SubscribeEmailSignup

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::CallbacksWorker, Sidekiq::Worker
Defined in:
app/workers/workarea/listrak/subscribe_email_signup.rb

Instance Method Summary collapse

Instance Method Details

#perform(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/workers/workarea/listrak/subscribe_email_signup.rb', line 15

def perform(id)
   = Email::Signup.find id
  list_id = Listrak.configuration.default_list_id
  event_ids = Array.wrap(Listrak.configuration.external_event_ids).to_csv(row_sep: nil).presence

  contact = Listrak::Models::ContactForm.new(
    email: .email,
    subscription_state: 'Subscribed'
  )

  options = {
    overrideUnsubscribe: true,
    eventIds: event_ids
  }.compact

  Listrak.email.contacts.upsert list_id, contact, options
end