Class: Blastengine::Transaction
- Includes:
- Blastengine
- Defined in:
- lib/blastengine/transaction.rb
Constant Summary
Constants included from Blastengine
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#cc ⇒ Object
Returns the value of attribute cc.
-
#encode ⇒ Object
Returns the value of attribute encode.
-
#html_part ⇒ Object
Returns the value of attribute html_part.
-
#insert_code ⇒ Object
Returns the value of attribute insert_code.
-
#list_unsubscribe ⇒ Object
Returns the value of attribute list_unsubscribe.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text_part ⇒ Object
Returns the value of attribute text_part.
-
#to ⇒ Object
Returns the value of attribute to.
Attributes inherited from Base
#created_time, #delivery_id, #delivery_time, #delivery_type, #drop_count, #hard_error_count, #open_count, #sent_count, #soft_error_count, #status, #total_count, #updated_time
Instance Method Summary collapse
-
#from(email:, name: "") ⇒ Object
送信主の追加.
-
#initialize ⇒ Transaction
constructor
A new instance of Transaction.
-
#send ⇒ Object
トランザクションメールの送信.
Methods included from Blastengine
Methods inherited from Base
#cancel, #client, client, #delete, #get, #set, #sets, #unsubscribe
Constructor Details
#initialize ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/blastengine/transaction.rb', line 7 def initialize @to = "" @cc = [] @bcc = [] = [] @encode = "UTF-8" @insert_code = {} @list_unsubscribe = { url: "", email: "" } end |
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def end |
#bcc ⇒ Object
Returns the value of attribute bcc.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def bcc @bcc end |
#cc ⇒ Object
Returns the value of attribute cc.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def cc @cc end |
#encode ⇒ Object
Returns the value of attribute encode.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def encode @encode end |
#html_part ⇒ Object
Returns the value of attribute html_part.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def html_part @html_part end |
#insert_code ⇒ Object
Returns the value of attribute insert_code.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def insert_code @insert_code end |
#list_unsubscribe ⇒ Object
Returns the value of attribute list_unsubscribe.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def list_unsubscribe @list_unsubscribe end |
#subject ⇒ Object
Returns the value of attribute subject.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def subject @subject end |
#text_part ⇒ Object
Returns the value of attribute text_part.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def text_part @text_part end |
#to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'lib/blastengine/transaction.rb', line 6 def to @to end |
Instance Method Details
#from(email:, name: "") ⇒ Object
送信主の追加
23 24 25 |
# File 'lib/blastengine/transaction.rb', line 23 def from(email:, name: "") @_from = {email: email, name: name} end |
#send ⇒ Object
トランザクションメールの送信
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/blastengine/transaction.rb', line 30 def send # APIリクエスト用のパス path = "/deliveries/transaction" # APIリクエスト用のデータ data = { from: @_from, to: @to, cc: @cc, bcc: @bcc, subject: @subject, encode: @encode, text_part: @text_part, } # HTMLパートがある場合は追加 data[:html_part] = @html_part unless @html_part.nil? if @insert_code != nil data[:insert_code] = @insert_code.map do |key, value| { key: "__#{key}__", value: value } end end unless @list_unsubscribe.nil? data[:list_unsubscribe] = {} data[:list_unsubscribe][:url] = @list_unsubscribe[:url] if !@list_unsubscribe[:url].nil? && @list_unsubscribe[:url] != "" data[:list_unsubscribe][:mailto] = "mailto:#{@list_unsubscribe[:email]}" if !@list_unsubscribe[:email].nil? && @list_unsubscribe[:email] != "" end # API実行 res = @@client.post path, data, # エラーがあったら例外を投げるので、この場合は通常終了 @delivery_id = res["delivery_id"] return res["delivery_id"] end |