customers_mail_cloud 0.2.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/Gemfile.lock +1 -1
- data/README.md +22 -0
- data/lib/customers_mail_cloud/client.rb +22 -2
- data/lib/customers_mail_cloud/transaction.rb +91 -0
- data/lib/customers_mail_cloud/version.rb +1 -1
- data/lib/customers_mail_cloud.rb +1 -0
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7cdbca25fe57436409f8390d3ab6dc5a61fe8540ba2abab0604e906e2be332ad
|
|
4
|
+
data.tar.gz: 545610d4b3b4db204a841e7f56599543ed9dd25224c3cf05fff3c98f232c55fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b9b17b636422c284695ec6fe05e9f553f30c3d599b47934dc917136a917a6c97739155a3f4af5ba11c57886fbec25935621817fc9328134314f31987b3e2c5f
|
|
7
|
+
data.tar.gz: b7b38ad6e256d39a3f93a2e63d949a4ea2a86d71930ca368fbdc41bda1959f2e369a1f02969d645d4097fe9f953e79d8f45fd4b80873fa604adbac12cc6f784f
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -49,6 +49,28 @@ client.attachments << open("./test.rb")
|
|
|
49
49
|
json = client.send
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
## Get Transaction
|
|
53
|
+
|
|
54
|
+
### Get bounce
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
bounce = @client.bounce
|
|
58
|
+
bounce.server_composition = 'sandbox'
|
|
59
|
+
bounce.start_date = Date.parse("2020-11-20")
|
|
60
|
+
bounce.limit = 100
|
|
61
|
+
bounce.list
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Get delivery
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
delivery = @client.bounce
|
|
68
|
+
delivery.server_composition = 'sandbox'
|
|
69
|
+
delivery.date = Date.parse("2020-11-20")
|
|
70
|
+
delivery.limit = 100
|
|
71
|
+
delivery.list
|
|
72
|
+
```
|
|
73
|
+
|
|
52
74
|
## Contributing
|
|
53
75
|
|
|
54
76
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/customers_mail_cloud. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/customers_mail_cloud/blob/master/CODE_OF_CONDUCT.md).
|
|
@@ -19,10 +19,14 @@ module CustomersMailCloud
|
|
|
19
19
|
@subject = ''
|
|
20
20
|
@text = ''
|
|
21
21
|
@html = ''
|
|
22
|
+
@envfrom = nil
|
|
23
|
+
@replyto = nil
|
|
24
|
+
@headers = {}
|
|
25
|
+
@charset = 'UTF-8'
|
|
22
26
|
@attachments = []
|
|
23
27
|
end
|
|
24
28
|
attr_accessor :api_user, :api_key, :to, :from,
|
|
25
|
-
:subject, :text, :html, :attachments
|
|
29
|
+
:subject, :text, :html, :envfrom, :replyto, :headers, :charset, :attachments
|
|
26
30
|
def trial
|
|
27
31
|
@url = @endpoints[:trial]
|
|
28
32
|
end
|
|
@@ -36,6 +40,18 @@ module CustomersMailCloud
|
|
|
36
40
|
@url = @endpoints[:pro].gsub('SUBDOMAIN', subdomain)
|
|
37
41
|
end
|
|
38
42
|
|
|
43
|
+
def bounce
|
|
44
|
+
Transaction.new 'bounces', self
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def delivery
|
|
48
|
+
Transaction.new 'deliveries', self
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def block
|
|
52
|
+
Transaction.new 'blocks', self
|
|
53
|
+
end
|
|
54
|
+
|
|
39
55
|
def send
|
|
40
56
|
raise Error.new '契約プランを選択してください(trial/standard/pro)' if @url == nil || @url == ''
|
|
41
57
|
raise Error.new '送信元アドレスは必須です' if @from == nil
|
|
@@ -51,7 +67,11 @@ module CustomersMailCloud
|
|
|
51
67
|
subject: @subject,
|
|
52
68
|
text: @text
|
|
53
69
|
}
|
|
54
|
-
params
|
|
70
|
+
params[:envfrom] = @envfrom if @envfrom
|
|
71
|
+
params[:replyto] = @replyto if @replyto
|
|
72
|
+
params[:headers] = @headers if @headers.size > 0
|
|
73
|
+
params[:charset] = @charset if @charset != 'UTF-8'
|
|
74
|
+
params[:html] = @html if @html != ''
|
|
55
75
|
headers = {
|
|
56
76
|
'Content-Type': 'application/json',
|
|
57
77
|
'Accept': 'application/json'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module CustomersMailCloud
|
|
2
|
+
class Transaction
|
|
3
|
+
def initialize type, client
|
|
4
|
+
@client = client
|
|
5
|
+
@type = type
|
|
6
|
+
@server_composition = nil
|
|
7
|
+
@base_url = 'https://api.smtps.jp/transaction/v2/__TYPE__/__ACTION__.json'
|
|
8
|
+
@params = {}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
attr_accessor :server_composition
|
|
12
|
+
|
|
13
|
+
def url action
|
|
14
|
+
@base_url.gsub('__TYPE__', @type).gsub('__ACTION__', action)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def list
|
|
18
|
+
params = @params
|
|
19
|
+
params[:api_user] = @client.api_user
|
|
20
|
+
params[:api_key] = @client.api_key
|
|
21
|
+
unless @server_composition
|
|
22
|
+
raise Error.new('Server Composition is required.')
|
|
23
|
+
end
|
|
24
|
+
params[:server_composition] = @server_composition
|
|
25
|
+
headers = {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'Accept': 'application/json'
|
|
28
|
+
}
|
|
29
|
+
uri = URI.parse url('list')
|
|
30
|
+
req = Net::HTTP::Post.new(uri.path)
|
|
31
|
+
req.body = params.to_json
|
|
32
|
+
headers.each do |k, v|
|
|
33
|
+
req[k] = v
|
|
34
|
+
end
|
|
35
|
+
http = Net::HTTP.new uri.host, uri.port
|
|
36
|
+
http.use_ssl = true
|
|
37
|
+
response = http.request req
|
|
38
|
+
if response.code == '200' || response.code == '204'
|
|
39
|
+
return [] if response.body.nil?
|
|
40
|
+
return JSON.parse(response.body)[@type]
|
|
41
|
+
else
|
|
42
|
+
message = JSON.parse(response.body)['errors'].map do |error|
|
|
43
|
+
"#{error['message']} (#{error['code']})"
|
|
44
|
+
end.join(" ")
|
|
45
|
+
raise Error.new message
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def email= address
|
|
50
|
+
@params[:email] = address
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def status= status
|
|
54
|
+
@params[:status] = status
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def start_date= date
|
|
58
|
+
@params[:start_date] = date.strftime('%Y-%m-%d')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def end_date= date
|
|
62
|
+
@params[:end_date] = date.strftime('%Y-%m-%d')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def date= date
|
|
66
|
+
@params[:date] = date.strftime('%Y-%m-%d')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def hour= hour
|
|
70
|
+
if hour < 0 || hour > 23
|
|
71
|
+
raise Error.new('hour allows the range from 0 to 23.')
|
|
72
|
+
end
|
|
73
|
+
@params[:hour] = hour
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def minute= minute
|
|
77
|
+
if minute < 0 || minute > 59
|
|
78
|
+
raise Error.new('minute allows the range from 0 to 59.')
|
|
79
|
+
end
|
|
80
|
+
@params[:minute] = minute
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def page= page
|
|
84
|
+
@params[:p] = page
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def limit= limit
|
|
88
|
+
@params[:r] = limit
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/lib/customers_mail_cloud.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: customers_mail_cloud
|
|
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
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-07-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Ruby library for Customers Mail Cloud. Customers Mail Cloud is email
|
|
14
14
|
sending service provider that supports SMTP or Web API.
|
|
@@ -33,6 +33,7 @@ files:
|
|
|
33
33
|
- lib/customers_mail_cloud.rb
|
|
34
34
|
- lib/customers_mail_cloud/client.rb
|
|
35
35
|
- lib/customers_mail_cloud/mail_address.rb
|
|
36
|
+
- lib/customers_mail_cloud/transaction.rb
|
|
36
37
|
- lib/customers_mail_cloud/version.rb
|
|
37
38
|
homepage: https://smtps.jp/
|
|
38
39
|
licenses:
|
|
@@ -41,7 +42,7 @@ metadata:
|
|
|
41
42
|
homepage_uri: https://smtps.jp/
|
|
42
43
|
source_code_uri: https://github.com/goofmint/CustmersMailCloud-rb
|
|
43
44
|
changelog_uri: https://github.com/goofmint/CustmersMailCloud-rb/CHANGELOG
|
|
44
|
-
post_install_message:
|
|
45
|
+
post_install_message:
|
|
45
46
|
rdoc_options: []
|
|
46
47
|
require_paths:
|
|
47
48
|
- lib
|
|
@@ -56,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
56
57
|
- !ruby/object:Gem::Version
|
|
57
58
|
version: '0'
|
|
58
59
|
requirements: []
|
|
59
|
-
rubygems_version: 3.
|
|
60
|
-
signing_key:
|
|
60
|
+
rubygems_version: 3.4.9
|
|
61
|
+
signing_key:
|
|
61
62
|
specification_version: 4
|
|
62
63
|
summary: Ruby library for Customers Mail Cloud
|
|
63
64
|
test_files: []
|