Sha256: 99b7811886584e5a5de65d138226bf76196d9ba56493889a33a76e0d3f6608e6

Contents?: true

Size: 738 Bytes

Versions: 3

Compression:

Stored size: 738 Bytes

Contents

module Workarea
  module Emarsys
    class SaveOrderContact
      include Sidekiq::Worker
      include Sidekiq::CallbacksWorker

      sidekiq_options(
        enqueue_on: { Workarea::Order => [:place] },
        unique: :until_executing
      )

      def perform(id)
        return unless settings.customer_id.present?

        order = Workarea::Order.find(id)
        address = Workarea::Payment.find(order.id).address

        attrs = Emarsys::Contact.new(order, address: address, contact_from: 'order').to_h
        gateway.create_contact(attrs)
      end

      private
        def settings
          Workarea::Emarsys::Configuration.current
        end

        def gateway
          Emarsys.gateway
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-emarsys-1.0.4 app/workers/workarea/emarsys/save_order_contact.rb
workarea-emarsys-1.0.3 app/workers/workarea/emarsys/save_order.rb
workarea-emarsys-1.0.2 app/workers/workarea/emarsys/save_order.rb