Sha256: b404c950506138f773f94ac8031e5856ee1f070c8ab7b5b389b8c73997eb32da

Contents?: true

Size: 832 Bytes

Versions: 4

Compression:

Stored size: 832 Bytes

Contents

module Workarea
  module Listrak
    class SubscribeEmailSignup
      include Sidekiq::Worker
      include Sidekiq::CallbacksWorker

      sidekiq_options(
        enqueue_on: {
          Email::Signup => :create
        },
        queue: "low",
        retry: true
      )

      def perform(id)
        signup = 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: signup.email,
          subscription_state: 'Subscribed'
        )

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-listrak-5.0.4 app/workers/workarea/listrak/subscribe_email_signup.rb
workarea-listrak-5.0.3 app/workers/workarea/listrak/subscribe_email_signup.rb
workarea-listrak-5.0.2 app/workers/workarea/listrak/subscribe_email_signup.rb
workarea-listrak-5.0.1 app/workers/workarea/listrak/subscribe_email_signup.rb