sendgrid4r 1.8.1 → 1.10.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/.rubocop.yml +6 -2
- data/README.md +1 -0
- data/lib/sendgrid4r/factory/campaign_factory.rb +18 -5
- data/lib/sendgrid4r/factory/condition_factory.rb +1 -1
- data/lib/sendgrid4r/factory/mail_factory.rb +57 -0
- data/lib/sendgrid4r/factory/segment_factory.rb +2 -5
- data/lib/sendgrid4r/factory/version_factory.rb +1 -1
- data/lib/sendgrid4r/rest/api.rb +48 -49
- data/lib/sendgrid4r/rest/api_keys_management/api_keys.rb +75 -0
- data/lib/sendgrid4r/rest/api_keys_management/permissions.rb +31 -0
- data/lib/sendgrid4r/rest/blocks.rb +49 -68
- data/lib/sendgrid4r/rest/bounces.rb +45 -64
- data/lib/sendgrid4r/rest/cancel_scheduled_sends.rb +53 -72
- data/lib/sendgrid4r/rest/categories.rb +31 -0
- data/lib/sendgrid4r/rest/email_activity.rb +72 -0
- data/lib/sendgrid4r/rest/invalid_emails.rb +50 -68
- data/lib/sendgrid4r/rest/ip_access_management.rb +86 -111
- data/lib/sendgrid4r/rest/ips/addresses.rb +50 -59
- data/lib/sendgrid4r/rest/ips/pools.rb +42 -53
- data/lib/sendgrid4r/rest/ips/warmup.rb +46 -55
- data/lib/sendgrid4r/rest/mail/address.rb +14 -0
- data/lib/sendgrid4r/rest/mail/attachment.rb +22 -0
- data/lib/sendgrid4r/rest/mail/content.rb +10 -0
- data/lib/sendgrid4r/rest/mail/mail.rb +28 -0
- data/lib/sendgrid4r/rest/mail/mail_settings.rb +62 -0
- data/lib/sendgrid4r/rest/mail/params.rb +64 -0
- data/lib/sendgrid4r/rest/mail/personalization.rb +33 -0
- data/lib/sendgrid4r/rest/mail/tracking_settings.rb +74 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/custom_fields.rb +12 -27
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/lists.rb +20 -34
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/recipients.rb +134 -0
- data/lib/sendgrid4r/rest/{contacts → marketing_campaigns/contacts}/reserved_fields.rb +6 -9
- data/lib/sendgrid4r/rest/marketing_campaigns/contacts/segments.rb +86 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/marketing_campaigns.rb +119 -0
- data/lib/sendgrid4r/rest/marketing_campaigns/senders.rb +101 -0
- data/lib/sendgrid4r/rest/request.rb +61 -63
- data/lib/sendgrid4r/rest/settings/enforced_tls.rb +23 -26
- data/lib/sendgrid4r/rest/settings/mail.rb +167 -183
- data/lib/sendgrid4r/rest/settings/partner.rb +33 -36
- data/lib/sendgrid4r/rest/settings/settings.rb +17 -22
- data/lib/sendgrid4r/rest/settings/tracking.rb +97 -107
- data/lib/sendgrid4r/rest/sm/global_unsubscribes.rb +52 -60
- data/lib/sendgrid4r/rest/sm/groups.rb +52 -58
- data/lib/sendgrid4r/rest/sm/sm.rb +15 -17
- data/lib/sendgrid4r/rest/sm/suppressions.rb +50 -67
- data/lib/sendgrid4r/rest/spam_reports.rb +49 -69
- data/lib/sendgrid4r/rest/stats/advanced.rb +100 -102
- data/lib/sendgrid4r/rest/stats/category.rb +31 -33
- data/lib/sendgrid4r/rest/stats/global.rb +17 -19
- data/lib/sendgrid4r/rest/stats/parse.rb +18 -20
- data/lib/sendgrid4r/rest/stats/stats.rb +59 -69
- data/lib/sendgrid4r/rest/stats/subuser.rb +70 -32
- data/lib/sendgrid4r/rest/subusers.rb +106 -134
- data/lib/sendgrid4r/rest/transactional_templates/templates.rb +63 -0
- data/lib/sendgrid4r/rest/transactional_templates/versions.rb +90 -0
- data/lib/sendgrid4r/rest/users.rb +125 -57
- data/lib/sendgrid4r/rest/webhooks/event.rb +36 -42
- data/lib/sendgrid4r/rest/webhooks/parse.rb +28 -37
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +176 -222
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +107 -128
- data/lib/sendgrid4r/rest/whitelabel/links.rb +131 -167
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +23 -13
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +12 -1
- data/spec/factory/campaign_factory_spec.rb +75 -35
- data/spec/factory/condition_factory_spec.rb +19 -18
- data/spec/factory/segment_factory_spec.rb +28 -21
- data/spec/factory/version_factory_spec.rb +28 -27
- data/spec/photo.jpg +0 -0
- data/spec/rest/api_keys_management/api_keys_spec.rb +174 -0
- data/spec/rest/api_keys_management/permissions_spec.rb +54 -0
- data/spec/rest/blocks_spec.rb +78 -106
- data/spec/rest/bounces_spec.rb +91 -118
- data/spec/rest/cancel_scheduled_sends_spec.rb +94 -149
- data/spec/rest/categories_spec.rb +77 -0
- data/spec/rest/email_activity_spec.rb +151 -0
- data/spec/rest/invalid_emails_spec.rb +85 -119
- data/spec/rest/ip_access_management_spec.rb +157 -195
- data/spec/rest/ips/addresses_spec.rb +94 -122
- data/spec/rest/ips/pools_spec.rb +84 -112
- data/spec/rest/ips/warmup_spec.rb +63 -71
- data/spec/rest/mail/address_spec.rb +28 -0
- data/spec/rest/mail/attachment_spec.rb +48 -0
- data/spec/rest/mail/content_spec.rb +32 -0
- data/spec/rest/mail/mail_settings_spec.rb +51 -0
- data/spec/rest/mail/mail_spec.rb +136 -0
- data/spec/rest/mail/params_spec.rb +152 -0
- data/spec/rest/mail/personalization_spec.rb +66 -0
- data/spec/rest/mail/tracking_settings_spec.rb +63 -0
- data/spec/rest/marketing_campaigns/contacts/custom_fields_spec.rb +146 -0
- data/spec/rest/marketing_campaigns/contacts/lists_spec.rb +307 -0
- data/spec/rest/marketing_campaigns/contacts/recipients_spec.rb +331 -0
- data/spec/rest/marketing_campaigns/contacts/reserved_fields_spec.rb +119 -0
- data/spec/rest/marketing_campaigns/contacts/segments_spec.rb +268 -0
- data/spec/rest/marketing_campaigns/marketing_campaigns_spec.rb +427 -0
- data/spec/rest/marketing_campaigns/senders_spec.rb +230 -0
- data/spec/rest/settings/enforced_tls_spec.rb +38 -54
- data/spec/rest/settings/mail_spec.rb +227 -330
- data/spec/rest/settings/partner_spec.rb +40 -59
- data/spec/rest/settings/settings_spec.rb +44 -42
- data/spec/rest/settings/tracking_spec.rb +130 -189
- data/spec/rest/sm/global_unsubscribes_spec.rb +47 -72
- data/spec/rest/sm/groups_spec.rb +88 -123
- data/spec/rest/sm/sm_spec.rb +32 -30
- data/spec/rest/sm/suppressions_spec.rb +105 -140
- data/spec/rest/spam_reports_spec.rb +81 -109
- data/spec/rest/stats/advanced_spec.rb +67 -125
- data/spec/rest/stats/category_spec.rb +27 -45
- data/spec/rest/stats/global_spec.rb +34 -42
- data/spec/rest/stats/parse_spec.rb +32 -30
- data/spec/rest/stats/stats_spec.rb +174 -172
- data/spec/rest/stats/subuser_spec.rb +97 -57
- data/spec/rest/subusers_spec.rb +156 -209
- data/spec/rest/transactional_templates/templates_spec.rb +199 -0
- data/spec/rest/transactional_templates/versions_spec.rb +228 -0
- data/spec/rest/users_spec.rb +176 -91
- data/spec/rest/webhooks/event_spec.rb +59 -85
- data/spec/rest/webhooks/parse_spec.rb +51 -71
- data/spec/rest/whitelabel/domains_spec.rb +333 -513
- data/spec/rest/whitelabel/ips_spec.rb +109 -147
- data/spec/rest/whitelabel/links_spec.rb +181 -265
- metadata +70 -40
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +0 -80
- data/lib/sendgrid4r/rest/api_keys/permissions.rb +0 -33
- data/lib/sendgrid4r/rest/campaigns/campaigns.rb +0 -126
- data/lib/sendgrid4r/rest/categories/categories.rb +0 -43
- data/lib/sendgrid4r/rest/contacts/recipients.rb +0 -150
- data/lib/sendgrid4r/rest/contacts/segments.rb +0 -97
- data/lib/sendgrid4r/rest/email_activity/email_activity.rb +0 -81
- data/lib/sendgrid4r/rest/templates/templates.rb +0 -69
- data/lib/sendgrid4r/rest/templates/versions.rb +0 -95
- data/spec/rest/api_keys/api_keys_spec.rb +0 -210
- data/spec/rest/api_keys/permissions_spec.rb +0 -65
- data/spec/rest/campaigns/campaigns_spec.rb +0 -492
- data/spec/rest/categories/categories_spec.rb +0 -96
- data/spec/rest/contacts/custom_fields_spec.rb +0 -174
- data/spec/rest/contacts/lists_spec.rb +0 -372
- data/spec/rest/contacts/recipients_spec.rb +0 -343
- data/spec/rest/contacts/reserved_fields_spec.rb +0 -146
- data/spec/rest/contacts/segments_spec.rb +0 -307
- data/spec/rest/email_activity/email_activity_spec.rb +0 -179
- data/spec/rest/templates/templates_spec.rb +0 -222
- data/spec/rest/templates/versions_spec.rb +0 -252
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
3
|
|
4
|
-
|
5
|
-
describe
|
6
|
-
|
7
|
-
|
4
|
+
module SendGrid4r::REST::Whitelabel
|
5
|
+
describe Ips do
|
6
|
+
describe 'integration test', :it do
|
7
|
+
before do
|
8
8
|
Dotenv.load
|
9
9
|
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
10
10
|
@subdomain_name = ENV['SUBDOMAIN_IP']
|
@@ -21,29 +21,19 @@ describe SendGrid4r::REST::Whitelabel::Ips do
|
|
21
21
|
@ipw = @client.post_wl_ip(
|
22
22
|
ip: @ip, subdomain: @subdomain_name, domain: @domain_name
|
23
23
|
)
|
24
|
-
rescue RestClient::ExceptionWithResponse => e
|
25
|
-
puts e.inspect
|
26
|
-
raise e
|
27
24
|
end
|
28
|
-
end
|
29
25
|
|
30
|
-
|
31
|
-
|
32
|
-
begin
|
26
|
+
context 'without block call' do
|
27
|
+
it '#get_wl_ips' do
|
33
28
|
ips = @client.get_wl_ips
|
34
29
|
expect(ips).to be_a(Array)
|
35
30
|
ips.each do |ip|
|
36
|
-
expect(ip).to be_a(
|
31
|
+
expect(ip).to be_a(Ips::Ip)
|
37
32
|
end
|
38
|
-
rescue RestClient::ExceptionWithResponse => e
|
39
|
-
puts e.inspect
|
40
|
-
raise e
|
41
33
|
end
|
42
|
-
end
|
43
34
|
|
44
|
-
|
45
|
-
|
46
|
-
expect(@ipw).to be_a(SendGrid4r::REST::Whitelabel::Ips::Ip)
|
35
|
+
it '#post_wl_ip' do
|
36
|
+
expect(@ipw).to be_a(Ips::Ip)
|
47
37
|
expect(@ipw.id).to be_a(Numeric)
|
48
38
|
expect(@ipw.ip).to eq(@ip)
|
49
39
|
expect(@ipw.rdns).to be_a(String)
|
@@ -52,177 +42,149 @@ describe SendGrid4r::REST::Whitelabel::Ips do
|
|
52
42
|
expect(@ipw.domain).to eq(@domain_name)
|
53
43
|
expect(@ipw.valid).to eq(false)
|
54
44
|
expect(@ipw.legacy).to eq(false)
|
55
|
-
expect(@ipw.a_record).to be_a(
|
56
|
-
SendGrid4r::REST::Whitelabel::Ips::ARecord
|
57
|
-
)
|
45
|
+
expect(@ipw.a_record).to be_a(Ips::ARecord)
|
58
46
|
expect(@ipw.a_record.valid).to eq(false)
|
59
47
|
expect(@ipw.a_record.type).to eq('a')
|
60
48
|
expect(@ipw.a_record.host).to be_a(String)
|
61
49
|
expect(@ipw.a_record.data).to eq(@ip)
|
62
|
-
rescue RestClient::ExceptionWithResponse => e
|
63
|
-
puts e.inspect
|
64
|
-
raise e
|
65
50
|
end
|
66
|
-
end
|
67
51
|
|
68
|
-
|
69
|
-
begin
|
52
|
+
it '#get_wl_ip' do
|
70
53
|
ip = @client.get_wl_ip(id: @ipw.id)
|
71
|
-
expect(ip).to be_a(
|
54
|
+
expect(ip).to be_a(Ips::Ip)
|
72
55
|
expect(ip.ip).to eq(@ip)
|
73
56
|
expect(ip.users).to be_a(Array)
|
74
57
|
expect(ip.subdomain).to eq(@subdomain_name)
|
75
58
|
expect(ip.domain).to eq(@domain_name)
|
76
59
|
expect(ip.valid).to eq(false)
|
77
60
|
expect(ip.legacy).to eq(false)
|
78
|
-
expect(ip.a_record).to be_a(
|
79
|
-
SendGrid4r::REST::Whitelabel::Ips::ARecord
|
80
|
-
)
|
61
|
+
expect(ip.a_record).to be_a(Ips::ARecord)
|
81
62
|
expect(ip.a_record.valid).to eq(false)
|
82
63
|
expect(ip.a_record.type).to eq('a')
|
83
64
|
expect(ip.a_record.host).to be_a(String)
|
84
65
|
expect(ip.a_record.data).to eq(@ip)
|
85
|
-
rescue RestClient::ExceptionWithResponse => e
|
86
|
-
puts e.inspect
|
87
|
-
raise e
|
88
66
|
end
|
89
|
-
end
|
90
67
|
|
91
|
-
|
92
|
-
begin
|
68
|
+
it '#delete_wl_ip' do
|
93
69
|
@client.delete_wl_ip(id: @ipw.id)
|
94
|
-
rescue RestClient::ExceptionWithResponse => e
|
95
|
-
puts e.inspect
|
96
|
-
raise e
|
97
70
|
end
|
98
|
-
end
|
99
71
|
|
100
|
-
|
101
|
-
begin
|
72
|
+
it '#validate_wl_ip' do
|
102
73
|
result = @client.validate_wl_ip(id: @ipw.id)
|
103
|
-
expect(result).to be_a(
|
104
|
-
SendGrid4r::REST::Whitelabel::Ips::Result
|
105
|
-
)
|
74
|
+
expect(result).to be_a(Ips::Result)
|
106
75
|
expect(result.valid).to be(false)
|
107
76
|
expect(result.validation_results.a_record.valid).to be(false)
|
108
77
|
expect(result.validation_results.a_record.reason).to be_a(String)
|
109
|
-
rescue RestClient::ExceptionWithResponse => e
|
110
|
-
puts e.inspect
|
111
|
-
raise e
|
112
78
|
end
|
113
79
|
end
|
114
80
|
end
|
115
|
-
end
|
116
81
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
82
|
+
describe 'unit test', :ut do
|
83
|
+
let(:client) do
|
84
|
+
SendGrid4r::Client.new(api_key: '')
|
85
|
+
end
|
121
86
|
|
122
|
-
|
123
|
-
|
124
|
-
|
87
|
+
let(:ips) do
|
88
|
+
JSON.parse('[]')
|
89
|
+
end
|
125
90
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
'"valid": true,'\
|
137
|
-
'"legacy": false,'\
|
138
|
-
'"a_record": {'\
|
91
|
+
let(:ip) do
|
92
|
+
JSON.parse(
|
93
|
+
'{'\
|
94
|
+
'"id": 123,'\
|
95
|
+
'"ip": "192.168.1.2",'\
|
96
|
+
'"rdns": "o1.email.example.com",'\
|
97
|
+
'"users": ['\
|
98
|
+
'],'\
|
99
|
+
'"subdomain": "email",'\
|
100
|
+
'"domain": "example.com",'\
|
139
101
|
'"valid": true,'\
|
140
|
-
'"
|
141
|
-
'"host": "o1.email.example.com",'\
|
142
|
-
'"data": "192.168.1.2"'\
|
143
|
-
'}'\
|
144
|
-
'}'
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
let(:result) do
|
149
|
-
JSON.parse(
|
150
|
-
'{'\
|
151
|
-
'"id": 1,'\
|
152
|
-
'"valid": true,'\
|
153
|
-
'"validation_results": {'\
|
102
|
+
'"legacy": false,'\
|
154
103
|
'"a_record": {'\
|
155
104
|
'"valid": true,'\
|
156
|
-
'"
|
105
|
+
'"type": "a",'\
|
106
|
+
'"host": "o1.email.example.com",'\
|
107
|
+
'"data": "192.168.1.2"'\
|
157
108
|
'}'\
|
158
|
-
'}'
|
159
|
-
|
160
|
-
|
161
|
-
end
|
109
|
+
'}'
|
110
|
+
)
|
111
|
+
end
|
162
112
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
113
|
+
let(:result) do
|
114
|
+
JSON.parse(
|
115
|
+
'{'\
|
116
|
+
'"id": 1,'\
|
117
|
+
'"valid": true,'\
|
118
|
+
'"validation_results": {'\
|
119
|
+
'"a_record": {'\
|
120
|
+
'"valid": true,'\
|
121
|
+
'"reason": null'\
|
122
|
+
'}'\
|
123
|
+
'}'\
|
124
|
+
'}'
|
125
|
+
)
|
126
|
+
end
|
168
127
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
128
|
+
it '#get_wl_ips' do
|
129
|
+
allow(client).to receive(:execute).and_return(ips)
|
130
|
+
actual = client.get_wl_ips
|
131
|
+
expect(actual).to be_a(Array)
|
132
|
+
end
|
174
133
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
134
|
+
it '#post_wl_ip' do
|
135
|
+
allow(client).to receive(:execute).and_return(ip)
|
136
|
+
actual = client.post_wl_ip(ip: '', subdomain: '', domain: '')
|
137
|
+
expect(actual).to be_a(Ips::Ip)
|
138
|
+
end
|
180
139
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
140
|
+
it '#get_wl_ip' do
|
141
|
+
allow(client).to receive(:execute).and_return(ip)
|
142
|
+
actual = client.get_wl_ip(id: '')
|
143
|
+
expect(actual).to be_a(Ips::Ip)
|
144
|
+
end
|
186
145
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
146
|
+
it '#delete_wl_ip' do
|
147
|
+
allow(client).to receive(:execute).and_return('')
|
148
|
+
actual = client.delete_wl_ip(id: '')
|
149
|
+
expect(actual).to eq('')
|
150
|
+
end
|
192
151
|
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
152
|
+
it '#validate_wl_ip' do
|
153
|
+
allow(client).to receive(:execute).and_return(result)
|
154
|
+
actual = client.validate_wl_ip(id: '')
|
155
|
+
expect(actual).to be_a(Ips::Result)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'creates ip instance' do
|
159
|
+
actual = Ips.create_ip(ip)
|
160
|
+
expect(actual).to be_a(Ips::Ip)
|
161
|
+
expect(actual.id).to eq(123)
|
162
|
+
expect(actual.ip).to eq('192.168.1.2')
|
163
|
+
expect(actual.rdns).to eq('o1.email.example.com')
|
164
|
+
expect(actual.users).to eq([])
|
165
|
+
expect(actual.subdomain).to eq('email')
|
166
|
+
expect(actual.domain).to eq('example.com')
|
167
|
+
expect(actual.valid).to eq(true)
|
168
|
+
expect(actual.legacy).to eq(false)
|
169
|
+
expect(actual.a_record).to be_a(Ips::ARecord)
|
170
|
+
expect(actual.a_record.valid).to eq(true)
|
171
|
+
expect(actual.a_record.type).to eq('a')
|
172
|
+
expect(actual.a_record.host).to eq('o1.email.example.com')
|
173
|
+
expect(actual.a_record.data).to eq('192.168.1.2')
|
174
|
+
end
|
212
175
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
expect(actual.validation_results.a_record.reason).to be(nil)
|
176
|
+
it 'creates result instance' do
|
177
|
+
actual = Ips.create_result(result)
|
178
|
+
expect(actual).to be_a(Ips::Result)
|
179
|
+
expect(actual.id).to eq(1)
|
180
|
+
expect(actual.valid).to eq(true)
|
181
|
+
expect(actual.validation_results).to be_a(Ips::ValidationResults)
|
182
|
+
expect(actual.validation_results.a_record).to be_a(
|
183
|
+
Ips::ValidationResult
|
184
|
+
)
|
185
|
+
expect(actual.validation_results.a_record.valid).to be(true)
|
186
|
+
expect(actual.validation_results.a_record.reason).to be(nil)
|
187
|
+
end
|
226
188
|
end
|
227
189
|
end
|
228
190
|
end
|