blastengine 0.3.0 → 0.4.0
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 +6 -0
- data/lib/blastengine/bulk.rb +12 -0
- data/lib/blastengine/client.rb +1 -1
- data/lib/blastengine/download.rb +20 -0
- data/lib/blastengine/email.rb +71 -0
- data/lib/blastengine/job.rb +2 -12
- data/lib/blastengine/report.rb +37 -0
- data/lib/blastengine/version.rb +1 -1
- data/lib/blastengine.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb192455e96f1e16a8c2d70ac2035758bef80f0d5e56c0c651b33dd118558f15
|
4
|
+
data.tar.gz: 6fc1ef4846f1090cb4b57b38fe1ff1c063a8eeb4f47cadff2a930fb62b1af0f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c44da8ddac18082ebcf1fe7a3007bf242e7b3d3236c4b6479df8ae643b1f0f8762122716b87f8795cc245ad6ebe97aafa0de0e5325a6db2f59d6ad96da1cb76
|
7
|
+
data.tar.gz: 7001480e3afe9debb0d7ec8c95996450c79bb0e92eafbdbdc37758ea2aa7c277e938b8772b2a362d537f8ca32ca904d506028a2ac4645d265cb5208c53d6a842
|
data/lib/blastengine/base.rb
CHANGED
data/lib/blastengine/bulk.rb
CHANGED
@@ -85,6 +85,14 @@ module Blastengine
|
|
85
85
|
return res["delivery_id"]
|
86
86
|
end
|
87
87
|
|
88
|
+
def cancel
|
89
|
+
# APIリクエスト用のパス
|
90
|
+
path = "/deliveries/#{@delivery_id}/cancel"
|
91
|
+
# API実行
|
92
|
+
res = @@client.patch path, {}
|
93
|
+
return res["delivery_id"]
|
94
|
+
end
|
95
|
+
|
88
96
|
def import(file, ignore_errors = false)
|
89
97
|
# APIリクエスト用のパス
|
90
98
|
path = "/deliveries/#{@delivery_id}/emails/import"
|
@@ -94,4 +102,8 @@ module Blastengine
|
|
94
102
|
return @job
|
95
103
|
end
|
96
104
|
end
|
105
|
+
|
106
|
+
def email
|
107
|
+
Blastengine::Email.new(@delivery_id)
|
108
|
+
end
|
97
109
|
end
|
data/lib/blastengine/client.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "zip"
|
2
|
+
require "tempfile"
|
3
|
+
|
4
|
+
module Blastengine
|
5
|
+
class Download < Base
|
6
|
+
include Blastengine
|
7
|
+
|
8
|
+
def download res
|
9
|
+
f = Tempfile.create("blastengine")
|
10
|
+
f.binmode
|
11
|
+
f.write res
|
12
|
+
f.flush
|
13
|
+
path = f.path
|
14
|
+
input = Zip::File.open path
|
15
|
+
data = input.read input.entries[0].to_s
|
16
|
+
f.close
|
17
|
+
return data
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Blastengine
|
2
|
+
class Email < Base
|
3
|
+
include Blastengine
|
4
|
+
attr_accessor :delivery_id, :address, :insert_code, :email_id, :created_time, :updated_time
|
5
|
+
def initialize delivery_id
|
6
|
+
@delivery_id = delivery_id
|
7
|
+
@insert_code = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def get
|
11
|
+
# APIリクエスト用のパス
|
12
|
+
path = "/deliveries/-/emails/#{@email_id}"
|
13
|
+
# API実行
|
14
|
+
res = @@client.get path
|
15
|
+
@email_id = res["email_id"]
|
16
|
+
res["insert_code"].each do |params|
|
17
|
+
@insert_code[params["key"].gsub("__", "")] = params["value"]
|
18
|
+
end
|
19
|
+
@address = res["email"]
|
20
|
+
@created_time = Time.parse(res["created_time"])
|
21
|
+
@updated_time = Time.parse(res["updated_time"])
|
22
|
+
return res["email_id"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def save
|
26
|
+
# APIリクエスト用のパス
|
27
|
+
if @email_id.nil?
|
28
|
+
return create
|
29
|
+
else
|
30
|
+
return update
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create
|
35
|
+
path = "/deliveries/#{@delivery_id}/emails"
|
36
|
+
params = {
|
37
|
+
email: @address,
|
38
|
+
insert_code: @insert_code.map{|key, value| {
|
39
|
+
key: "__#{key}__",
|
40
|
+
value: value
|
41
|
+
}}
|
42
|
+
}
|
43
|
+
# API実行
|
44
|
+
res = @@client.post path, params
|
45
|
+
@email_id = res["email_id"]
|
46
|
+
return res["email_id"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def update
|
50
|
+
path = "/deliveries/-/emails/#{@email_id}"
|
51
|
+
params = {
|
52
|
+
email: @address,
|
53
|
+
insert_code: @insert_code.map{|key, value| {
|
54
|
+
key: "__#{key}__",
|
55
|
+
value: value
|
56
|
+
}}
|
57
|
+
}
|
58
|
+
# API実行
|
59
|
+
res = @@client.put path, params
|
60
|
+
@email_id = res["email_id"]
|
61
|
+
return res["email_id"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete
|
65
|
+
path = "/deliveries/-/emails/#{@email_id}"
|
66
|
+
# API実行
|
67
|
+
res = @@client.delete path
|
68
|
+
return res["email_id"]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/blastengine/job.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
require "time"
|
2
|
-
require "zip"
|
3
|
-
require "tempfile"
|
4
|
-
|
5
1
|
module Blastengine
|
6
|
-
class Job <
|
2
|
+
class Job < Download
|
7
3
|
include Blastengine
|
8
4
|
attr_accessor :job_id, :percentage, :status, :error_file_url, :success_count, :failed_count, :total_count
|
9
5
|
def initialize id
|
@@ -28,13 +24,7 @@ module Blastengine
|
|
28
24
|
return nil if @error_file_url.nil?
|
29
25
|
path = "/deliveries/-/emails/import/#{@job_id}/errorinfo/download"
|
30
26
|
res = @@client.get path, true
|
31
|
-
|
32
|
-
f.binmode
|
33
|
-
f.write res
|
34
|
-
f.flush
|
35
|
-
path = f.path
|
36
|
-
input = Zip::File.open path
|
37
|
-
@error_message = input.read input.entries[0].to_s
|
27
|
+
@error_message = download res
|
38
28
|
@error_message
|
39
29
|
end
|
40
30
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Blastengine
|
2
|
+
class Report < Download
|
3
|
+
include Blastengine
|
4
|
+
attr_accessor :job_id, :delivery_id, :percentage, :status, :mail_open_file_url, :total_count, :report
|
5
|
+
def initialize delivery_id
|
6
|
+
@delivery_id = delivery_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
# APIリクエスト用のパス
|
11
|
+
path = "/deliveries/#{@delivery_id}/analysis/report"
|
12
|
+
res = @@client.post path
|
13
|
+
@job_id = res["job_id"]
|
14
|
+
return @job_id
|
15
|
+
end
|
16
|
+
|
17
|
+
def finish?
|
18
|
+
# APIリクエスト用のパス
|
19
|
+
path = "/deliveries/-/analysis/report/#{@job_id}"
|
20
|
+
res = @@client.get path
|
21
|
+
@percentage = res["percentage"]
|
22
|
+
@status = res["status"]
|
23
|
+
@total_count = res["total_count"] unless res["total_count"].nil?
|
24
|
+
@mail_open_file_url = res["mail_open_file_url"] unless res["mail_open_file_url"].nil?
|
25
|
+
return @percentage == 100
|
26
|
+
end
|
27
|
+
|
28
|
+
def get
|
29
|
+
return @report unless @report.nil?
|
30
|
+
return nil unless @percentage == 100
|
31
|
+
path = "/deliveries/-/analysis/report/#{@job_id}/download"
|
32
|
+
res = @@client.get path, true
|
33
|
+
@report = download res
|
34
|
+
@report
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/blastengine/version.rb
CHANGED
data/lib/blastengine.rb
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
require_relative "blastengine/version"
|
4
4
|
require "blastengine/client"
|
5
5
|
require "blastengine/base"
|
6
|
+
require "blastengine/download"
|
6
7
|
require "blastengine/transaction"
|
7
8
|
require "blastengine/bulk"
|
8
9
|
require "blastengine/job"
|
9
10
|
require "blastengine/usage"
|
11
|
+
require "blastengine/email"
|
12
|
+
require "blastengine/report"
|
10
13
|
|
11
14
|
module Blastengine
|
12
15
|
class Error < StandardError; end
|
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.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atsushi Nakatsugawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a SDK for sending email by blastengine.
|
14
14
|
email:
|
@@ -30,7 +30,10 @@ files:
|
|
30
30
|
- lib/blastengine/base.rb
|
31
31
|
- lib/blastengine/bulk.rb
|
32
32
|
- lib/blastengine/client.rb
|
33
|
+
- lib/blastengine/download.rb
|
34
|
+
- lib/blastengine/email.rb
|
33
35
|
- lib/blastengine/job.rb
|
36
|
+
- lib/blastengine/report.rb
|
34
37
|
- lib/blastengine/transaction.rb
|
35
38
|
- lib/blastengine/usage.rb
|
36
39
|
- lib/blastengine/version.rb
|