sendgrid4r 0.0.2 → 0.0.4
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/README.md +70 -8
- data/lib/sendgrid4r/rest/addresses.rb +64 -0
- data/lib/sendgrid4r/rest/api.rb +4 -2
- data/lib/sendgrid4r/rest/groups.rb +20 -19
- data/lib/sendgrid4r/rest/pools.rb +53 -0
- data/lib/sendgrid4r/rest/request.rb +6 -0
- data/lib/sendgrid4r/rest/suppressions.rb +10 -11
- data/lib/sendgrid4r/rest/templates.rb +14 -14
- data/lib/sendgrid4r/rest/versions.rb +0 -1
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/addresses_spec.rb +47 -0
- data/spec/client_spec.rb +34 -16
- data/spec/pools_spec.rb +75 -0
- metadata +9 -6
- data/lib/sendgrid4r/rest/ip_addresses.rb +0 -46
- data/spec/ip_addresses_spec.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0db3013d7c882c2bcb1c3fac0f255e67f6643003
|
|
4
|
+
data.tar.gz: e93b5ac5f804506349d97fe9a5eb302da2ca1248
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4107cc159f95eea46b62c203719e35cbb75529622a02a337fe79ac01c292bbb3ddfe12eacd2e3706bbc2c305377defa28af503489e4af7ff49a4a633537aedcd
|
|
7
|
+
data.tar.gz: 74821591aa3c7c5a5d38b1364f3730ad1d148c865f5bb762e236914089aa04cbecbba015dfe47ab344ce7c84191d3c2c80d55afdeaa71a81de3636d6516eec87
|
data/README.md
CHANGED
|
@@ -36,7 +36,7 @@ client = Sendgrid4r::Client.new("user", "pass")
|
|
|
36
36
|
#### Groups
|
|
37
37
|
|
|
38
38
|
##### GET
|
|
39
|
-
|
|
39
|
+
Retrieve all suppression groups associated with your account.
|
|
40
40
|
```Ruby
|
|
41
41
|
groups = client.get_groups
|
|
42
42
|
groups.each{|group|
|
|
@@ -49,7 +49,7 @@ groups.each{|group|
|
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
##### GET
|
|
52
|
-
Get
|
|
52
|
+
Get information on a single suppression group.
|
|
53
53
|
```Ruby
|
|
54
54
|
group = client.get_group(100)
|
|
55
55
|
puts group.id # => 100
|
|
@@ -60,13 +60,13 @@ puts group.unsubscribes # => 400
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
##### POST
|
|
63
|
-
Create a suppression group.
|
|
63
|
+
Create a new suppression group.
|
|
64
64
|
```Ruby
|
|
65
65
|
new_group = client.post_group("group_name", "group_desc")
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
##### PATCH
|
|
69
|
-
|
|
69
|
+
Update a suppression group.
|
|
70
70
|
```Ruby
|
|
71
71
|
new_group.name = "group_edit"
|
|
72
72
|
new_group.description = "group_desc_edit"
|
|
@@ -74,7 +74,7 @@ client.patch_group(new_group.id, new_group)
|
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
##### DELETE
|
|
77
|
-
Delete
|
|
77
|
+
Delete a suppression group.
|
|
78
78
|
```Ruby
|
|
79
79
|
client.delete_group(100)
|
|
80
80
|
```
|
|
@@ -102,7 +102,7 @@ suppressions.each{|suppression|
|
|
|
102
102
|
##### GET
|
|
103
103
|
Retrieve suppressed emails for a group.
|
|
104
104
|
```Ruby
|
|
105
|
-
emails = client.get_suppressed_emails(
|
|
105
|
+
emails = client.get_suppressed_emails(100)
|
|
106
106
|
emails.each{|email|
|
|
107
107
|
puts email
|
|
108
108
|
}
|
|
@@ -111,7 +111,7 @@ emails.each{|email|
|
|
|
111
111
|
##### DELETE
|
|
112
112
|
Delete a recipient email from the suppressions list for a given group.
|
|
113
113
|
```Ruby
|
|
114
|
-
client.
|
|
114
|
+
client.delete_suppressed_email(100, "email1@address.com")
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
#### Global Suppressions
|
|
@@ -140,16 +140,78 @@ client.delete_global_suppressed_email("email1@address.com")
|
|
|
140
140
|
#### IP Addresses
|
|
141
141
|
|
|
142
142
|
##### GET
|
|
143
|
-
See a list of all IPs and the IPs warm up status.
|
|
143
|
+
See a list of all IPs and the IPs, including warm up status and pools.
|
|
144
144
|
```Ruby
|
|
145
145
|
ips = client.get_ips
|
|
146
146
|
ips.each{|ip|
|
|
147
147
|
puts ip.ip # => "xxx.xxx.xxx.xxx"
|
|
148
|
+
puts ip.pools # => ["new_test5"]
|
|
148
149
|
puts ip.warmup # => true/false
|
|
149
150
|
puts ip.start_date # => 1409616000
|
|
150
151
|
}
|
|
151
152
|
```
|
|
152
153
|
|
|
154
|
+
##### GET
|
|
155
|
+
See which pools an IP address belongs to.
|
|
156
|
+
```Ruby
|
|
157
|
+
ip = client.get_ip("xxx.xxx.xxx.xxx")
|
|
158
|
+
puts ip.ip # => "xxx.xxx.xxx.xxx"
|
|
159
|
+
puts ip.pools # => ["new_test5"]
|
|
160
|
+
puts ip.warmup # => true/false
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
##### POST
|
|
164
|
+
Add an IP to a pool.
|
|
165
|
+
```Ruby
|
|
166
|
+
ip = client.post_ip_to_pool("pool_name", "xxx.xxx.xxx.xxx")
|
|
167
|
+
puts ip.ip # => "xxx.xxx.xxx.xxx"
|
|
168
|
+
puts ip.pool_name # => "new_test5"
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
##### DELETE
|
|
172
|
+
Remove an IP address from a pool.
|
|
173
|
+
```Ruby
|
|
174
|
+
client.delete_ip_from_pool("xxx.xxx.xxx.xxx")
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### IP Pools
|
|
178
|
+
|
|
179
|
+
##### GET
|
|
180
|
+
List all IP pools.
|
|
181
|
+
```Ruby
|
|
182
|
+
pools = client.get_pools
|
|
183
|
+
puts pools.inspect # => ["marketing","transactional"]
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
##### POST
|
|
187
|
+
Create an IP pool.
|
|
188
|
+
```Ruby
|
|
189
|
+
pool = client.post_pool("name")
|
|
190
|
+
puts pool.name # => "name"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
##### GET
|
|
194
|
+
List the IPs in a specified pool.
|
|
195
|
+
```Ruby
|
|
196
|
+
pool = client.get_pool("name")
|
|
197
|
+
puts pool.name # => "name"
|
|
198
|
+
puts pool.ips.inspect # => ["167.89.21.3"]
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
##### PUT
|
|
202
|
+
Update an IP pool’s name
|
|
203
|
+
```Ruby
|
|
204
|
+
client.put_pool("name", "new_name")
|
|
205
|
+
puts pool.name # => "name"
|
|
206
|
+
puts pool.ips.inspect # => ["167.89.21.3"]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
##### DELETE
|
|
210
|
+
Delete an IP pool.
|
|
211
|
+
```Ruby
|
|
212
|
+
client.delete_pool("name")
|
|
213
|
+
```
|
|
214
|
+
|
|
153
215
|
#### IP Warmup
|
|
154
216
|
|
|
155
217
|
##### GET
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.unshift File.dirname(__FILE__)
|
|
3
|
+
|
|
4
|
+
require "sendgrid4r/rest/request"
|
|
5
|
+
|
|
6
|
+
module SendGrid4r
|
|
7
|
+
module REST
|
|
8
|
+
module Ips
|
|
9
|
+
module Addresses
|
|
10
|
+
|
|
11
|
+
include SendGrid4r::REST::Request
|
|
12
|
+
|
|
13
|
+
def get_ips
|
|
14
|
+
response = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips")
|
|
15
|
+
ips = Array.new
|
|
16
|
+
response.each{|ip|
|
|
17
|
+
ip_address = Address.create(ip)
|
|
18
|
+
ips.push(ip_address)
|
|
19
|
+
} if response.length > 0
|
|
20
|
+
ips
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_ip(ip)
|
|
24
|
+
Address.create(get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/#{ip}"))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def post_ip_to_pool(pool_name, ip)
|
|
28
|
+
params = Hash.new
|
|
29
|
+
params["ip"] = ip
|
|
30
|
+
Address.create(post(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{pool_name}/ips", params))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def delete_ip_from_pool(ip)
|
|
34
|
+
params = Hash.new
|
|
35
|
+
params["ip"] = ip
|
|
36
|
+
delete(@auth,"#{SendGrid4r::Client::BASE_URL}/ips/pools/#{pool_name}/ips", params)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
class Address
|
|
42
|
+
|
|
43
|
+
attr_accessor :ip, :pools, :warmup, :start_date, :pool_name
|
|
44
|
+
|
|
45
|
+
def self.create(value)
|
|
46
|
+
obj = Address.new
|
|
47
|
+
obj.ip = value["ip"]
|
|
48
|
+
obj.pools = []
|
|
49
|
+
value["pools"].each{|pool|
|
|
50
|
+
ver = Pool.create(pool)
|
|
51
|
+
obj.pools.push(ver)
|
|
52
|
+
}
|
|
53
|
+
obj.warmup = value["warmup"]
|
|
54
|
+
obj.start_date = value["start_date"]
|
|
55
|
+
obj.pool_name = value["pool_name"]
|
|
56
|
+
obj
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
data/lib/sendgrid4r/rest/api.rb
CHANGED
|
@@ -4,7 +4,8 @@ require "sendgrid4r/rest/groups"
|
|
|
4
4
|
require "sendgrid4r/rest/suppressions"
|
|
5
5
|
require "sendgrid4r/rest/global_suppressions"
|
|
6
6
|
require "sendgrid4r/rest/enforced_tls"
|
|
7
|
-
require "sendgrid4r/rest/
|
|
7
|
+
require "sendgrid4r/rest/addresses"
|
|
8
|
+
require "sendgrid4r/rest/pools"
|
|
8
9
|
require "sendgrid4r/rest/warmup"
|
|
9
10
|
|
|
10
11
|
module SendGrid4r
|
|
@@ -16,8 +17,9 @@ module SendGrid4r
|
|
|
16
17
|
include SendGrid4r::REST::Asm::Suppressions
|
|
17
18
|
include SendGrid4r::REST::Asm::GlobalSuppressions
|
|
18
19
|
include SendGrid4r::REST::Settings::EnforcedTls
|
|
19
|
-
include SendGrid4r::REST::Ips::
|
|
20
|
+
include SendGrid4r::REST::Ips::Addresses
|
|
20
21
|
include SendGrid4r::REST::Ips::Warmup
|
|
22
|
+
include SendGrid4r::REST::Ips::Pools
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
end
|
|
@@ -39,31 +39,32 @@ module SendGrid4r
|
|
|
39
39
|
delete(@auth, "#{SendGrid4r::Client::BASE_URL}/asm/groups/#{group_id}")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
end
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
class Group
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
obj = Group.new
|
|
48
|
-
obj.id = value["id"]
|
|
49
|
-
obj.name = value["name"]
|
|
50
|
-
obj.description = value["description"]
|
|
51
|
-
obj.last_email_sent_at = value["last_email_sent_at"]
|
|
52
|
-
obj.unsubscribes = value["unsubscribes"]
|
|
53
|
-
obj
|
|
54
|
-
end
|
|
46
|
+
attr_accessor :id, :name, :description, :last_email_sent_at, :unsubscribes
|
|
55
47
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
48
|
+
def self.create(value)
|
|
49
|
+
obj = Group.new
|
|
50
|
+
obj.id = value["id"]
|
|
51
|
+
obj.name = value["name"]
|
|
52
|
+
obj.description = value["description"]
|
|
53
|
+
obj.last_email_sent_at = value["last_email_sent_at"]
|
|
54
|
+
obj.unsubscribes = value["unsubscribes"]
|
|
55
|
+
obj
|
|
56
|
+
end
|
|
63
57
|
|
|
58
|
+
def to_hash
|
|
59
|
+
hash = {
|
|
60
|
+
"name" => @name,
|
|
61
|
+
"description" => @description,
|
|
62
|
+
}
|
|
63
|
+
hash
|
|
64
64
|
end
|
|
65
|
+
|
|
65
66
|
end
|
|
66
|
-
end
|
|
67
67
|
|
|
68
|
+
end
|
|
68
69
|
end
|
|
69
70
|
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.unshift File.dirname(__FILE__)
|
|
3
|
+
|
|
4
|
+
require "sendgrid4r/rest/request"
|
|
5
|
+
|
|
6
|
+
module SendGrid4r
|
|
7
|
+
module REST
|
|
8
|
+
module Ips
|
|
9
|
+
module Pools
|
|
10
|
+
|
|
11
|
+
include SendGrid4r::REST::Request
|
|
12
|
+
|
|
13
|
+
def get_pools
|
|
14
|
+
get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def post_pool(name)
|
|
18
|
+
params = Hash.new
|
|
19
|
+
params["name"] = name
|
|
20
|
+
Pool.create(post(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools", params))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_pool(name)
|
|
24
|
+
Pool.create(get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}"))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def put_pool(name, new_name)
|
|
28
|
+
params = Hash.new
|
|
29
|
+
params["name"] = new_name
|
|
30
|
+
Pool.create(put(@auth, "#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}", params))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def delete_pool(name)
|
|
34
|
+
delete(@auth,"#{SendGrid4r::Client::BASE_URL}/ips/pools/#{name}")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class Pool
|
|
40
|
+
|
|
41
|
+
attr_accessor :name, :ips
|
|
42
|
+
|
|
43
|
+
def self.create(value)
|
|
44
|
+
obj = Pool.new
|
|
45
|
+
obj.name = value["name"]
|
|
46
|
+
obj.ips = value["ips"]
|
|
47
|
+
obj
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -31,6 +31,12 @@ module SendGrid4r
|
|
|
31
31
|
JSON.parse(body)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def put(auth, endpoint, params)
|
|
35
|
+
resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
|
|
36
|
+
body = resource.put(params.to_json, :content_type => :json).body
|
|
37
|
+
JSON.parse(body)
|
|
38
|
+
end
|
|
39
|
+
|
|
34
40
|
def delete(auth, endpoint)
|
|
35
41
|
resource = RestClient::Resource.new(endpoint, auth.get_username, auth.get_password)
|
|
36
42
|
resource.delete
|
|
@@ -36,23 +36,22 @@ module SendGrid4r
|
|
|
36
36
|
delete(@auth, "#{SendGrid4r::Client::BASE_URL}/asm/groups/#{group_id}/suppressions/#{email_address}")
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
end
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
class Suppression
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
obj = Suppression.new
|
|
45
|
-
obj.id = value["id"]
|
|
46
|
-
obj.name = value["name"]
|
|
47
|
-
obj.description = value["description"]
|
|
48
|
-
obj.suppressed = value["suppressed"]
|
|
49
|
-
obj
|
|
50
|
-
end
|
|
43
|
+
attr_accessor :id, :name, :description, :suppressed
|
|
51
44
|
|
|
45
|
+
def self.create(value)
|
|
46
|
+
obj = Suppression.new
|
|
47
|
+
obj.id = value["id"]
|
|
48
|
+
obj.name = value["name"]
|
|
49
|
+
obj.description = value["description"]
|
|
50
|
+
obj.suppressed = value["suppressed"]
|
|
51
|
+
obj
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
|
-
|
|
57
56
|
end
|
|
58
57
|
end
|
|
@@ -41,24 +41,24 @@ module SendGrid4r
|
|
|
41
41
|
delete(@auth, "#{SendGrid4r::Client::BASE_URL}/templates/#{template_id}")
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
end
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
class Template
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
obj = Template.new
|
|
50
|
-
obj.id = value["id"]
|
|
51
|
-
obj.name = value["name"]
|
|
52
|
-
obj.versions = []
|
|
53
|
-
value["versions"].each{|version|
|
|
54
|
-
ver = Version.create(version)
|
|
55
|
-
obj.versions.push(ver)
|
|
56
|
-
}
|
|
57
|
-
obj
|
|
58
|
-
end
|
|
48
|
+
attr_accessor :id, :name, :versions
|
|
59
49
|
|
|
50
|
+
def self.create(value)
|
|
51
|
+
obj = Template.new
|
|
52
|
+
obj.id = value["id"]
|
|
53
|
+
obj.name = value["name"]
|
|
54
|
+
obj.versions = []
|
|
55
|
+
value["versions"].each{|version|
|
|
56
|
+
ver = Templates::Version.create(version)
|
|
57
|
+
obj.versions.push(ver)
|
|
58
|
+
}
|
|
59
|
+
obj
|
|
60
60
|
end
|
|
61
|
-
end
|
|
62
61
|
|
|
62
|
+
end
|
|
63
63
|
end
|
|
64
64
|
end
|
data/lib/sendgrid4r/version.rb
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "SendGrid4r::REST::Ips::Addresses" do
|
|
5
|
+
|
|
6
|
+
before :all do
|
|
7
|
+
Dotenv.load
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context "free account" do
|
|
11
|
+
it "raise error for get_ips" do
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
client = SendGrid4r::Client.new(ENV["SENDGRID_USERNAME"], ENV["SENDGRID_PASSWORD"])
|
|
15
|
+
# get the ips
|
|
16
|
+
expect{client.get_ips}.to raise_error(RestClient::Forbidden)
|
|
17
|
+
# get the ip
|
|
18
|
+
expect{client.get_ip("10.10.10.10").to raise_error(RestClient::Forbidden)}
|
|
19
|
+
rescue => ex
|
|
20
|
+
puts ex.inspect
|
|
21
|
+
raise ex
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "silver account" do
|
|
29
|
+
it "returns Array of Address instance" do
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
client = SendGrid4r::Client.new(ENV["SILVER_SENDGRID_USERNAME"], ENV["SILVER_SENDGRID_PASSWORD"])
|
|
33
|
+
# get the ips
|
|
34
|
+
ips = client.get_ips
|
|
35
|
+
expect(ips.length).to be(1)
|
|
36
|
+
expect(ips[0].class).to be(SendGrid4r::REST::Ips::Address)
|
|
37
|
+
expect(client.get_ip(ips[0].ip).class).to be(SendGrid4r::REST::Ips::Address)
|
|
38
|
+
rescue => ex
|
|
39
|
+
puts ex.inspect
|
|
40
|
+
raise ex
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/spec/client_spec.rb
CHANGED
|
@@ -17,26 +17,48 @@ describe "SendGrid4r::Client" do
|
|
|
17
17
|
it "is exist method" do
|
|
18
18
|
|
|
19
19
|
client = SendGrid4r::Client.new(ENV["SENDGRID_USERNAME"], ENV["SENDGRID_PASSWORD"])
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
expect(client.respond_to?("patch_enforced_tls")).to eq(true)
|
|
23
|
-
# global suppressions
|
|
24
|
-
expect(client.respond_to?("post_global_suppressed_emails")).to eq(true)
|
|
25
|
-
expect(client.respond_to?("get_global_suppressed_email")).to eq(true)
|
|
26
|
-
expect(client.respond_to?("delete_global_suppressed_email")).to eq(true)
|
|
20
|
+
|
|
21
|
+
# Advanced Suppression Manager
|
|
27
22
|
# groups
|
|
28
23
|
expect(client.respond_to?("get_groups")).to eq(true)
|
|
29
24
|
expect(client.respond_to?("get_group")).to eq(true)
|
|
30
25
|
expect(client.respond_to?("post_group")).to eq(true)
|
|
31
26
|
expect(client.respond_to?("patch_group")).to eq(true)
|
|
32
27
|
expect(client.respond_to?("delete_group")).to eq(true)
|
|
33
|
-
# ip addresses
|
|
34
|
-
expect(client.respond_to?("get_ips")).to eq(true)
|
|
35
28
|
# suppressions
|
|
29
|
+
expect(client.respond_to?("post_suppressed_emails")).to eq(true)
|
|
36
30
|
expect(client.respond_to?("get_suppressions")).to eq(true)
|
|
37
31
|
expect(client.respond_to?("get_suppressed_emails")).to eq(true)
|
|
38
|
-
expect(client.respond_to?("post_suppressed_emails")).to eq(true)
|
|
39
32
|
expect(client.respond_to?("delete_suppressed_email")).to eq(true)
|
|
33
|
+
# global suppressions
|
|
34
|
+
expect(client.respond_to?("post_global_suppressed_emails")).to eq(true)
|
|
35
|
+
expect(client.respond_to?("get_global_suppressed_email")).to eq(true)
|
|
36
|
+
expect(client.respond_to?("delete_global_suppressed_email")).to eq(true)
|
|
37
|
+
|
|
38
|
+
# IP Management
|
|
39
|
+
# ip addresses
|
|
40
|
+
expect(client.respond_to?("get_ips")).to eq(true)
|
|
41
|
+
expect(client.respond_to?("get_ip")).to eq(true)
|
|
42
|
+
expect(client.respond_to?("post_ip_to_pool")).to eq(true)
|
|
43
|
+
expect(client.respond_to?("delete_ip_from_pool")).to eq(true)
|
|
44
|
+
# pool
|
|
45
|
+
expect(client.respond_to?("get_pools")).to eq(true)
|
|
46
|
+
expect(client.respond_to?("post_pool")).to eq(true)
|
|
47
|
+
expect(client.respond_to?("get_pool")).to eq(true)
|
|
48
|
+
expect(client.respond_to?("put_pool")).to eq(true)
|
|
49
|
+
expect(client.respond_to?("delete_pool")).to eq(true)
|
|
50
|
+
# warmup
|
|
51
|
+
expect(client.respond_to?("get_warmup_ips")).to eq(true)
|
|
52
|
+
expect(client.respond_to?("get_warmup_ip")).to eq(true)
|
|
53
|
+
expect(client.respond_to?("post_warmup_ip")).to eq(true)
|
|
54
|
+
expect(client.respond_to?("delete_warmup_ip")).to eq(true)
|
|
55
|
+
|
|
56
|
+
# Settings
|
|
57
|
+
# enforced_tls
|
|
58
|
+
expect(client.respond_to?("get_enforced_tls")).to eq(true)
|
|
59
|
+
expect(client.respond_to?("patch_enforced_tls")).to eq(true)
|
|
60
|
+
|
|
61
|
+
# Template Engine
|
|
40
62
|
# templates
|
|
41
63
|
expect(client.respond_to?("get_templates")).to eq(true)
|
|
42
64
|
expect(client.respond_to?("get_template")).to eq(true)
|
|
@@ -49,18 +71,14 @@ describe "SendGrid4r::Client" do
|
|
|
49
71
|
expect(client.respond_to?("activate_version")).to eq(true)
|
|
50
72
|
expect(client.respond_to?("patch_version")).to eq(true)
|
|
51
73
|
expect(client.respond_to?("delete_version")).to eq(true)
|
|
52
|
-
|
|
53
|
-
expect(client.respond_to?("get_warmup_ips")).to eq(true)
|
|
54
|
-
expect(client.respond_to?("get_warmup_ip")).to eq(true)
|
|
55
|
-
expect(client.respond_to?("post_warmup_ip")).to eq(true)
|
|
56
|
-
expect(client.respond_to?("delete_warmup_ip")).to eq(true)
|
|
74
|
+
|
|
57
75
|
end
|
|
58
76
|
end
|
|
59
77
|
|
|
60
78
|
describe "Version" do
|
|
61
79
|
|
|
62
80
|
it "Validate version" do
|
|
63
|
-
expect(SendGrid4r::VERSION).to eq("0.0.
|
|
81
|
+
expect(SendGrid4r::VERSION).to eq("0.0.4")
|
|
64
82
|
end
|
|
65
83
|
|
|
66
84
|
end
|
data/spec/pools_spec.rb
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
+
|
|
4
|
+
describe "SendGrid4r::REST::Ips::Pools" do
|
|
5
|
+
|
|
6
|
+
before :all do
|
|
7
|
+
Dotenv.load
|
|
8
|
+
@pool_name = "pool_test"
|
|
9
|
+
@pool_edit = "pool_edit"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "free account" do
|
|
13
|
+
it "raise error" do
|
|
14
|
+
|
|
15
|
+
begin
|
|
16
|
+
#client = SendGrid4r::Client.new(ENV["SENDGRID_USERNAME"], ENV["SENDGRID_PASSWORD"])
|
|
17
|
+
# get ip pools
|
|
18
|
+
#expect{client.get_pools}.to raise_error(RestClient::Forbidden)
|
|
19
|
+
# post an ip pool
|
|
20
|
+
#expect{client.post_pool("test")}.to raise_error(RestClient::Forbidden)
|
|
21
|
+
# get the ip pool
|
|
22
|
+
#expect{client.get_pool("test")}.to raise_error(RestClient::Forbidden)
|
|
23
|
+
# put the ip pool
|
|
24
|
+
#expect{client.put_pool("test", "new_test")}.to raise_error(RestClient::Forbidden)
|
|
25
|
+
# delete the ip pool
|
|
26
|
+
#expect{client.delete_pool("test")}.to raise_error(RestClient::Forbidden)
|
|
27
|
+
rescue => ex
|
|
28
|
+
puts ex.inspect
|
|
29
|
+
raise ex
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "silver account" do
|
|
37
|
+
it "is normal" do
|
|
38
|
+
|
|
39
|
+
begin
|
|
40
|
+
client = SendGrid4r::Client.new(ENV["SILVER_SENDGRID_USERNAME"], ENV["SILVER_SENDGRID_PASSWORD"])
|
|
41
|
+
# clean up test env
|
|
42
|
+
pools = client.get_pools
|
|
43
|
+
expect(pools.length >= 0).to eq(true)
|
|
44
|
+
pools.each{|pool|
|
|
45
|
+
if pool == @pool_name || pool == @pool_edit then
|
|
46
|
+
client.delete_pool(pool)
|
|
47
|
+
end
|
|
48
|
+
}
|
|
49
|
+
# post a pool
|
|
50
|
+
new_pool = client.post_pool(@pool_name)
|
|
51
|
+
expect(@pool_name).to eq(new_pool.name)
|
|
52
|
+
# put the pool
|
|
53
|
+
edit_pool = client.put_pool(@pool_name, @pool_edit)
|
|
54
|
+
expect(@pool_edit).to eq(edit_pool.name)
|
|
55
|
+
# get the pool
|
|
56
|
+
pool = client.get_pool(@pool_edit)
|
|
57
|
+
expect(SendGrid4r::REST::Ips::Pool).to be(pool.class)
|
|
58
|
+
# delete the pool
|
|
59
|
+
client.delete_pool(pool.name)
|
|
60
|
+
expect{client.get_pool(pool.name)}
|
|
61
|
+
ips = client.get_ips
|
|
62
|
+
expect(ips.length).to be(1)
|
|
63
|
+
expect(ips[0].class).to be(SendGrid4r::REST::Ips::Address)
|
|
64
|
+
expect(client.get_ip(ips[0].ip).class).to be(SendGrid4r::REST::Ips::Address)
|
|
65
|
+
|
|
66
|
+
rescue => ex
|
|
67
|
+
puts ex.inspect
|
|
68
|
+
raise ex
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sendgrid4r
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- awwa500@gmail.com
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -84,11 +84,12 @@ files:
|
|
|
84
84
|
- lib/client.rb
|
|
85
85
|
- lib/sendgrid4r.rb
|
|
86
86
|
- lib/sendgrid4r/factory/version_factory.rb
|
|
87
|
+
- lib/sendgrid4r/rest/addresses.rb
|
|
87
88
|
- lib/sendgrid4r/rest/api.rb
|
|
88
89
|
- lib/sendgrid4r/rest/enforced_tls.rb
|
|
89
90
|
- lib/sendgrid4r/rest/global_suppressions.rb
|
|
90
91
|
- lib/sendgrid4r/rest/groups.rb
|
|
91
|
-
- lib/sendgrid4r/rest/
|
|
92
|
+
- lib/sendgrid4r/rest/pools.rb
|
|
92
93
|
- lib/sendgrid4r/rest/request.rb
|
|
93
94
|
- lib/sendgrid4r/rest/suppressions.rb
|
|
94
95
|
- lib/sendgrid4r/rest/templates.rb
|
|
@@ -96,11 +97,12 @@ files:
|
|
|
96
97
|
- lib/sendgrid4r/rest/warmup.rb
|
|
97
98
|
- lib/sendgrid4r/version.rb
|
|
98
99
|
- sendgrid4r.gemspec
|
|
100
|
+
- spec/addresses_spec.rb
|
|
99
101
|
- spec/client_spec.rb
|
|
100
102
|
- spec/enforced_tls_spec.rb
|
|
101
103
|
- spec/global_suppressions_spec.rb
|
|
102
104
|
- spec/groups_spec.rb
|
|
103
|
-
- spec/
|
|
105
|
+
- spec/pools_spec.rb
|
|
104
106
|
- spec/spec_helper.rb
|
|
105
107
|
- spec/suppressions_spec.rb
|
|
106
108
|
- spec/templates_spec.rb
|
|
@@ -127,16 +129,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
129
|
version: '0'
|
|
128
130
|
requirements: []
|
|
129
131
|
rubyforge_project:
|
|
130
|
-
rubygems_version: 2.
|
|
132
|
+
rubygems_version: 2.4.2
|
|
131
133
|
signing_key:
|
|
132
134
|
specification_version: 4
|
|
133
135
|
summary: SendGrid Web API v3 module
|
|
134
136
|
test_files:
|
|
137
|
+
- spec/addresses_spec.rb
|
|
135
138
|
- spec/client_spec.rb
|
|
136
139
|
- spec/enforced_tls_spec.rb
|
|
137
140
|
- spec/global_suppressions_spec.rb
|
|
138
141
|
- spec/groups_spec.rb
|
|
139
|
-
- spec/
|
|
142
|
+
- spec/pools_spec.rb
|
|
140
143
|
- spec/spec_helper.rb
|
|
141
144
|
- spec/suppressions_spec.rb
|
|
142
145
|
- spec/templates_spec.rb
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
$:.unshift File.dirname(__FILE__)
|
|
3
|
-
|
|
4
|
-
require "sendgrid4r/rest/request"
|
|
5
|
-
|
|
6
|
-
module SendGrid4r
|
|
7
|
-
module REST
|
|
8
|
-
module Ips
|
|
9
|
-
module IpAddresses
|
|
10
|
-
|
|
11
|
-
include SendGrid4r::REST::Request
|
|
12
|
-
|
|
13
|
-
def get_ips
|
|
14
|
-
response = get(@auth, "#{SendGrid4r::Client::BASE_URL}/ips")
|
|
15
|
-
ips = Array.new
|
|
16
|
-
response.each{|ip|
|
|
17
|
-
ip_address = IpAddress.create(ip)
|
|
18
|
-
ips.push(ip_address)
|
|
19
|
-
} if response.length > 0
|
|
20
|
-
ips
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
class IpAddress
|
|
24
|
-
|
|
25
|
-
attr_accessor :ip, :pools, :warmup, :start_date
|
|
26
|
-
|
|
27
|
-
def self.create(value)
|
|
28
|
-
obj = IpAddress.new
|
|
29
|
-
obj.ip = value["ip"]
|
|
30
|
-
obj.pools = []
|
|
31
|
-
# TODO Implements if ip pools GA
|
|
32
|
-
# value["pools"].each{|pool|
|
|
33
|
-
# ver = Pool.create(pool)
|
|
34
|
-
# obj.pools.push(ver)
|
|
35
|
-
# }
|
|
36
|
-
obj.warmup = value["warmup"]
|
|
37
|
-
obj.start_date = value["start_date"]
|
|
38
|
-
obj
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
end
|
|
46
|
-
end
|
data/spec/ip_addresses_spec.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
|
3
|
-
|
|
4
|
-
describe "SendGrid4r::REST::Ips::IpAddresses" do
|
|
5
|
-
|
|
6
|
-
before :all do
|
|
7
|
-
Dotenv.load
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
context "normal" do
|
|
11
|
-
it "is normal" do
|
|
12
|
-
|
|
13
|
-
begin
|
|
14
|
-
client = SendGrid4r::Client.new(ENV["SENDGRID_USERNAME"], ENV["SENDGRID_PASSWORD"])
|
|
15
|
-
# get the ips
|
|
16
|
-
expect{client.get_ips}.to raise_error(RestClient::Forbidden)
|
|
17
|
-
rescue => ex
|
|
18
|
-
puts ex.inspect
|
|
19
|
-
raise ex
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
end
|