customers_mail_cloud 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +22 -0
- data/lib/customers_mail_cloud.rb +1 -0
- data/lib/customers_mail_cloud/client.rb +12 -0
- data/lib/customers_mail_cloud/transaction.rb +91 -0
- data/lib/customers_mail_cloud/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ace0a622b1296cfaf753148596ae5dbc4353b003b47dab9281918b967b4d4b
|
4
|
+
data.tar.gz: 19068e35c021e5439f4a2ecb8e583ca2fc15d24f971c755f445a1f8082c3cac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83b5986d9996d2ef206091e73c393258dd9698b353912709533e6f5ddcba3972ca8ad883b7064490e3b9dd90ee8bc46e0adaf99533ef6b2ac9e93421911e859
|
7
|
+
data.tar.gz: bbc629ed5f045b77f37dbc6eb18f56b9efb09a2f1842b1cc3fd401b366c8ec0263b0e8701244e61d88546c23f12222c3af195f889b8913d361514f921b225c62
|
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).
|
data/lib/customers_mail_cloud.rb
CHANGED
@@ -36,6 +36,18 @@ module CustomersMailCloud
|
|
36
36
|
@url = @endpoints[:pro].gsub('SUBDOMAIN', subdomain)
|
37
37
|
end
|
38
38
|
|
39
|
+
def bounce
|
40
|
+
Transaction.new 'bounces', self
|
41
|
+
end
|
42
|
+
|
43
|
+
def delivery
|
44
|
+
Transaction.new 'deliveries', self
|
45
|
+
end
|
46
|
+
|
47
|
+
def block
|
48
|
+
Transaction.new 'blocks', self
|
49
|
+
end
|
50
|
+
|
39
51
|
def send
|
40
52
|
raise Error.new '契約プランを選択してください(trial/standard/pro)' if @url == nil || @url == ''
|
41
53
|
raise Error.new '送信元アドレスは必須です' if @from == nil
|
@@ -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
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atsushi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-25 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:
|