Sha256: 2d6ca62a1675059c96faab4b2a69f75e5d538ce40cd9c900974342c2fecef60f

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

class DelayedSubscriberAdd < Struct.new(:store_code, :user, :list, :ops)
  def perform

    if list.nil? || !user
      subscriber_id = -1
    else
      begin
        token= Spree::BrontoConfiguration.account[store_code]['token']
        if user.is_a? String
          email=user
        else
          email=user.email
        end

        contact = BrontoIntegration::Contact.new(token)
        contacts=contact.set_up(email,ops||{})
        subscriber_id= contacts[:id]

        communication = BrontoIntegration::Communication.new(token)
        communication.add_to_list(list.title,email)

      rescue => exception
          subscriber_id = -1
          #raise exception
      end
    end

    unless user.is_a? String
      begin
      user.bronto_lists << list
      user.save!
      rescue
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_bronto-3.0.0 lib/delayed_subscriber_add.rb