Class: DelayedTrigger

Inherits:
Struct
  • Object
show all
Defined in:
lib/delayed_trigger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes

Returns:

  • (Object)

    the current value of attributes



1
2
3
# File 'lib/delayed_trigger.rb', line 1

def attributes
  @attributes
end

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



1
2
3
# File 'lib/delayed_trigger.rb', line 1

def email
  @email
end

#mail_typeObject

Returns the value of attribute mail_type

Returns:

  • (Object)

    the current value of mail_type



1
2
3
# File 'lib/delayed_trigger.rb', line 1

def mail_type
  @mail_type
end

#message_nameObject

Returns the value of attribute message_name

Returns:

  • (Object)

    the current value of message_name



1
2
3
# File 'lib/delayed_trigger.rb', line 1

def message_name
  @message_name
end

#store_codeObject

Returns the value of attribute store_code

Returns:

  • (Object)

    the current value of store_code



1
2
3
# File 'lib/delayed_trigger.rb', line 1

def store_code
  @store_code
end

Instance Method Details

#performObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/delayed_trigger.rb', line 2

def perform
  return if email.blank?
  begin
    token= Spree::BrontoConfiguration.[store_code]['token']
    from_email= Spree::Store.current.mail_from_address
    from_name= Spree::BrontoConfiguration.[store_code]['from_name']
    reply_email= Spree::Store.current.mail_from_address
    email_options={:fromEmail =>from_email,:fromName => from_name, :replyEmail => reply_email}

    communication = BrontoIntegration::Communication.new(token)
    communication.trigger_delivery_by_id(message_name,email,'triggered',mail_type||'html',attributes||{},email_options)
  rescue => exception
    #raise exception   # as now only campaign use this and their templates may not be approved. let it go.
  end
end