sendgrid4r 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +1 -0
- data/lib/client.rb +1 -0
- data/lib/sendgrid4r/factory/campaign_factory.rb +25 -0
- data/lib/sendgrid4r/factory/segment_factory.rb +8 -4
- data/lib/sendgrid4r/rest/api.rb +2 -0
- data/lib/sendgrid4r/rest/campaigns/campaigns.rb +128 -0
- data/lib/sendgrid4r/rest/contacts/lists.rb +7 -5
- data/lib/sendgrid4r/rest/contacts/recipients.rb +25 -31
- data/lib/sendgrid4r/rest/contacts/segments.rb +4 -9
- data/lib/sendgrid4r/rest/request.rb +3 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/client_spec.rb +21 -8
- data/spec/factory/campaign_factory_spec.rb +38 -0
- data/spec/factory/segment_factory_spec.rb +0 -2
- data/spec/rest/campaigns/campaigns_spec.rb +454 -0
- data/spec/rest/contacts/lists_spec.rb +10 -12
- data/spec/rest/contacts/recipients_spec.rb +80 -133
- data/spec/rest/contacts/segments_spec.rb +24 -109
- metadata +8 -2
@@ -5,7 +5,6 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
begin
|
8
|
-
pending 'waiting sendgrid documentation update'
|
9
8
|
Dotenv.load
|
10
9
|
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
11
10
|
@email1 = 'jones@example.com'
|
@@ -33,7 +32,7 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
33
32
|
params['email'] = @email1
|
34
33
|
params['last_name'] = @last_name1
|
35
34
|
params[@custom_field_name] = @pet1
|
36
|
-
@
|
35
|
+
@result = @client.post_recipients(params: [params])
|
37
36
|
rescue RestClient::ExceptionWithResponse => e
|
38
37
|
puts e.inspect
|
39
38
|
raise e
|
@@ -41,77 +40,59 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
context 'without block call' do
|
44
|
-
it '#
|
43
|
+
it '#post_recipients' do
|
45
44
|
begin
|
46
45
|
params = {}
|
47
46
|
params['email'] = @email2
|
48
47
|
params['last_name'] = @last_name2
|
49
48
|
params[@custom_field_name] = @pet2
|
50
|
-
|
51
|
-
expect(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
expect(new_recipient.email).to eq(@email2)
|
58
|
-
expect(new_recipient.first_name).to eq(nil)
|
59
|
-
expect(new_recipient.id).to eq(@email2)
|
60
|
-
expect(new_recipient.last_clicked).to eq(nil)
|
61
|
-
expect(new_recipient.last_emailed).to eq(nil)
|
62
|
-
expect(new_recipient.last_name).to eq(@last_name2)
|
63
|
-
expect(new_recipient.last_opened).to eq(nil)
|
64
|
-
expect(new_recipient.updated_at).to be_a(Time)
|
49
|
+
result = @client.post_recipients(params: [params])
|
50
|
+
expect(result.error_count).to eq(0)
|
51
|
+
expect(result.error_indices).to eq([])
|
52
|
+
expect(result.new_count).to eq(1)
|
53
|
+
expect(result.persisted_recipients).to be_a(Array)
|
54
|
+
expect(result.updated_count).to eq(0)
|
65
55
|
rescue RestClient::ExceptionWithResponse => e
|
66
56
|
puts e.inspect
|
67
57
|
raise e
|
68
58
|
end
|
69
59
|
end
|
70
60
|
|
71
|
-
it '#
|
61
|
+
it '#patch_recipients' do
|
72
62
|
begin
|
73
63
|
params = {}
|
74
64
|
params['email'] = @email1
|
75
|
-
params['last_name'] =
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
it '#get_recipients' do
|
85
|
-
begin
|
86
|
-
recipients = @client.get_recipients(limit: 100, offset: 0)
|
87
|
-
expect(recipients.recipients.length).to be > 0
|
88
|
-
recipients.recipients.each do |recipient|
|
89
|
-
expect(
|
90
|
-
recipient
|
91
|
-
).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
92
|
-
end
|
65
|
+
params['last_name'] = 'JonesEdit'
|
66
|
+
result = @client.patch_recipients(params: [params])
|
67
|
+
expect(result.error_count).to eq(0)
|
68
|
+
expect(result.error_indices).to eq([])
|
69
|
+
expect(result.new_count).to eq(0)
|
70
|
+
expect(result.persisted_recipients).to be_a(Array)
|
71
|
+
expect(result.updated_count).to eq(1)
|
93
72
|
rescue RestClient::ExceptionWithResponse => e
|
94
73
|
puts e.inspect
|
95
74
|
raise e
|
96
75
|
end
|
97
76
|
end
|
98
77
|
|
99
|
-
it '#
|
78
|
+
it '#delete_recipients' do
|
100
79
|
begin
|
101
|
-
|
102
|
-
expect(actual_count).to be >= 0
|
80
|
+
@client.delete_recipients(recipient_ids: @result.persisted_recipients)
|
103
81
|
rescue RestClient::ExceptionWithResponse => e
|
104
82
|
puts e.inspect
|
105
83
|
raise e
|
106
84
|
end
|
107
85
|
end
|
108
86
|
|
109
|
-
it '#
|
87
|
+
it '#get_recipients' do
|
110
88
|
begin
|
111
|
-
|
112
|
-
|
113
|
-
recipients
|
114
|
-
|
89
|
+
recipients = @client.get_recipients(page: 1, page_size: 100)
|
90
|
+
expect(recipients.recipients.length).to be > 0
|
91
|
+
recipients.recipients.each do |recipient|
|
92
|
+
expect(
|
93
|
+
recipient
|
94
|
+
).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
95
|
+
end
|
115
96
|
rescue RestClient::ExceptionWithResponse => e
|
116
97
|
puts e.inspect
|
117
98
|
raise e
|
@@ -120,7 +101,9 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
120
101
|
|
121
102
|
it '#get_recipient' do
|
122
103
|
begin
|
123
|
-
recipient = @client.get_recipient(
|
104
|
+
recipient = @client.get_recipient(
|
105
|
+
recipient_id: @result.persisted_recipients[0]
|
106
|
+
)
|
124
107
|
expect(
|
125
108
|
recipient
|
126
109
|
).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
@@ -130,58 +113,29 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
130
113
|
end
|
131
114
|
end
|
132
115
|
|
133
|
-
it '#
|
116
|
+
it '#delete_recipient' do
|
134
117
|
begin
|
135
|
-
|
136
|
-
recipient_id: @
|
118
|
+
@client.delete_recipient(
|
119
|
+
recipient_id: @result.persisted_recipients[0]
|
137
120
|
)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
).to eq(true)
|
142
|
-
end
|
143
|
-
rescue RestClient::ExceptionWithResponse => e
|
144
|
-
puts e.inspect
|
145
|
-
raise e
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
it '#post_recipients' do
|
150
|
-
begin
|
151
|
-
recipient1 = {}
|
152
|
-
recipient1['email'] = @email1
|
153
|
-
recipient1['last_name'] = @last_name1
|
154
|
-
recipient1[@custom_field_name] = @pet1
|
155
|
-
recipient2 = {}
|
156
|
-
recipient2['email'] = @email2
|
157
|
-
recipient2['last_name'] = @last_name2
|
158
|
-
recipient2[@custom_field_name] = @pet2
|
159
|
-
params = [recipient1, recipient2]
|
160
|
-
result = @client.post_recipients(params: params)
|
161
|
-
expect(result.error_count).to eq(0)
|
162
|
-
result.error_indices.each do |index|
|
163
|
-
expect(index).to be_a(Fixnum)
|
164
|
-
end
|
165
|
-
expect(result.new_count).to be_a(Fixnum)
|
166
|
-
expect(result.updated_count).to be_a(Fixnum)
|
121
|
+
expect do
|
122
|
+
@client.get_recipient(recipient_id: @result.persisted_recipients[0])
|
123
|
+
end.to raise_error(RestClient::ResourceNotFound)
|
167
124
|
rescue RestClient::ExceptionWithResponse => e
|
168
125
|
puts e.inspect
|
169
126
|
raise e
|
170
127
|
end
|
171
128
|
end
|
172
129
|
|
173
|
-
it '#
|
130
|
+
it '#get_lists_recipient_belong' do
|
174
131
|
begin
|
175
|
-
|
176
|
-
|
177
|
-
recipient_ids: recipient_ids
|
132
|
+
lists = @client.get_lists_recipient_belong(
|
133
|
+
recipient_id: @result.persisted_recipients[0]
|
178
134
|
)
|
179
|
-
|
180
|
-
expect(actual_recipients.recipients.length).to eq(1)
|
181
|
-
actual_recipients.recipients.each do |recip|
|
135
|
+
lists.lists.each do |list|
|
182
136
|
expect(
|
183
|
-
|
184
|
-
).to
|
137
|
+
list.is_a?(SendGrid4r::REST::Contacts::Lists::List)
|
138
|
+
).to eq(true)
|
185
139
|
end
|
186
140
|
rescue RestClient::ExceptionWithResponse => e
|
187
141
|
puts e.inspect
|
@@ -189,21 +143,22 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
189
143
|
end
|
190
144
|
end
|
191
145
|
|
192
|
-
it '#
|
146
|
+
it '#get_recipient_count' do
|
193
147
|
begin
|
194
|
-
@client.
|
195
|
-
expect
|
196
|
-
@client.get_recipient(recipient_id: @new_recipient.id)
|
197
|
-
end.to raise_error(RestClient::ResourceNotFound)
|
148
|
+
actual_count = @client.get_recipients_count
|
149
|
+
expect(actual_count).to be >= 0
|
198
150
|
rescue RestClient::ExceptionWithResponse => e
|
199
151
|
puts e.inspect
|
200
152
|
raise e
|
201
153
|
end
|
202
154
|
end
|
203
155
|
|
204
|
-
it '#
|
156
|
+
it '#search_recipients' do
|
205
157
|
begin
|
206
|
-
|
158
|
+
params = {}
|
159
|
+
params['email'] = @email1
|
160
|
+
recipients = @client.search_recipients(params: params)
|
161
|
+
expect(recipients.recipients).to be_a(Array)
|
207
162
|
rescue RestClient::ExceptionWithResponse => e
|
208
163
|
puts e.inspect
|
209
164
|
raise e
|
@@ -223,7 +178,7 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
223
178
|
'"created_at": 1422313607,'\
|
224
179
|
'"email": "jones@example.com",'\
|
225
180
|
'"first_name": null,'\
|
226
|
-
'"id": "
|
181
|
+
'"id": "YUBh",'\
|
227
182
|
'"last_clicked": null,'\
|
228
183
|
'"last_emailed": null,'\
|
229
184
|
'"last_name": "Jones",'\
|
@@ -249,7 +204,7 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
249
204
|
'"created_at": 1422313607,'\
|
250
205
|
'"email": "jones@example.com",'\
|
251
206
|
'"first_name": null,'\
|
252
|
-
'"id": "
|
207
|
+
'"id": "YUBh",'\
|
253
208
|
'"last_clicked": null,'\
|
254
209
|
'"last_emailed": null,'\
|
255
210
|
'"last_name": "Jones",'\
|
@@ -307,68 +262,60 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
307
262
|
)
|
308
263
|
end
|
309
264
|
|
310
|
-
it '#
|
311
|
-
allow(client).to receive(:execute).and_return(
|
312
|
-
actual = client.
|
313
|
-
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::
|
265
|
+
it '#post_recipients' do
|
266
|
+
allow(client).to receive(:execute).and_return(result)
|
267
|
+
actual = client.post_recipients(params: {})
|
268
|
+
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Result)
|
314
269
|
end
|
315
270
|
|
316
|
-
it '#
|
317
|
-
allow(client).to receive(:execute).and_return(
|
318
|
-
actual = client.
|
319
|
-
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::
|
271
|
+
it '#patch_recipients' do
|
272
|
+
allow(client).to receive(:execute).and_return(result)
|
273
|
+
actual = client.patch_recipients(params: {})
|
274
|
+
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Result)
|
320
275
|
end
|
321
276
|
|
322
|
-
it '#
|
323
|
-
allow(client).to receive(:execute).and_return(
|
324
|
-
actual = client.
|
325
|
-
expect(actual).to
|
277
|
+
it '#delete_recipients' do
|
278
|
+
allow(client).to receive(:execute).and_return('')
|
279
|
+
actual = client.delete_recipients(recipient_ids: ['', ''])
|
280
|
+
expect(actual).to eq('')
|
326
281
|
end
|
327
282
|
|
328
|
-
it '#
|
283
|
+
it '#get_recipients' do
|
329
284
|
allow(client).to receive(:execute).and_return(recipients)
|
330
|
-
actual = client.
|
285
|
+
actual = client.get_recipients(page: 0, page_size: 0)
|
331
286
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipients)
|
332
287
|
end
|
333
288
|
|
334
289
|
it '#get_recipient' do
|
335
290
|
allow(client).to receive(:execute).and_return(recipient)
|
336
|
-
actual = client.get_recipient(recipient_id:
|
291
|
+
actual = client.get_recipient(recipient_id: '')
|
337
292
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
338
293
|
end
|
339
294
|
|
295
|
+
it '#delete_recipient' do
|
296
|
+
allow(client).to receive(:execute).and_return('')
|
297
|
+
actual = client.delete_recipient(recipient_id: '')
|
298
|
+
expect(actual).to eq('')
|
299
|
+
end
|
300
|
+
|
340
301
|
it '#get_lists_recipient_belong' do
|
341
302
|
allow(client).to receive(:execute).and_return(lists)
|
342
|
-
actual = client.get_lists_recipient_belong(recipient_id:
|
303
|
+
actual = client.get_lists_recipient_belong(recipient_id: '')
|
343
304
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Lists::Lists)
|
344
305
|
end
|
345
306
|
|
346
|
-
it '#
|
347
|
-
allow(client).to receive(:execute).and_return(
|
348
|
-
actual = client.
|
349
|
-
expect(actual).to be_a(
|
350
|
-
SendGrid4r::REST::Contacts::Recipients::ResultAddMultiple
|
351
|
-
)
|
307
|
+
it '#get_recipient_count' do
|
308
|
+
allow(client).to receive(:execute).and_return(recipient_count)
|
309
|
+
actual = client.get_recipients_count
|
310
|
+
expect(actual).to be_a(Fixnum)
|
352
311
|
end
|
353
312
|
|
354
|
-
it '#
|
313
|
+
it '#search_recipients' do
|
355
314
|
allow(client).to receive(:execute).and_return(recipients)
|
356
|
-
actual = client.
|
315
|
+
actual = client.search_recipients(params: {})
|
357
316
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipients)
|
358
317
|
end
|
359
318
|
|
360
|
-
it '#delete_recipient' do
|
361
|
-
allow(client).to receive(:execute).and_return('')
|
362
|
-
actual = client.delete_recipient(recipient_id: 0)
|
363
|
-
expect(actual).to eq('')
|
364
|
-
end
|
365
|
-
|
366
|
-
it '#delete_recipients' do
|
367
|
-
allow(client).to receive(:execute).and_return('')
|
368
|
-
actual = client.delete_recipients(emails: ['', ''])
|
369
|
-
expect(actual).to eq('')
|
370
|
-
end
|
371
|
-
|
372
319
|
it 'creates recipient instance' do
|
373
320
|
actual = SendGrid4r::REST::Contacts::Recipients.create_recipient(
|
374
321
|
recipient
|
@@ -377,7 +324,7 @@ describe SendGrid4r::REST::Contacts::Recipients do
|
|
377
324
|
expect(actual.created_at).to eq(Time.at(1422313607))
|
378
325
|
expect(actual.email).to eq('jones@example.com')
|
379
326
|
expect(actual.first_name).to eq(nil)
|
380
|
-
expect(actual.id).to eq('
|
327
|
+
expect(actual.id).to eq('YUBh')
|
381
328
|
expect(actual.last_clicked).to eq(nil)
|
382
329
|
expect(actual.last_emailed).to eq(nil)
|
383
330
|
expect(actual.last_name).to eq('Jones')
|
@@ -41,7 +41,7 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
41
41
|
field: @field, value: @value, operator: @operator, and_or: @and_or
|
42
42
|
)
|
43
43
|
params1 = @segment_factory.create(
|
44
|
-
name: @name1, conditions: [@condition]
|
44
|
+
name: @name1, list_id: nil, conditions: [@condition]
|
45
45
|
)
|
46
46
|
@segment1 = @client.post_segment(params: params1)
|
47
47
|
rescue RestClient::ExceptionWithResponse => e
|
@@ -53,13 +53,14 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
53
53
|
context 'without block call' do
|
54
54
|
it '#post_segment' do
|
55
55
|
begin
|
56
|
+
lists = @client.get_lists
|
56
57
|
params2 = @segment_factory.create(
|
57
|
-
name: @name2, conditions: [@condition]
|
58
|
+
name: @name2, list_id: lists.lists[0].id, conditions: [@condition]
|
58
59
|
)
|
59
60
|
segment = @client.post_segment(params: params2)
|
60
61
|
expect(segment.id).to be_a(Fixnum)
|
61
62
|
expect(segment.name).to eq(@name2)
|
62
|
-
expect(segment.list_id).to eq(
|
63
|
+
expect(segment.list_id).to eq(lists.lists[0].id)
|
63
64
|
expect(segment.conditions.length).to eq(1)
|
64
65
|
expect(segment.recipient_count).to eq(0)
|
65
66
|
condition = segment.conditions[0]
|
@@ -106,13 +107,12 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
109
|
-
it '#
|
110
|
+
it '#patch_segment' do
|
110
111
|
begin
|
111
|
-
pending 'waiting for sendgrid documentation update'
|
112
112
|
edit_params = @segment_factory.create(
|
113
113
|
name: @edit_name1, conditions: [@condition]
|
114
114
|
)
|
115
|
-
edit_segment = @client.
|
115
|
+
edit_segment = @client.patch_segment(
|
116
116
|
segment_id: @segment1.id, params: edit_params
|
117
117
|
)
|
118
118
|
expect(edit_segment.name).to eq(@edit_name1)
|
@@ -122,116 +122,31 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
it '#
|
125
|
+
it '#delete_segment' do
|
126
126
|
begin
|
127
|
-
|
128
|
-
recipients = @client.get_recipients_from_segment(
|
129
|
-
segment_id: @segment1.id
|
130
|
-
)
|
131
|
-
recipients.recipients.each do |recipient|
|
132
|
-
expect(
|
133
|
-
recipient
|
134
|
-
).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
135
|
-
end
|
127
|
+
@client.delete_segment(segment_id: @segment1.id)
|
136
128
|
rescue RestClient::ExceptionWithResponse => e
|
137
129
|
puts e.inspect
|
138
130
|
raise e
|
139
131
|
end
|
140
132
|
end
|
141
133
|
|
142
|
-
it '#
|
134
|
+
it '#get_recipients_on_segment' do
|
143
135
|
begin
|
144
|
-
|
145
|
-
|
136
|
+
recipients = @client.get_recipients_on_segment(
|
137
|
+
segment_id: @segment1.id
|
138
|
+
)
|
139
|
+
recipients.recipients.each do |recipient|
|
140
|
+
expect(
|
141
|
+
recipient
|
142
|
+
).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipient)
|
143
|
+
end
|
146
144
|
rescue RestClient::ExceptionWithResponse => e
|
147
145
|
puts e.inspect
|
148
146
|
raise e
|
149
147
|
end
|
150
148
|
end
|
151
149
|
end
|
152
|
-
|
153
|
-
context 'with block all' do
|
154
|
-
it '#post_segment' do
|
155
|
-
params2 = @segment_factory.create(
|
156
|
-
name: @name2, conditions: [@condition]
|
157
|
-
)
|
158
|
-
@client.post_segment(params: params2) do |resp, req, res|
|
159
|
-
resp =
|
160
|
-
SendGrid4r::REST::Contacts::Segments.create_segment(
|
161
|
-
JSON.parse(resp)
|
162
|
-
)
|
163
|
-
expect(resp).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
164
|
-
expect(req).to be_a(RestClient::Request)
|
165
|
-
expect(res).to be_a(Net::HTTPCreated)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
it '#get_segments' do
|
170
|
-
@client.get_segments do |resp, req, res|
|
171
|
-
resp =
|
172
|
-
SendGrid4r::REST::Contacts::Segments.create_segments(
|
173
|
-
JSON.parse(resp)
|
174
|
-
)
|
175
|
-
expect(resp).to be_a(SendGrid4r::REST::Contacts::Segments::Segments)
|
176
|
-
expect(req).to be_a(RestClient::Request)
|
177
|
-
expect(res).to be_a(Net::HTTPOK)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
it '#get_segment' do
|
182
|
-
@client.get_segment(segment_id: @segment1.id) do |resp, req, res|
|
183
|
-
resp =
|
184
|
-
SendGrid4r::REST::Contacts::Segments.create_segment(
|
185
|
-
JSON.parse(resp)
|
186
|
-
)
|
187
|
-
expect(resp).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
188
|
-
expect(req).to be_a(RestClient::Request)
|
189
|
-
expect(res).to be_a(Net::HTTPOK)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
it '#put_segment' do
|
194
|
-
pending 'waiting for sendgrid documentation update'
|
195
|
-
edit_params = @segment_factory.create(
|
196
|
-
name: @edit_name1, conditions: [@condition]
|
197
|
-
)
|
198
|
-
@client.put_segment(
|
199
|
-
segment_id: @segment1.id, params: edit_params
|
200
|
-
) do |resp, req, res|
|
201
|
-
resp =
|
202
|
-
SendGrid4r::REST::Contacts::Segments.create_segment(
|
203
|
-
JSON.parse(resp)
|
204
|
-
)
|
205
|
-
expect(resp).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
206
|
-
expect(req).to be_a(RestClient::Request)
|
207
|
-
expect(res).to be_a(Net::HTTPOK)
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
it '#get_recipients_from_segment' do
|
212
|
-
@client.get_recipients_from_segment(
|
213
|
-
segment_id: @segment1.id
|
214
|
-
) do |resp, req, res|
|
215
|
-
resp =
|
216
|
-
SendGrid4r::REST::Contacts::Recipients.create_recipients(
|
217
|
-
JSON.parse(resp)
|
218
|
-
)
|
219
|
-
expect(resp).to be_a(
|
220
|
-
SendGrid4r::REST::Contacts::Recipients::Recipients
|
221
|
-
)
|
222
|
-
expect(req).to be_a(RestClient::Request)
|
223
|
-
expect(res).to be_a(Net::HTTPOK)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
it '#delete_segment' do
|
228
|
-
@client.delete_segment(segment_id: @segment1.id) do |resp, req, res|
|
229
|
-
expect(resp).to eq('')
|
230
|
-
expect(req).to be_a(RestClient::Request)
|
231
|
-
expect(res).to be_a(Net::HTTPNoContent)
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
150
|
end
|
236
151
|
|
237
152
|
describe 'unit test', :ut do
|
@@ -255,7 +170,7 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
255
170
|
'{'\
|
256
171
|
'"id": 1,'\
|
257
172
|
'"name": "Last Name Miller",'\
|
258
|
-
'"list_id":
|
173
|
+
'"list_id": 4,'\
|
259
174
|
'"conditions": ['\
|
260
175
|
'{'\
|
261
176
|
'"field": "last_name",'\
|
@@ -276,7 +191,7 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
276
191
|
'{'\
|
277
192
|
'"id": 1,'\
|
278
193
|
'"name": "Last Name Miller",'\
|
279
|
-
'"list_id":
|
194
|
+
'"list_id": 4,'\
|
280
195
|
'"conditions": ['\
|
281
196
|
'{'\
|
282
197
|
'"field": "last_name",'\
|
@@ -338,15 +253,15 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
338
253
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
339
254
|
end
|
340
255
|
|
341
|
-
it '#
|
256
|
+
it '#patch_segment' do
|
342
257
|
allow(client).to receive(:execute).and_return(segment)
|
343
|
-
actual = client.
|
258
|
+
actual = client.patch_segment(segment_id: 0, params: nil)
|
344
259
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
345
260
|
end
|
346
261
|
|
347
|
-
it '#
|
262
|
+
it '#get_recipients_on_segment' do
|
348
263
|
allow(client).to receive(:execute).and_return(recipients)
|
349
|
-
actual = client.
|
264
|
+
actual = client.get_recipients_on_segment(segment_id: 0)
|
350
265
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Recipients::Recipients)
|
351
266
|
end
|
352
267
|
|
@@ -370,7 +285,7 @@ describe SendGrid4r::REST::Contacts::Segments do
|
|
370
285
|
expect(actual).to be_a(SendGrid4r::REST::Contacts::Segments::Segment)
|
371
286
|
expect(actual.id).to eq(1)
|
372
287
|
expect(actual.name).to eq('Last Name Miller')
|
373
|
-
expect(actual.list_id).to eq(
|
288
|
+
expect(actual.list_id).to eq(4)
|
374
289
|
expect(actual.conditions).to be_a(Array)
|
375
290
|
actual.conditions.each do |condition|
|
376
291
|
expect(condition).to be_a(
|
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.2.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: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/auth.rb
|
123
123
|
- lib/client.rb
|
124
124
|
- lib/sendgrid4r.rb
|
125
|
+
- lib/sendgrid4r/factory/campaign_factory.rb
|
125
126
|
- lib/sendgrid4r/factory/condition_factory.rb
|
126
127
|
- lib/sendgrid4r/factory/segment_factory.rb
|
127
128
|
- lib/sendgrid4r/factory/version_factory.rb
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- lib/sendgrid4r/rest/asm/global_suppressions.rb
|
132
133
|
- lib/sendgrid4r/rest/asm/groups.rb
|
133
134
|
- lib/sendgrid4r/rest/asm/suppressions.rb
|
135
|
+
- lib/sendgrid4r/rest/campaigns/campaigns.rb
|
134
136
|
- lib/sendgrid4r/rest/categories/categories.rb
|
135
137
|
- lib/sendgrid4r/rest/contacts/custom_fields.rb
|
136
138
|
- lib/sendgrid4r/rest/contacts/lists.rb
|
@@ -163,6 +165,7 @@ files:
|
|
163
165
|
- lib/sendgrid4r/version.rb
|
164
166
|
- sendgrid4r.gemspec
|
165
167
|
- spec/client_spec.rb
|
168
|
+
- spec/factory/campaign_factory_spec.rb
|
166
169
|
- spec/factory/condition_factory_spec.rb
|
167
170
|
- spec/factory/segment_factory_spec.rb
|
168
171
|
- spec/factory/version_factory_spec.rb
|
@@ -171,6 +174,7 @@ files:
|
|
171
174
|
- spec/rest/asm/global_suppressions_spec.rb
|
172
175
|
- spec/rest/asm/groups_spec.rb
|
173
176
|
- spec/rest/asm/suppressions_spec.rb
|
177
|
+
- spec/rest/campaigns/campaigns_spec.rb
|
174
178
|
- spec/rest/categories/categories_spec.rb
|
175
179
|
- spec/rest/contacts/custom_fields_spec.rb
|
176
180
|
- spec/rest/contacts/lists_spec.rb
|
@@ -226,6 +230,7 @@ specification_version: 4
|
|
226
230
|
summary: SendGrid Web API v3 module
|
227
231
|
test_files:
|
228
232
|
- spec/client_spec.rb
|
233
|
+
- spec/factory/campaign_factory_spec.rb
|
229
234
|
- spec/factory/condition_factory_spec.rb
|
230
235
|
- spec/factory/segment_factory_spec.rb
|
231
236
|
- spec/factory/version_factory_spec.rb
|
@@ -234,6 +239,7 @@ test_files:
|
|
234
239
|
- spec/rest/asm/global_suppressions_spec.rb
|
235
240
|
- spec/rest/asm/groups_spec.rb
|
236
241
|
- spec/rest/asm/suppressions_spec.rb
|
242
|
+
- spec/rest/campaigns/campaigns_spec.rb
|
237
243
|
- spec/rest/categories/categories_spec.rb
|
238
244
|
- spec/rest/contacts/custom_fields_spec.rb
|
239
245
|
- spec/rest/contacts/lists_spec.rb
|