blastengine 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/blastengine/base.rb +5 -0
- data/lib/blastengine/bulk.rb +18 -1
- data/lib/blastengine/mail.rb +22 -1
- data/lib/blastengine/transaction.rb +10 -1
- data/lib/blastengine/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fc0c6d0e0ae11a8ec331c4893a7dc01e1e864cd9e5a9170429e3a9157071e55
|
4
|
+
data.tar.gz: 3209cf3a38d25d8973500ed30b2e61dcdfa21e0f2fea28e092704f600352589c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e187cc819ef4a049ae1e3fa38903293502db78f5b81ca2ee27acb172f5a3d92429e445d076c92227476bafb5260b3667539f40b1794eef5a4a8dead7d8c41d59
|
7
|
+
data.tar.gz: 72cf1b0088c672d99363c26395aef7d681aa36fdd16b468694709f08d1c16d4dff5efbb96cf267d4c67e8aa894816a2b1ae5cfb21eb97157990120603d6f6fa2
|
data/lib/blastengine/base.rb
CHANGED
data/lib/blastengine/bulk.rb
CHANGED
@@ -6,11 +6,15 @@ require "date"
|
|
6
6
|
module Blastengine
|
7
7
|
class Bulk < Base
|
8
8
|
include Blastengine
|
9
|
-
attr_accessor :subject, :text_part, :encode, :html_part, :attachments, :delivery_id, :job
|
9
|
+
attr_accessor :subject, :text_part, :encode, :html_part, :attachments, :delivery_id, :job, :list_unsubscribe
|
10
10
|
def initialize
|
11
11
|
@to = []
|
12
12
|
@attachments = []
|
13
13
|
@encode = "UTF-8"
|
14
|
+
@list_unsubscribe = {
|
15
|
+
url: "",
|
16
|
+
email: ""
|
17
|
+
}
|
14
18
|
end
|
15
19
|
|
16
20
|
#
|
@@ -34,6 +38,12 @@ module Blastengine
|
|
34
38
|
}
|
35
39
|
# HTMLパートがある場合は追加
|
36
40
|
data[:html_part] = @html_part unless @html_part.nil?
|
41
|
+
# 退会リンクがある場合は追加
|
42
|
+
unless @list_unsubscribe.nil?
|
43
|
+
data[:list_unsubscribe] = {}
|
44
|
+
data[:list_unsubscribe][:url] = @list_unsubscribe[:url] if !@list_unsubscribe[:url].nil? && @list_unsubscribe[:url] != ""
|
45
|
+
data[:list_unsubscribe][:mailto] = "mailto:#{@list_unsubscribe[:email]}" if !@list_unsubscribe[:email].nil? && @list_unsubscribe[:email] != ""
|
46
|
+
end
|
37
47
|
# API実行
|
38
48
|
res = @@client.post path, data, @attachments
|
39
49
|
@delivery_id = res["delivery_id"]
|
@@ -75,6 +85,13 @@ module Blastengine
|
|
75
85
|
data[:from] = @_from unless @_from.nil?
|
76
86
|
data[:text_part] = @text_part unless @text_part.nil?
|
77
87
|
data[:html_part] = @html_part unless @html_part.nil?
|
88
|
+
|
89
|
+
# 退会リンクがある場合は追加
|
90
|
+
unless @list_unsubscribe.nil?
|
91
|
+
data[:list_unsubscribe] = {}
|
92
|
+
data[:list_unsubscribe][:url] = @list_unsubscribe[:url] if !@list_unsubscribe[:url].nil? && @list_unsubscribe[:url] != ""
|
93
|
+
data[:list_unsubscribe][:mailto] = "mailto:#{@list_unsubscribe[:email]}" if !@list_unsubscribe[:email].nil? && @list_unsubscribe[:email] != ""
|
94
|
+
end
|
78
95
|
# API実行
|
79
96
|
res = @@client.put path, data
|
80
97
|
return res["delivery_id"]
|
data/lib/blastengine/mail.rb
CHANGED
@@ -3,13 +3,18 @@ require 'date'
|
|
3
3
|
module Blastengine
|
4
4
|
class Mail < Base
|
5
5
|
include Blastengine
|
6
|
-
attr_accessor :to, :cc, :bcc, :subject, :text_part, :encode, :html_part, :attachments, :delivery_id
|
6
|
+
attr_accessor :to, :cc, :bcc, :subject, :text_part, :encode, :html_part, :attachments, :delivery_id, :list_unsubscribe
|
7
|
+
|
7
8
|
def initialize
|
8
9
|
@to = []
|
9
10
|
@cc = []
|
10
11
|
@bcc = []
|
11
12
|
@attachments = []
|
12
13
|
@encode = "UTF-8"
|
14
|
+
@list_unsubscribe = {
|
15
|
+
url: "",
|
16
|
+
email: ""
|
17
|
+
}
|
13
18
|
end
|
14
19
|
|
15
20
|
#
|
@@ -50,6 +55,7 @@ module Blastengine
|
|
50
55
|
bulk.encode = @encode
|
51
56
|
bulk.text_part = @text_part
|
52
57
|
bulk.html_part = @html_part
|
58
|
+
bulk.unsubscribe url: @list_unsubscribe[:url], email: @list_unsubscribe[:email]
|
53
59
|
if @attachments.size > 0
|
54
60
|
bulk.attachments = @attachments
|
55
61
|
end
|
@@ -74,6 +80,7 @@ module Blastengine
|
|
74
80
|
transaction.insert_code = @to[0][:insert_code] if @to[0][:insert_code].size > 0
|
75
81
|
transaction.cc = @cc if @cc.size > 0
|
76
82
|
transaction.bcc = @bcc if @bcc.size > 0
|
83
|
+
transaction.unsubscribe url: @list_unsubscribe[:url], email: @list_unsubscribe[:email]
|
77
84
|
if @attachments.size > 0
|
78
85
|
transaction.attachments = @attachments
|
79
86
|
end
|
@@ -101,5 +108,19 @@ module Blastengine
|
|
101
108
|
res = Mail.client.get url
|
102
109
|
return res['data'].map {|params| Mail.from_hash params }
|
103
110
|
end
|
111
|
+
|
112
|
+
def self.all(params = {})
|
113
|
+
Hash[ params.map{|k,v| [k.to_sym, v] } ]
|
114
|
+
if params[:delivery_start] != nil
|
115
|
+
params[:delivery_start] = params[:delivery_start].iso8601
|
116
|
+
end
|
117
|
+
if params[:delivery_end] != nil
|
118
|
+
params[:delivery_end] = params[:delivery_end].iso8601
|
119
|
+
end
|
120
|
+
query_string = URI.encode_www_form(params)
|
121
|
+
url = "/deliveries/all?#{query_string}";
|
122
|
+
res = Mail.client.get url
|
123
|
+
return res['data'].map {|params| Mail.from_hash params }
|
124
|
+
end
|
104
125
|
end
|
105
126
|
end
|
@@ -3,7 +3,7 @@ require 'date'
|
|
3
3
|
module Blastengine
|
4
4
|
class Transaction < Base
|
5
5
|
include Blastengine
|
6
|
-
attr_accessor :to, :cc, :bcc, :subject, :text_part, :encode, :html_part, :attachments, :insert_code
|
6
|
+
attr_accessor :to, :cc, :bcc, :subject, :text_part, :encode, :html_part, :attachments, :insert_code, :list_unsubscribe
|
7
7
|
def initialize
|
8
8
|
@to = ""
|
9
9
|
@cc = []
|
@@ -11,6 +11,10 @@ module Blastengine
|
|
11
11
|
@attachments = []
|
12
12
|
@encode = "UTF-8"
|
13
13
|
@insert_code = {}
|
14
|
+
@list_unsubscribe = {
|
15
|
+
url: "",
|
16
|
+
email: ""
|
17
|
+
}
|
14
18
|
end
|
15
19
|
|
16
20
|
#
|
@@ -46,6 +50,11 @@ module Blastengine
|
|
46
50
|
}
|
47
51
|
end
|
48
52
|
end
|
53
|
+
unless @list_unsubscribe.nil?
|
54
|
+
data[:list_unsubscribe] = {}
|
55
|
+
data[:list_unsubscribe][:url] = @list_unsubscribe[:url] if !@list_unsubscribe[:url].nil? && @list_unsubscribe[:url] != ""
|
56
|
+
data[:list_unsubscribe][:mailto] = "mailto:#{@list_unsubscribe[:email]}" if !@list_unsubscribe[:email].nil? && @list_unsubscribe[:email] != ""
|
57
|
+
end
|
49
58
|
# API実行
|
50
59
|
res = @@client.post path, data, @attachments
|
51
60
|
# エラーがあったら例外を投げるので、この場合は通常終了
|
data/lib/blastengine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blastengine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atsushi Nakatsugawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a SDK for sending email by blastengine.
|
14
14
|
email:
|