sendgrid4r 1.4.0 → 1.5.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/.travis.yml +3 -0
- data/lib/sendgrid4r/rest/api.rb +4 -0
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +21 -5
- data/lib/sendgrid4r/rest/api_keys/permissions.rb +36 -0
- data/lib/sendgrid4r/rest/asm/groups.rb +7 -2
- data/lib/sendgrid4r/rest/settings/partner.rb +0 -12
- data/lib/sendgrid4r/rest/webhooks/parse_api.rb +40 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +12 -3
- data/spec/rest/api_keys/api_keys_spec.rb +62 -5
- data/spec/rest/api_keys/permissions_spec.rb +65 -0
- data/spec/rest/asm/groups_spec.rb +31 -9
- data/spec/rest/campaigns/campaigns_spec.rb +8 -7
- data/spec/rest/settings/partner_spec.rb +0 -40
- data/spec/rest/webhooks/parse_api_spec.rb +68 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b883e10192bc8e517a58fcdfd458ba5fc7316d99
|
4
|
+
data.tar.gz: 5ef42cbf4825c31ceadbc1fa480ea3fc767f5f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba77bfc725d1e5ca8afb4a8763de623ee1548185c97180d3fb410c09380e3aa64d91e092312c327cb90ffa655c2d3898e9f52006653b1ca7c8fa31fc2879105a
|
7
|
+
data.tar.gz: 63cffb12a1ab09703aba06f3904dc87650f59b41d1ea858dba25c7d1ad9c0d936de433117c5ef09168dfd5ee42cfbd6886a293738dd87eab5b385654b128923f
|
data/.travis.yml
CHANGED
data/lib/sendgrid4r/rest/api.rb
CHANGED
@@ -29,6 +29,7 @@ require 'sendgrid4r/rest/contacts/reserved_fields'
|
|
29
29
|
require 'sendgrid4r/rest/contacts/segments'
|
30
30
|
require 'sendgrid4r/rest/campaigns/campaigns'
|
31
31
|
require 'sendgrid4r/rest/api_keys/api_keys'
|
32
|
+
require 'sendgrid4r/rest/api_keys/permissions'
|
32
33
|
require 'sendgrid4r/rest/subusers'
|
33
34
|
require 'sendgrid4r/rest/email_activity/email_activity'
|
34
35
|
require 'sendgrid4r/rest/whitelabel/domains'
|
@@ -37,6 +38,7 @@ require 'sendgrid4r/rest/whitelabel/links'
|
|
37
38
|
require 'sendgrid4r/rest/users'
|
38
39
|
require 'sendgrid4r/rest/bounces'
|
39
40
|
require 'sendgrid4r/rest/cancel_scheduled_sends'
|
41
|
+
require 'sendgrid4r/rest/webhooks/parse_api'
|
40
42
|
|
41
43
|
module SendGrid4r
|
42
44
|
module REST
|
@@ -71,6 +73,7 @@ module SendGrid4r
|
|
71
73
|
include SendGrid4r::REST::Contacts::Segments
|
72
74
|
include SendGrid4r::REST::Campaigns::Campaigns
|
73
75
|
include SendGrid4r::REST::ApiKeys
|
76
|
+
include SendGrid4r::REST::ApiKeys::Permissions
|
74
77
|
include SendGrid4r::REST::Subusers
|
75
78
|
include SendGrid4r::REST::EmailActivity
|
76
79
|
include SendGrid4r::REST::Whitelabel::Domains
|
@@ -79,6 +82,7 @@ module SendGrid4r
|
|
79
82
|
include SendGrid4r::REST::Users
|
80
83
|
include SendGrid4r::REST::Bounces
|
81
84
|
include SendGrid4r::REST::CancelScheduledSends
|
85
|
+
include SendGrid4r::REST::Webhooks::ParseApi
|
82
86
|
end
|
83
87
|
end
|
84
88
|
end
|
@@ -12,11 +12,11 @@ module SendGrid4r
|
|
12
12
|
include SendGrid4r::REST::Request
|
13
13
|
|
14
14
|
ApiKeys = Struct.new(:result)
|
15
|
-
ApiKey = Struct.new(:name, :api_key_id, :api_key, :
|
15
|
+
ApiKey = Struct.new(:name, :api_key_id, :api_key, :scopes)
|
16
16
|
|
17
|
-
def self.url(
|
17
|
+
def self.url(api_key_id = nil)
|
18
18
|
url = "#{BASE_URL}/api_keys"
|
19
|
-
url = "#{url}/#{
|
19
|
+
url = "#{url}/#{api_key_id}" unless api_key_id.nil?
|
20
20
|
url
|
21
21
|
end
|
22
22
|
|
@@ -35,7 +35,7 @@ module SendGrid4r
|
|
35
35
|
resp['name'],
|
36
36
|
resp['api_key_id'],
|
37
37
|
resp['api_key'],
|
38
|
-
resp['
|
38
|
+
resp['scopes']
|
39
39
|
)
|
40
40
|
end
|
41
41
|
|
@@ -44,13 +44,20 @@ module SendGrid4r
|
|
44
44
|
SendGrid4r::REST::ApiKeys.create_api_keys(resp)
|
45
45
|
end
|
46
46
|
|
47
|
-
def post_api_key(name:, &block)
|
47
|
+
def post_api_key(name:, scopes: nil, &block)
|
48
48
|
params = {}
|
49
49
|
params['name'] = name
|
50
|
+
params['scopes'] = scopes unless scopes.nil?
|
50
51
|
resp = post(@auth, SendGrid4r::REST::ApiKeys.url, params, &block)
|
51
52
|
SendGrid4r::REST::ApiKeys.create_api_key(resp)
|
52
53
|
end
|
53
54
|
|
55
|
+
def get_api_key(api_key_id:, &block)
|
56
|
+
endpoint = SendGrid4r::REST::ApiKeys.url(api_key_id)
|
57
|
+
resp = get(@auth, endpoint, &block)
|
58
|
+
SendGrid4r::REST::ApiKeys.create_api_key(resp)
|
59
|
+
end
|
60
|
+
|
54
61
|
def delete_api_key(api_key_id:, &block)
|
55
62
|
delete(@auth, SendGrid4r::REST::ApiKeys.url(api_key_id), &block)
|
56
63
|
end
|
@@ -62,6 +69,15 @@ module SendGrid4r
|
|
62
69
|
resp = patch(@auth, endpoint, params, &block)
|
63
70
|
SendGrid4r::REST::ApiKeys.create_api_key(resp)
|
64
71
|
end
|
72
|
+
|
73
|
+
def put_api_key(api_key_id:, name:, scopes:, &block)
|
74
|
+
params = {}
|
75
|
+
params['name'] = name unless name.nil?
|
76
|
+
params['scopes'] = scopes unless scopes.nil?
|
77
|
+
endpoint = SendGrid4r::REST::ApiKeys.url(api_key_id)
|
78
|
+
resp = put(@auth, endpoint, params, &block)
|
79
|
+
SendGrid4r::REST::ApiKeys.create_api_key(resp)
|
80
|
+
end
|
65
81
|
end
|
66
82
|
end
|
67
83
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'sendgrid4r/rest/request'
|
5
|
+
|
6
|
+
module SendGrid4r
|
7
|
+
module REST
|
8
|
+
#
|
9
|
+
# SendGrid Web API v3 ApiKeys
|
10
|
+
#
|
11
|
+
module ApiKeys
|
12
|
+
#
|
13
|
+
# SendGrid Web API v3 ApiKeys Permissions
|
14
|
+
#
|
15
|
+
module Permissions
|
16
|
+
include SendGrid4r::REST::Request
|
17
|
+
|
18
|
+
Permissions = Struct.new(:scopes)
|
19
|
+
|
20
|
+
def self.url
|
21
|
+
"#{BASE_URL}/scopes"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_permissions(resp)
|
25
|
+
return resp if resp.nil?
|
26
|
+
Permissions.new(resp['scopes'])
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_permissions(&block)
|
30
|
+
resp = get(@auth, SendGrid4r::REST::ApiKeys::Permissions.url, &block)
|
31
|
+
SendGrid4r::REST::ApiKeys::Permissions.create_permissions(resp)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -13,7 +13,9 @@ module SendGrid4r
|
|
13
13
|
include SendGrid4r::REST::Request
|
14
14
|
|
15
15
|
Group = Struct.new(
|
16
|
-
:id, :name, :description, :
|
16
|
+
:id, :name, :description, :last_email_sent_at, :is_default,
|
17
|
+
:unsubscribes
|
18
|
+
)
|
17
19
|
|
18
20
|
def self.url(group_id = nil)
|
19
21
|
url = "#{BASE_URL}/asm/groups"
|
@@ -36,12 +38,15 @@ module SendGrid4r
|
|
36
38
|
resp['id'],
|
37
39
|
resp['name'],
|
38
40
|
resp['description'],
|
41
|
+
resp['last_email_sent_at'],
|
42
|
+
resp['is_default'],
|
39
43
|
resp['unsubscribes']
|
40
44
|
)
|
41
45
|
end
|
42
46
|
|
43
|
-
def post_group(name:, description:, &block)
|
47
|
+
def post_group(name:, description:, is_default: nil, &block)
|
44
48
|
params = { name: name, description: description }
|
49
|
+
params['is_default'] = is_default unless is_default.nil?
|
45
50
|
resp = post(@auth, SendGrid4r::REST::Asm::Groups.url, params, &block)
|
46
51
|
SendGrid4r::REST::Asm::Groups.create_group(resp)
|
47
52
|
end
|
@@ -44,18 +44,6 @@ module SendGrid4r
|
|
44
44
|
resp = patch(@auth, endpoint, params.to_h, &block)
|
45
45
|
SendGrid4r::REST::Settings::Partner.create_partner(resp)
|
46
46
|
end
|
47
|
-
|
48
|
-
def get_settings_sendwithus(&block)
|
49
|
-
endpoint = SendGrid4r::REST::Settings::Partner.url('sendwithus')
|
50
|
-
resp = get(@auth, endpoint, &block)
|
51
|
-
SendGrid4r::REST::Settings::Partner.create_partner(resp)
|
52
|
-
end
|
53
|
-
|
54
|
-
def patch_settings_sendwithus(params:, &block)
|
55
|
-
endpoint = SendGrid4r::REST::Settings::Partner.url('sendwithus')
|
56
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
57
|
-
SendGrid4r::REST::Settings::Partner.create_partner(resp)
|
58
|
-
end
|
59
47
|
end
|
60
48
|
end
|
61
49
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'sendgrid4r/rest/request'
|
5
|
+
|
6
|
+
module SendGrid4r
|
7
|
+
module REST
|
8
|
+
#
|
9
|
+
# SendGrid Web API v3 Webhooks
|
10
|
+
#
|
11
|
+
module Webhooks
|
12
|
+
#
|
13
|
+
# SendGrid Web API v3 Webhooks ParseApi
|
14
|
+
#
|
15
|
+
module ParseApi
|
16
|
+
include SendGrid4r::REST::Request
|
17
|
+
|
18
|
+
ParseSettings = Struct.new(:url, :hostname, :spam_check_outgoing)
|
19
|
+
|
20
|
+
def self.url
|
21
|
+
"#{BASE_URL}/webhooks/parse/settings"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.create_parse_settings(resp)
|
25
|
+
return resp if resp.nil?
|
26
|
+
ParseSettings.new(
|
27
|
+
resp['url'],
|
28
|
+
resp['hostname'],
|
29
|
+
resp['spam_check_outgoing']
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_parse_settings(&block)
|
34
|
+
resp = get(@auth, SendGrid4r::REST::Webhooks::ParseApi.url, &block)
|
35
|
+
SendGrid4r::REST::Webhooks::ParseApi.create_parse_settings(resp)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/sendgrid4r/version.rb
CHANGED
data/sendgrid4r.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency('rest-client', '>=1.8.0', '<1.9.0')
|
22
22
|
spec.add_development_dependency('rubocop', '>=0.29.0', '<0.34.3')
|
23
|
-
spec.add_development_dependency('bundler', '>=1.6.0', '<1.
|
23
|
+
spec.add_development_dependency('bundler', '>=1.6.0', '<1.12.0')
|
24
24
|
spec.add_development_dependency('rspec', '3.3.0')
|
25
25
|
spec.add_development_dependency('dotenv', '=0.11.0', '<=2.0.2')
|
26
26
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -121,8 +121,6 @@ describe SendGrid4r::Client do
|
|
121
121
|
expect(@client.respond_to?('get_partner_settings')).to eq(true)
|
122
122
|
expect(@client.respond_to?('get_settings_new_relic')).to eq(true)
|
123
123
|
expect(@client.respond_to?('patch_settings_new_relic')).to eq(true)
|
124
|
-
expect(@client.respond_to?('get_settings_sendwithus')).to eq(true)
|
125
|
-
expect(@client.respond_to?('patch_settings_sendwithus')).to eq(true)
|
126
124
|
|
127
125
|
# tracking
|
128
126
|
expect(@client.respond_to?('get_tracking_settings')).to eq(true)
|
@@ -268,12 +266,23 @@ describe SendGrid4r::Client do
|
|
268
266
|
expect(@client.respond_to?('get_scheduled_sends')).to eq(true)
|
269
267
|
expect(@client.respond_to?('patch_scheduled_send')).to eq(true)
|
270
268
|
expect(@client.respond_to?('delete_scheduled_send')).to eq(true)
|
269
|
+
|
270
|
+
# Api Keys
|
271
|
+
expect(@client.respond_to?('get_api_keys')).to eq(true)
|
272
|
+
expect(@client.respond_to?('post_api_key')).to eq(true)
|
273
|
+
expect(@client.respond_to?('get_api_key')).to eq(true)
|
274
|
+
expect(@client.respond_to?('delete_api_key')).to eq(true)
|
275
|
+
expect(@client.respond_to?('patch_api_key')).to eq(true)
|
276
|
+
expect(@client.respond_to?('put_api_key')).to eq(true)
|
277
|
+
|
278
|
+
# Permissions
|
279
|
+
expect(@client.respond_to?('get_permissions')).to eq(true)
|
271
280
|
end
|
272
281
|
end
|
273
282
|
|
274
283
|
describe 'VERSION' do
|
275
284
|
it 'returns VERSION value' do
|
276
|
-
expect(SendGrid4r::VERSION).to eq('1.
|
285
|
+
expect(SendGrid4r::VERSION).to eq('1.5.0')
|
277
286
|
end
|
278
287
|
end
|
279
288
|
end
|
@@ -26,7 +26,7 @@ describe SendGrid4r::REST::ApiKeys do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# post api_key
|
29
|
-
@api_key1 = @client.post_api_key(name: @name1)
|
29
|
+
@api_key1 = @client.post_api_key(name: @name1, scopes: ['mail.send'])
|
30
30
|
rescue RestClient::ExceptionWithResponse => e
|
31
31
|
puts e.inspect
|
32
32
|
raise e
|
@@ -58,6 +58,33 @@ describe SendGrid4r::REST::ApiKeys do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
it '#post_api_key with scopes' do
|
62
|
+
begin
|
63
|
+
api_key2 = @client.post_api_key(name: @name2, scopes: ['mail.send'])
|
64
|
+
expect(api_key2).to be_a(SendGrid4r::REST::ApiKeys::ApiKey)
|
65
|
+
expect(api_key2.name).to eq(@name2)
|
66
|
+
expect(api_key2.api_key_id).to be_a(String)
|
67
|
+
expect(api_key2.api_key).to be_a(String)
|
68
|
+
expect(api_key2.scopes).to be_a(Array)
|
69
|
+
rescue RestClient::ExceptionWithResponse => e
|
70
|
+
puts e.inspect
|
71
|
+
raise e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it '#get_api_key' do
|
76
|
+
begin
|
77
|
+
api_key = @client.get_api_key(api_key_id: @api_key1.api_key_id)
|
78
|
+
expect(api_key).to be_a(SendGrid4r::REST::ApiKeys::ApiKey)
|
79
|
+
expect(api_key.api_key_id).to eq(@api_key1.api_key_id)
|
80
|
+
expect(api_key.name).to eq('api_key_name1')
|
81
|
+
expect(api_key.scopes).to be_a(Array)
|
82
|
+
rescue RestClient::ExceptionWithResponse => e
|
83
|
+
puts e.inspect
|
84
|
+
raise e
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
61
88
|
it '#delete_api_key' do
|
62
89
|
begin
|
63
90
|
@client.delete_api_key(api_key_id: @api_key1.api_key_id)
|
@@ -79,6 +106,22 @@ describe SendGrid4r::REST::ApiKeys do
|
|
79
106
|
raise e
|
80
107
|
end
|
81
108
|
end
|
109
|
+
|
110
|
+
it '#put_api_key' do
|
111
|
+
begin
|
112
|
+
edit_api_key = @client.put_api_key(
|
113
|
+
api_key_id: @api_key1.api_key_id,
|
114
|
+
name: @name1e,
|
115
|
+
scopes: ['mail.send']
|
116
|
+
)
|
117
|
+
expect(edit_api_key.api_key_id).to eq(@api_key1.api_key_id)
|
118
|
+
expect(edit_api_key.name).to eq(@name1e)
|
119
|
+
expect(edit_api_key.scopes).to eq(['mail.send'])
|
120
|
+
rescue RestClient::ExceptionWithResponse => e
|
121
|
+
puts e.inspect
|
122
|
+
raise e
|
123
|
+
end
|
124
|
+
end
|
82
125
|
end
|
83
126
|
end
|
84
127
|
|
@@ -103,8 +146,14 @@ describe SendGrid4r::REST::ApiKeys do
|
|
103
146
|
let(:api_key) do
|
104
147
|
JSON.parse(
|
105
148
|
'{'\
|
106
|
-
'"
|
107
|
-
'"
|
149
|
+
'"api_key": "SG.xxxxxxxx.yyyyyyyy",'\
|
150
|
+
'"api_key_id": "xxxxxxxx",'\
|
151
|
+
'"name": "My API Key",'\
|
152
|
+
'"scopes": ['\
|
153
|
+
'"mail.send",'\
|
154
|
+
'"alerts.create",'\
|
155
|
+
'"alerts.read"'\
|
156
|
+
']'\
|
108
157
|
'}'
|
109
158
|
)
|
110
159
|
end
|
@@ -133,11 +182,19 @@ describe SendGrid4r::REST::ApiKeys do
|
|
133
182
|
expect(actual).to be_a(SendGrid4r::REST::ApiKeys::ApiKey)
|
134
183
|
end
|
135
184
|
|
185
|
+
it '#put_api_key' do
|
186
|
+
allow(client).to receive(:execute).and_return(api_key)
|
187
|
+
actual = client.put_api_key(api_key_id: '', name: '', scopes: [])
|
188
|
+
expect(actual).to be_a(SendGrid4r::REST::ApiKeys::ApiKey)
|
189
|
+
end
|
190
|
+
|
136
191
|
it 'creates api_key instance' do
|
137
192
|
actual = SendGrid4r::REST::ApiKeys.create_api_key(api_key)
|
138
193
|
expect(actual).to be_a(SendGrid4r::REST::ApiKeys::ApiKey)
|
139
|
-
expect(actual.
|
140
|
-
expect(actual.
|
194
|
+
expect(actual.api_key).to eq('SG.xxxxxxxx.yyyyyyyy')
|
195
|
+
expect(actual.api_key_id).to eq('xxxxxxxx')
|
196
|
+
expect(actual.name).to eq('My API Key')
|
197
|
+
expect(actual.scopes).to eq(['mail.send', 'alerts.create', 'alerts.read'])
|
141
198
|
end
|
142
199
|
|
143
200
|
it 'creates api_keys instance' do
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::ApiKeys::Permissions do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
Dotenv.load
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'without block call' do
|
12
|
+
it '#get_permissions' do
|
13
|
+
begin
|
14
|
+
permissions = @client.get_permissions
|
15
|
+
expect(permissions).to be_a(
|
16
|
+
SendGrid4r::REST::ApiKeys::Permissions::Permissions
|
17
|
+
)
|
18
|
+
expect(permissions.scopes).to be_a(Array)
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
20
|
+
puts e.inspect
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'unit test', :ut do
|
28
|
+
let(:client) do
|
29
|
+
SendGrid4r::Client.new(api_key: '')
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:permissions) do
|
33
|
+
JSON.parse(
|
34
|
+
'{'\
|
35
|
+
'"scopes": ['\
|
36
|
+
'"alerts.create",'\
|
37
|
+
'"alerts.read",'\
|
38
|
+
'"alerts.update"'\
|
39
|
+
']'\
|
40
|
+
'}'
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#get_permissions' do
|
45
|
+
allow(client).to receive(:execute).and_return(permissions)
|
46
|
+
actual = client.get_permissions
|
47
|
+
expect(actual).to be_a(
|
48
|
+
SendGrid4r::REST::ApiKeys::Permissions::Permissions
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'creates permissions instance' do
|
53
|
+
actual = SendGrid4r::REST::ApiKeys::Permissions.create_permissions(
|
54
|
+
permissions
|
55
|
+
)
|
56
|
+
expect(actual).to be_a(
|
57
|
+
SendGrid4r::REST::ApiKeys::Permissions::Permissions
|
58
|
+
)
|
59
|
+
expect(actual.scopes).to be_a(Array)
|
60
|
+
expect(actual.scopes[0]).to eq('alerts.create')
|
61
|
+
expect(actual.scopes[1]).to eq('alerts.read')
|
62
|
+
expect(actual.scopes[2]).to eq('alerts.update')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -50,17 +50,14 @@ describe SendGrid4r::REST::Asm::Groups do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
it '#
|
53
|
+
it '#post_group with is_default' do
|
54
54
|
begin
|
55
|
-
|
56
|
-
|
57
|
-
group_edit1 = @client.patch_group(
|
58
|
-
group_id: @group1.id, group: @group1
|
55
|
+
group2 = @client.post_group(
|
56
|
+
name: @group_name2, description: @group_desc, is_default: false
|
59
57
|
)
|
60
|
-
expect(
|
61
|
-
expect(
|
62
|
-
expect(
|
63
|
-
expect(group_edit1.unsubscribes).to eq(nil)
|
58
|
+
expect(@group_name2).to eq(group2.name)
|
59
|
+
expect(@group_desc).to eq(group2.description)
|
60
|
+
expect(false).to eq(group2.is_default)
|
64
61
|
rescue RestClient::ExceptionWithResponse => e
|
65
62
|
puts e.inspect
|
66
63
|
raise e
|
@@ -93,6 +90,23 @@ describe SendGrid4r::REST::Asm::Groups do
|
|
93
90
|
end
|
94
91
|
end
|
95
92
|
|
93
|
+
it '#patch_group' do
|
94
|
+
begin
|
95
|
+
@group1.name = @group_name_edit1
|
96
|
+
@group1.description = @group_desc_edit
|
97
|
+
group_edit1 = @client.patch_group(
|
98
|
+
group_id: @group1.id, group: @group1
|
99
|
+
)
|
100
|
+
expect(group_edit1.id).to be_a(Fixnum)
|
101
|
+
expect(group_edit1.name).to eq(@group_name_edit1)
|
102
|
+
expect(group_edit1.description).to eq(@group_desc_edit)
|
103
|
+
expect(group_edit1.unsubscribes).to eq(nil)
|
104
|
+
rescue RestClient::ExceptionWithResponse => e
|
105
|
+
puts e.inspect
|
106
|
+
raise e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
96
110
|
it '#delete_group' do
|
97
111
|
begin
|
98
112
|
@client.delete_group(group_id: @group1.id)
|
@@ -115,6 +129,8 @@ describe SendGrid4r::REST::Asm::Groups do
|
|
115
129
|
'"id": 100,'\
|
116
130
|
'"name": "Newsletters",'\
|
117
131
|
'"description": "Our monthly newsletter.",'\
|
132
|
+
'"last_email_sent_at": null,'\
|
133
|
+
'"is_default": true,'\
|
118
134
|
'"unsubscribes": 400'\
|
119
135
|
'}'
|
120
136
|
)
|
@@ -127,12 +143,16 @@ describe SendGrid4r::REST::Asm::Groups do
|
|
127
143
|
'"id": 100,'\
|
128
144
|
'"name": "Newsletters",'\
|
129
145
|
'"description": "Our monthly newsletter.",'\
|
146
|
+
'"last_email_sent_at": null,'\
|
147
|
+
'"is_default": true,'\
|
130
148
|
'"unsubscribes": 400'\
|
131
149
|
'},'\
|
132
150
|
'{'\
|
133
151
|
'"id": 101,'\
|
134
152
|
'"name": "Alerts",'\
|
135
153
|
'"description": "Emails triggered by user-defined rules.",'\
|
154
|
+
'"last_email_sent_at": null,'\
|
155
|
+
'"is_default": false,'\
|
136
156
|
'"unsubscribes": 1'\
|
137
157
|
'}'\
|
138
158
|
']'
|
@@ -180,6 +200,8 @@ describe SendGrid4r::REST::Asm::Groups do
|
|
180
200
|
expect(actual.id).to eq(100)
|
181
201
|
expect(actual.name).to eq('Newsletters')
|
182
202
|
expect(actual.description).to eq('Our monthly newsletter.')
|
203
|
+
expect(actual.last_email_sent_at).to eq(nil)
|
204
|
+
expect(actual.is_default).to eq(true)
|
183
205
|
expect(actual.unsubscribes).to eq(400)
|
184
206
|
end
|
185
207
|
|
@@ -68,8 +68,9 @@ describe SendGrid4r::REST::Campaigns::Campaigns do
|
|
68
68
|
@params = @campaign_factory.create(
|
69
69
|
title: @title1, subject: @subject1, sender_id: 493,
|
70
70
|
list_ids: [@list1.id], categories: ['cat1'],
|
71
|
-
suppression_group_id: @group1.id,
|
72
|
-
|
71
|
+
suppression_group_id: @group1.id,
|
72
|
+
html_content: 'html <a href="[unsubscribe]">unsub</a>',
|
73
|
+
plain_content: 'plain [unsubscribe]')
|
73
74
|
@campaign1 = @client.post_campaign(params: @params)
|
74
75
|
rescue RestClient::ExceptionWithResponse => e
|
75
76
|
puts e.inspect
|
@@ -162,7 +163,7 @@ describe SendGrid4r::REST::Campaigns::Campaigns do
|
|
162
163
|
|
163
164
|
it '#schedule_campaign' do
|
164
165
|
begin
|
165
|
-
send_at = Time.
|
166
|
+
send_at = Time.at(Time.now.to_i, 0)
|
166
167
|
actual = @client.schedule_campaign(
|
167
168
|
campaign_id: @campaign1.id,
|
168
169
|
send_at: send_at
|
@@ -178,12 +179,12 @@ describe SendGrid4r::REST::Campaigns::Campaigns do
|
|
178
179
|
|
179
180
|
it '#reschedule_campaign' do
|
180
181
|
begin
|
181
|
-
send_at = Time.
|
182
|
+
send_at = Time.at(Time.now.to_i, 0)
|
182
183
|
@client.schedule_campaign(
|
183
184
|
campaign_id: @campaign1.id,
|
184
185
|
send_at: send_at
|
185
186
|
)
|
186
|
-
send_at = Time.
|
187
|
+
send_at = Time.at(Time.now.to_i, 0)
|
187
188
|
actual = @client.reschedule_campaign(
|
188
189
|
campaign_id: @campaign1.id,
|
189
190
|
send_at: send_at
|
@@ -199,7 +200,7 @@ describe SendGrid4r::REST::Campaigns::Campaigns do
|
|
199
200
|
|
200
201
|
it '#get_schedule_time_campaign' do
|
201
202
|
begin
|
202
|
-
send_at = Time.
|
203
|
+
send_at = Time.at(Time.now.to_i, 0)
|
203
204
|
@client.schedule_campaign(
|
204
205
|
campaign_id: @campaign1.id,
|
205
206
|
send_at: send_at
|
@@ -216,7 +217,7 @@ describe SendGrid4r::REST::Campaigns::Campaigns do
|
|
216
217
|
|
217
218
|
it '#unschedule_campaign' do
|
218
219
|
begin
|
219
|
-
send_at = Time.
|
220
|
+
send_at = Time.at(Time.now.to_i, 0)
|
220
221
|
@client.schedule_campaign(
|
221
222
|
campaign_id: @campaign1.id, send_at: send_at
|
222
223
|
)
|
@@ -50,34 +50,6 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
50
50
|
raise e
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
it '#get_settings_sendwithus' do
|
55
|
-
pending 'entry not found'
|
56
|
-
begin
|
57
|
-
actual = @client.get_settings_sendwithus
|
58
|
-
expect(actual).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
59
|
-
rescue RestClient::ExceptionWithResponse => e
|
60
|
-
puts e.inspect
|
61
|
-
raise e
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it '#patch_settings_sendwithus' do
|
66
|
-
pending 'entry not found'
|
67
|
-
begin
|
68
|
-
# get original settings
|
69
|
-
actual = @client.get_settings_sendwithus
|
70
|
-
# patch the value
|
71
|
-
actual.enabled = false
|
72
|
-
actual.license_key = 'sendwithus_license_key'
|
73
|
-
edit = @client.patch_settings_sendwithus(params: actual)
|
74
|
-
expect(edit.enabled).to eq(false)
|
75
|
-
expect(edit.license_key).to eq('sendwithus_license_key')
|
76
|
-
rescue RestClient::ExceptionWithResponse => e
|
77
|
-
puts e.inspect
|
78
|
-
raise e
|
79
|
-
end
|
80
|
-
end
|
81
53
|
end
|
82
54
|
end
|
83
55
|
|
@@ -107,18 +79,6 @@ describe SendGrid4r::REST::Settings::Partner do
|
|
107
79
|
expect(actual).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
108
80
|
end
|
109
81
|
|
110
|
-
it '#get_settings_sendwithus' do
|
111
|
-
allow(client).to receive(:execute).and_return(partner)
|
112
|
-
actual = client.get_settings_sendwithus
|
113
|
-
expect(actual).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
114
|
-
end
|
115
|
-
|
116
|
-
it '#patch_settings_sendwithus' do
|
117
|
-
allow(client).to receive(:execute).and_return(partner)
|
118
|
-
actual = client.patch_settings_sendwithus(params: nil)
|
119
|
-
expect(actual).to be_a(SendGrid4r::REST::Settings::Partner::Partner)
|
120
|
-
end
|
121
|
-
|
122
82
|
it 'creates partner instance' do
|
123
83
|
actual = SendGrid4r::REST::Settings::Partner.create_partner(partner)
|
124
84
|
expect(actual.enabled).to eq(true)
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::Webhooks::ParseApi do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
begin
|
8
|
+
Dotenv.load
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
raise e
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'without block call' do
|
17
|
+
it '#get_parse_settings' do
|
18
|
+
pending 'resource not found'
|
19
|
+
begin
|
20
|
+
parse_settings = @client.get_parse_settings
|
21
|
+
expect(parse_settings).to be_a(
|
22
|
+
SendGrid4r::REST::Webhooks::ParseApi::ParseSettings
|
23
|
+
)
|
24
|
+
expect(parse_settings.url).to be_a(String)
|
25
|
+
rescue RestClient::ExceptionWithResponse => e
|
26
|
+
puts e.inspect
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'unit test', :ut do
|
34
|
+
let(:client) do
|
35
|
+
SendGrid4r::Client.new(api_key: '')
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:parse_settings) do
|
39
|
+
JSON.parse(
|
40
|
+
'{'\
|
41
|
+
'"url": "http://mydomain.com/parse",'\
|
42
|
+
'"hostname": "mail.mydomain.com",'\
|
43
|
+
'"spam_check_outgoing": true'\
|
44
|
+
'}'
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
it '#get_parse_settings' do
|
49
|
+
allow(client).to receive(:execute).and_return(parse_settings)
|
50
|
+
actual = client.get_parse_settings
|
51
|
+
expect(actual).to be_a(
|
52
|
+
SendGrid4r::REST::Webhooks::ParseApi::ParseSettings
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'creates parse_settings instance' do
|
57
|
+
actual = SendGrid4r::REST::Webhooks::ParseApi.create_parse_settings(
|
58
|
+
parse_settings
|
59
|
+
)
|
60
|
+
expect(actual).to be_a(
|
61
|
+
SendGrid4r::REST::Webhooks::ParseApi::ParseSettings
|
62
|
+
)
|
63
|
+
expect(actual.url).to eq('http://mydomain.com/parse')
|
64
|
+
expect(actual.hostname).to eq('mail.mydomain.com')
|
65
|
+
expect(actual.spam_check_outgoing).to eq(true)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
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: 1.
|
4
|
+
version: 1.5.0
|
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:
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
version: 1.6.0
|
60
60
|
- - "<"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 1.
|
62
|
+
version: 1.12.0
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ dependencies:
|
|
69
69
|
version: 1.6.0
|
70
70
|
- - "<"
|
71
71
|
- !ruby/object:Gem::Version
|
72
|
-
version: 1.
|
72
|
+
version: 1.12.0
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: rspec
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/sendgrid4r/factory/version_factory.rb
|
129
129
|
- lib/sendgrid4r/rest/api.rb
|
130
130
|
- lib/sendgrid4r/rest/api_keys/api_keys.rb
|
131
|
+
- lib/sendgrid4r/rest/api_keys/permissions.rb
|
131
132
|
- lib/sendgrid4r/rest/asm/asm.rb
|
132
133
|
- lib/sendgrid4r/rest/asm/global_suppressions.rb
|
133
134
|
- lib/sendgrid4r/rest/asm/groups.rb
|
@@ -161,6 +162,7 @@ files:
|
|
161
162
|
- lib/sendgrid4r/rest/templates/templates.rb
|
162
163
|
- lib/sendgrid4r/rest/templates/versions.rb
|
163
164
|
- lib/sendgrid4r/rest/users.rb
|
165
|
+
- lib/sendgrid4r/rest/webhooks/parse_api.rb
|
164
166
|
- lib/sendgrid4r/rest/whitelabel/domains.rb
|
165
167
|
- lib/sendgrid4r/rest/whitelabel/ips.rb
|
166
168
|
- lib/sendgrid4r/rest/whitelabel/links.rb
|
@@ -172,6 +174,7 @@ files:
|
|
172
174
|
- spec/factory/segment_factory_spec.rb
|
173
175
|
- spec/factory/version_factory_spec.rb
|
174
176
|
- spec/rest/api_keys/api_keys_spec.rb
|
177
|
+
- spec/rest/api_keys/permissions_spec.rb
|
175
178
|
- spec/rest/asm/asm_spec.rb
|
176
179
|
- spec/rest/asm/global_suppressions_spec.rb
|
177
180
|
- spec/rest/asm/groups_spec.rb
|
@@ -204,6 +207,7 @@ files:
|
|
204
207
|
- spec/rest/templates/templates_spec.rb
|
205
208
|
- spec/rest/templates/versions_spec.rb
|
206
209
|
- spec/rest/users_spec.rb
|
210
|
+
- spec/rest/webhooks/parse_api_spec.rb
|
207
211
|
- spec/rest/whitelabel/domains_spec.rb
|
208
212
|
- spec/rest/whitelabel/ips_spec.rb
|
209
213
|
- spec/rest/whitelabel/links_spec.rb
|
@@ -228,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
232
|
version: '0'
|
229
233
|
requirements: []
|
230
234
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.4.3
|
232
236
|
signing_key:
|
233
237
|
specification_version: 4
|
234
238
|
summary: SendGrid Web API v3 module
|
@@ -239,6 +243,7 @@ test_files:
|
|
239
243
|
- spec/factory/segment_factory_spec.rb
|
240
244
|
- spec/factory/version_factory_spec.rb
|
241
245
|
- spec/rest/api_keys/api_keys_spec.rb
|
246
|
+
- spec/rest/api_keys/permissions_spec.rb
|
242
247
|
- spec/rest/asm/asm_spec.rb
|
243
248
|
- spec/rest/asm/global_suppressions_spec.rb
|
244
249
|
- spec/rest/asm/groups_spec.rb
|
@@ -271,6 +276,7 @@ test_files:
|
|
271
276
|
- spec/rest/templates/templates_spec.rb
|
272
277
|
- spec/rest/templates/versions_spec.rb
|
273
278
|
- spec/rest/users_spec.rb
|
279
|
+
- spec/rest/webhooks/parse_api_spec.rb
|
274
280
|
- spec/rest/whitelabel/domains_spec.rb
|
275
281
|
- spec/rest/whitelabel/ips_spec.rb
|
276
282
|
- spec/rest/whitelabel/links_spec.rb
|