Class: Spree::SendWithUs::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/spree_sendwithus/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessage

Returns a new instance of Message.



9
10
11
12
13
14
15
16
17
# File 'lib/spree_sendwithus/message.rb', line 9

def initialize
  @email_data = {}
  @to = {}
  @from = {}
  @cc = []
  @bcc = []
  @files = []
   = Base. || ""
end

Instance Attribute Details

#bccObject (readonly)

Returns the value of attribute bcc.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def bcc
  @bcc
end

#ccObject (readonly)

Returns the value of attribute cc.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def cc
  @cc
end

#email_dataObject (readonly)

Returns the value of attribute email_data.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def email_data
  @email_data
end

#email_idObject (readonly)

Returns the value of attribute email_id.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def email_id
  @email_id
end

#esp_accountObject (readonly)

Returns the value of attribute esp_account.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def 
  
end

#filesObject (readonly)

Returns the value of attribute files.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def files
  @files
end

#fromObject (readonly)

Returns the value of attribute from.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



6
7
8
# File 'lib/spree_sendwithus/message.rb', line 6

def to
  @to
end

Instance Method Details

#assign(key, value) ⇒ Object



19
20
21
# File 'lib/spree_sendwithus/message.rb', line 19

def assign(key, value)
  @email_data.merge!(key.to_sym => value)
end

#deliverObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/spree_sendwithus/message.rb', line 50

def deliver
  ::SendWithUs::Api.new.send_with(
    @email_id,
    @to,
    @email_data,
    @from,
    @cc,
    @bcc,
    @files,
    
  )
end

#merge!(params = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/spree_sendwithus/message.rb', line 23

def merge!(params = {})
  params.each_pair do |key, value|
    case key
    when :email_id
      @email_id = value
    when :recipient_name
      @to.merge!(name: value)
    when :recipient_address
      @to.merge!(address: value)
    when :from_name
      @from.merge!(name: value)
    when :from_address
      @from.merge!(address: value)
    when :reply_to
      @from.merge!(reply_to: value)
    when :cc
      @cc.concat(value)
    when :bcc
      @bcc.concat(value)
    when :files
      @files.concat(value)
    when :esp_account
       = value
    end
  end
end