postmark 1.25.0 → 1.25.1
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/CHANGELOG.rdoc +3 -0
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/postmark/account_api_client.rb +1 -0
- data/lib/postmark/version.rb +1 -1
- data/postmark.gemspec +4 -0
- data/spec/unit/postmark/account_api_client_spec.rb +73 -63
- data/spec/unit/postmark/api_client_spec.rb +54 -45
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90fcc71a7a7018bbcd3e4784d0276291a511ada74d290f284ca88d0909aea119
|
4
|
+
data.tar.gz: 8f7474cc7af5f878fd3ffee1f98e8eeab4361e48981359794f0426411c7659ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c90ab55895ab6b55b399e137e5193cc4465d081d554611df9e60751b0167102ffe598594d83c9ff2f94aac0a5ec165ed17cc94386807c9958ec10889972d6d9a
|
7
|
+
data.tar.gz: 9857b3188c3dec4daeaa1217cf0c6e8ce1142a7f057556b931e19ca8c981ed8812d2443a26757f1b7474080d2f406c22404c6b9e4f3021c7ca9326bc10c17428
|
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
@@ -23,8 +23,8 @@ For details about Postmark API in general, please check out [Postmark developer
|
|
23
23
|
You will need a Postmark account, server and sender signature (or verified domain) set up to use it. For details about setup, check out [wiki pages](https://github.com/ActiveCampaign/postmark-gem/wiki/Getting-Started).
|
24
24
|
|
25
25
|
If you plan using the library in a Rails project, check out the [postmark-rails](https://github.com/ActiveCampaign/postmark-rails/) gem, which
|
26
|
-
is meant to integrate with ActionMailer. The plugin will try to use ActiveSupport
|
27
|
-
it will attempt to use the built-in Ruby
|
26
|
+
is meant to integrate with ActionMailer. The plugin will try to use ActiveSupport JSON if it is already included. If not,
|
27
|
+
it will attempt to use the built-in Ruby JSON library.
|
28
28
|
|
29
29
|
You can also explicitly specify which one to be used, using following code:
|
30
30
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.25.
|
1
|
+
1.25.1
|
data/lib/postmark/version.rb
CHANGED
data/postmark.gemspec
CHANGED
@@ -21,6 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
+
if s.respond_to?(:metadata) # not supported in Bundler/Ruby 1.x
|
25
|
+
s.metadata["changelog_uri"] = "https://github.com/ActiveCampaign/postmark-gem/blob/main/CHANGELOG.rdoc"
|
26
|
+
end
|
27
|
+
|
24
28
|
s.post_install_message = %q{
|
25
29
|
==================
|
26
30
|
Thanks for installing the postmark gem. If you don't have an account, please
|
@@ -12,6 +12,13 @@ describe Postmark::AccountApiClient do
|
|
12
12
|
expect { subject.new(api_token, :http_read_timeout => 5) }.not_to raise_error
|
13
13
|
end
|
14
14
|
|
15
|
+
it "doesn't mutate options hash" do
|
16
|
+
options = { "my_option" => true }
|
17
|
+
subject.new(api_token, options)
|
18
|
+
|
19
|
+
expect(options).to eq({ "my_option" => true })
|
20
|
+
end
|
21
|
+
|
15
22
|
context 'instance' do
|
16
23
|
subject { Postmark::AccountApiClient.new(api_token) }
|
17
24
|
|
@@ -37,7 +44,8 @@ describe Postmark::AccountApiClient do
|
|
37
44
|
end
|
38
45
|
|
39
46
|
it 'lazily loads senders' do
|
40
|
-
|
47
|
+
expect(subject.http_client).to receive(:get).
|
48
|
+
exactly(5).times.
|
41
49
|
with('senders', an_instance_of(Hash)).and_return(response)
|
42
50
|
subject.senders.take(1000)
|
43
51
|
end
|
@@ -63,20 +71,20 @@ describe Postmark::AccountApiClient do
|
|
63
71
|
end
|
64
72
|
|
65
73
|
it 'performs a GET request to /senders endpoint' do
|
66
|
-
|
74
|
+
expect(subject.http_client).to receive(:get).
|
67
75
|
with('senders', :offset => 0, :count => 30).
|
68
76
|
and_return(response)
|
69
77
|
subject.get_senders
|
70
78
|
end
|
71
79
|
|
72
80
|
it 'formats the keys of returned list of senders' do
|
73
|
-
|
81
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
74
82
|
keys = subject.get_senders.map { |s| s.keys }.flatten
|
75
83
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
76
84
|
end
|
77
85
|
|
78
86
|
it 'accepts offset and count options' do
|
79
|
-
|
87
|
+
expect(subject.http_client).to receive(:get).
|
80
88
|
with('senders', :offset => 10, :count => 42).
|
81
89
|
and_return(response)
|
82
90
|
subject.get_senders(:offset => 10, :count => 42)
|
@@ -92,7 +100,7 @@ describe Postmark::AccountApiClient do
|
|
92
100
|
end
|
93
101
|
|
94
102
|
it 'returns a total number of senders' do
|
95
|
-
|
103
|
+
expect(subject.http_client).to receive(:get).
|
96
104
|
with('senders', an_instance_of(Hash)).and_return(response)
|
97
105
|
expect(subject.get_senders_count).to eq(42)
|
98
106
|
end
|
@@ -115,13 +123,13 @@ describe Postmark::AccountApiClient do
|
|
115
123
|
end
|
116
124
|
|
117
125
|
it 'performs a GET request to /senders/:id endpoint' do
|
118
|
-
|
126
|
+
expect(subject.http_client).to receive(:get).with("senders/42").
|
119
127
|
and_return(response)
|
120
128
|
subject.get_sender(42)
|
121
129
|
end
|
122
130
|
|
123
131
|
it 'formats the keys of returned response' do
|
124
|
-
|
132
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
125
133
|
keys = subject.get_sender(42).keys
|
126
134
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
127
135
|
end
|
@@ -144,19 +152,19 @@ describe Postmark::AccountApiClient do
|
|
144
152
|
end
|
145
153
|
|
146
154
|
it 'performs a POST request to /senders endpoint' do
|
147
|
-
|
155
|
+
expect(subject.http_client).to receive(:post).
|
148
156
|
with("senders", an_instance_of(String)).and_return(response)
|
149
157
|
subject.create_sender(:name => 'Chris Nagele')
|
150
158
|
end
|
151
159
|
|
152
160
|
it 'converts the sender attributes names to camel case' do
|
153
|
-
|
161
|
+
expect(subject.http_client).to receive(:post).
|
154
162
|
with("senders", {'FooBar' => 'bar'}.to_json).and_return(response)
|
155
163
|
subject.create_sender(:foo_bar => 'bar')
|
156
164
|
end
|
157
165
|
|
158
166
|
it 'formats the keys of returned response' do
|
159
|
-
|
167
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
160
168
|
keys = subject.create_sender(:foo => 'bar').keys
|
161
169
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
162
170
|
end
|
@@ -180,19 +188,19 @@ describe Postmark::AccountApiClient do
|
|
180
188
|
end
|
181
189
|
|
182
190
|
it 'performs a PUT request to /senders/:id endpoint' do
|
183
|
-
|
191
|
+
expect(subject.http_client).to receive(:put).
|
184
192
|
with('senders/42', an_instance_of(String)).and_return(response)
|
185
193
|
subject.update_sender(42, :name => 'Chris Nagele')
|
186
194
|
end
|
187
195
|
|
188
196
|
it 'converts the sender attributes names to camel case' do
|
189
|
-
|
197
|
+
expect(subject.http_client).to receive(:put).
|
190
198
|
with('senders/42', {'FooBar' => 'bar'}.to_json).and_return(response)
|
191
199
|
subject.update_sender(42, :foo_bar => 'bar')
|
192
200
|
end
|
193
201
|
|
194
202
|
it 'formats the keys of returned response' do
|
195
|
-
|
203
|
+
expect(subject.http_client).to receive(:put).and_return(response)
|
196
204
|
keys = subject.update_sender(42, :foo => 'bar').keys
|
197
205
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
198
206
|
end
|
@@ -212,13 +220,13 @@ describe Postmark::AccountApiClient do
|
|
212
220
|
end
|
213
221
|
|
214
222
|
it 'performs a POST request to /senders/:id/resend endpoint' do
|
215
|
-
|
223
|
+
expect(subject.http_client).to receive(:post).
|
216
224
|
with('senders/42/resend').and_return(response)
|
217
225
|
subject.resend_sender_confirmation(42)
|
218
226
|
end
|
219
227
|
|
220
228
|
it 'formats the keys of returned response' do
|
221
|
-
|
229
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
222
230
|
keys = subject.resend_sender_confirmation(42).keys
|
223
231
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
224
232
|
end
|
@@ -233,18 +241,18 @@ describe Postmark::AccountApiClient do
|
|
233
241
|
end
|
234
242
|
|
235
243
|
it 'performs a POST request to /senders/:id/verifyspf endpoint' do
|
236
|
-
|
244
|
+
expect(subject.http_client).to receive(:post).
|
237
245
|
with('senders/42/verifyspf').and_return(response)
|
238
246
|
subject.verified_sender_spf?(42)
|
239
247
|
end
|
240
248
|
|
241
249
|
it 'returns false when SPFVerified field of the response is false' do
|
242
|
-
|
250
|
+
expect(subject.http_client).to receive(:post).and_return(false_response)
|
243
251
|
expect(subject.verified_sender_spf?(42)).to be false
|
244
252
|
end
|
245
253
|
|
246
254
|
it 'returns true when SPFVerified field of the response is true' do
|
247
|
-
|
255
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
248
256
|
expect(subject.verified_sender_spf?(42)).to be true
|
249
257
|
end
|
250
258
|
end
|
@@ -267,13 +275,13 @@ describe Postmark::AccountApiClient do
|
|
267
275
|
end
|
268
276
|
|
269
277
|
it 'performs a POST request to /senders/:id/requestnewdkim endpoint' do
|
270
|
-
|
278
|
+
expect(subject.http_client).to receive(:post).
|
271
279
|
with('senders/42/requestnewdkim').and_return(response)
|
272
280
|
subject.request_new_sender_dkim(42)
|
273
281
|
end
|
274
282
|
|
275
283
|
it 'formats the keys of returned response' do
|
276
|
-
|
284
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
277
285
|
keys = subject.request_new_sender_dkim(42).keys
|
278
286
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
279
287
|
end
|
@@ -292,13 +300,13 @@ describe Postmark::AccountApiClient do
|
|
292
300
|
end
|
293
301
|
|
294
302
|
it 'performs a DELETE request to /senders/:id endpoint' do
|
295
|
-
|
303
|
+
expect(subject.http_client).to receive(:delete).
|
296
304
|
with('senders/42').and_return(response)
|
297
305
|
subject.delete_sender(42)
|
298
306
|
end
|
299
307
|
|
300
308
|
it 'formats the keys of returned response' do
|
301
|
-
|
309
|
+
expect(subject.http_client).to receive(:delete).and_return(response)
|
302
310
|
keys = subject.delete_sender(42).keys
|
303
311
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
304
312
|
end
|
@@ -312,7 +320,8 @@ describe Postmark::AccountApiClient do
|
|
312
320
|
end
|
313
321
|
|
314
322
|
it 'lazily loads domains' do
|
315
|
-
|
323
|
+
expect(subject.http_client).to receive(:get).
|
324
|
+
exactly(5).times.
|
316
325
|
with('domains', an_instance_of(Hash)).and_return(response)
|
317
326
|
subject.domains.take(1000)
|
318
327
|
end
|
@@ -332,20 +341,20 @@ describe Postmark::AccountApiClient do
|
|
332
341
|
}
|
333
342
|
|
334
343
|
it 'performs a GET request to /domains endpoint' do
|
335
|
-
|
344
|
+
expect(subject.http_client).to receive(:get).
|
336
345
|
with('domains', :offset => 0, :count => 30).
|
337
346
|
and_return(response)
|
338
347
|
subject.get_domains
|
339
348
|
end
|
340
349
|
|
341
350
|
it 'formats the keys of returned list of domains' do
|
342
|
-
|
351
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
343
352
|
keys = subject.get_domains.map { |s| s.keys }.flatten
|
344
353
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
345
354
|
end
|
346
355
|
|
347
356
|
it 'accepts offset and count options' do
|
348
|
-
|
357
|
+
expect(subject.http_client).to receive(:get).
|
349
358
|
with('domains', :offset => 10, :count => 42).
|
350
359
|
and_return(response)
|
351
360
|
subject.get_domains(:offset => 10, :count => 42)
|
@@ -357,7 +366,7 @@ describe Postmark::AccountApiClient do
|
|
357
366
|
let(:response) { {'TotalCount' => 42} }
|
358
367
|
|
359
368
|
it 'returns a total number of domains' do
|
360
|
-
|
369
|
+
expect(subject.http_client).to receive(:get).
|
361
370
|
with('domains', an_instance_of(Hash)).and_return(response)
|
362
371
|
expect(subject.get_domains_count).to eq(42)
|
363
372
|
end
|
@@ -372,13 +381,13 @@ describe Postmark::AccountApiClient do
|
|
372
381
|
}
|
373
382
|
|
374
383
|
it 'performs a GET request to /domains/:id endpoint' do
|
375
|
-
|
384
|
+
expect(subject.http_client).to receive(:get).with("domains/42").
|
376
385
|
and_return(response)
|
377
386
|
subject.get_domain(42)
|
378
387
|
end
|
379
388
|
|
380
389
|
it 'formats the keys of returned response' do
|
381
|
-
|
390
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
382
391
|
keys = subject.get_domain(42).keys
|
383
392
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
384
393
|
end
|
@@ -393,19 +402,19 @@ describe Postmark::AccountApiClient do
|
|
393
402
|
}
|
394
403
|
|
395
404
|
it 'performs a POST request to /domains endpoint' do
|
396
|
-
|
405
|
+
expect(subject.http_client).to receive(:post).
|
397
406
|
with("domains", an_instance_of(String)).and_return(response)
|
398
407
|
subject.create_domain(:name => 'example.com')
|
399
408
|
end
|
400
409
|
|
401
410
|
it 'converts the domain attributes names to camel case' do
|
402
|
-
|
411
|
+
expect(subject.http_client).to receive(:post).
|
403
412
|
with("domains", {'FooBar' => 'bar'}.to_json).and_return(response)
|
404
413
|
subject.create_domain(:foo_bar => 'bar')
|
405
414
|
end
|
406
415
|
|
407
416
|
it 'formats the keys of returned response' do
|
408
|
-
|
417
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
409
418
|
keys = subject.create_domain(:foo => 'bar').keys
|
410
419
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
411
420
|
end
|
@@ -421,19 +430,19 @@ describe Postmark::AccountApiClient do
|
|
421
430
|
}
|
422
431
|
|
423
432
|
it 'performs a PUT request to /domains/:id endpoint' do
|
424
|
-
|
433
|
+
expect(subject.http_client).to receive(:put).
|
425
434
|
with('domains/42', an_instance_of(String)).and_return(response)
|
426
435
|
subject.update_domain(42, :return_path_domain => 'updated-return.example.com')
|
427
436
|
end
|
428
437
|
|
429
438
|
it 'converts the domain attributes names to camel case' do
|
430
|
-
|
439
|
+
expect(subject.http_client).to receive(:put).
|
431
440
|
with('domains/42', {'FooBar' => 'bar'}.to_json).and_return(response)
|
432
441
|
subject.update_domain(42, :foo_bar => 'bar')
|
433
442
|
end
|
434
443
|
|
435
444
|
it 'formats the keys of returned response' do
|
436
|
-
|
445
|
+
expect(subject.http_client).to receive(:put).and_return(response)
|
437
446
|
keys = subject.update_domain(42, :foo => 'bar').keys
|
438
447
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
439
448
|
end
|
@@ -444,18 +453,18 @@ describe Postmark::AccountApiClient do
|
|
444
453
|
let(:false_response) { {"SPFVerified" => false} }
|
445
454
|
|
446
455
|
it 'performs a POST request to /domains/:id/verifyspf endpoint' do
|
447
|
-
|
456
|
+
expect(subject.http_client).to receive(:post).
|
448
457
|
with('domains/42/verifyspf').and_return(response)
|
449
458
|
subject.verified_domain_spf?(42)
|
450
459
|
end
|
451
460
|
|
452
461
|
it 'returns false when SPFVerified field of the response is false' do
|
453
|
-
|
462
|
+
expect(subject.http_client).to receive(:post).and_return(false_response)
|
454
463
|
expect(subject.verified_domain_spf?(42)).to be false
|
455
464
|
end
|
456
465
|
|
457
466
|
it 'returns true when SPFVerified field of the response is true' do
|
458
|
-
|
467
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
459
468
|
expect(subject.verified_domain_spf?(42)).to be true
|
460
469
|
end
|
461
470
|
end
|
@@ -469,13 +478,13 @@ describe Postmark::AccountApiClient do
|
|
469
478
|
}
|
470
479
|
|
471
480
|
it 'performs a POST request to /domains/:id/rotatedkim endpoint' do
|
472
|
-
|
481
|
+
expect(subject.http_client).to receive(:post).
|
473
482
|
with('domains/42/rotatedkim').and_return(response)
|
474
483
|
subject.rotate_domain_dkim(42)
|
475
484
|
end
|
476
485
|
|
477
486
|
it 'formats the keys of returned response' do
|
478
|
-
|
487
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
479
488
|
keys = subject.rotate_domain_dkim(42).keys
|
480
489
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
481
490
|
end
|
@@ -490,13 +499,13 @@ describe Postmark::AccountApiClient do
|
|
490
499
|
}
|
491
500
|
|
492
501
|
it 'performs a DELETE request to /domains/:id endpoint' do
|
493
|
-
|
502
|
+
expect(subject.http_client).to receive(:delete).
|
494
503
|
with('domains/42').and_return(response)
|
495
504
|
subject.delete_domain(42)
|
496
505
|
end
|
497
506
|
|
498
507
|
it 'formats the keys of returned response' do
|
499
|
-
|
508
|
+
expect(subject.http_client).to receive(:delete).and_return(response)
|
500
509
|
keys = subject.delete_sender(42).keys
|
501
510
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
502
511
|
end
|
@@ -510,7 +519,8 @@ describe Postmark::AccountApiClient do
|
|
510
519
|
end
|
511
520
|
|
512
521
|
it 'lazily loads servers' do
|
513
|
-
|
522
|
+
expect(subject.http_client).to receive(:get).
|
523
|
+
exactly(5).times.
|
514
524
|
with('servers', an_instance_of(Hash)).and_return(response)
|
515
525
|
subject.servers.take(100)
|
516
526
|
end
|
@@ -542,19 +552,19 @@ describe Postmark::AccountApiClient do
|
|
542
552
|
}
|
543
553
|
|
544
554
|
it 'performs a GET request to /servers endpoint' do
|
545
|
-
|
555
|
+
expect(subject.http_client).to receive(:get).
|
546
556
|
with('servers', an_instance_of(Hash)).and_return(response)
|
547
557
|
subject.get_servers
|
548
558
|
end
|
549
559
|
|
550
560
|
it 'formats the keys of returned list of servers' do
|
551
|
-
|
561
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
552
562
|
keys = subject.get_servers.map { |s| s.keys }.flatten
|
553
563
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
554
564
|
end
|
555
565
|
|
556
566
|
it 'accepts offset and count options' do
|
557
|
-
|
567
|
+
expect(subject.http_client).to receive(:get).
|
558
568
|
with('servers', :offset => 30, :count => 50).
|
559
569
|
and_return(response)
|
560
570
|
subject.get_servers(:offset => 30, :count => 50)
|
@@ -582,13 +592,13 @@ describe Postmark::AccountApiClient do
|
|
582
592
|
}
|
583
593
|
|
584
594
|
it 'performs a GET request to /servers/:id endpoint' do
|
585
|
-
|
595
|
+
expect(subject.http_client).to receive(:get).
|
586
596
|
with('servers/42').and_return(response)
|
587
597
|
subject.get_server(42)
|
588
598
|
end
|
589
599
|
|
590
600
|
it 'formats the keys of returned response' do
|
591
|
-
|
601
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
592
602
|
keys = subject.get_server(42).keys
|
593
603
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
594
604
|
end
|
@@ -598,7 +608,7 @@ describe Postmark::AccountApiClient do
|
|
598
608
|
let(:response) { {'TotalCount' => 42} }
|
599
609
|
|
600
610
|
it 'returns a total number of servers' do
|
601
|
-
|
611
|
+
expect(subject.http_client).to receive(:get).
|
602
612
|
with('servers', an_instance_of(Hash)).and_return(response)
|
603
613
|
expect(subject.get_servers_count).to eq(42)
|
604
614
|
end
|
@@ -619,20 +629,20 @@ describe Postmark::AccountApiClient do
|
|
619
629
|
}
|
620
630
|
|
621
631
|
it 'performs a POST request to /servers endpoint' do
|
622
|
-
|
632
|
+
expect(subject.http_client).to receive(:post).
|
623
633
|
with('servers', an_instance_of(String)).and_return(response)
|
624
634
|
subject.create_server(:foo => 'bar')
|
625
635
|
end
|
626
636
|
|
627
637
|
it 'converts the server attribute names to camel case' do
|
628
|
-
|
638
|
+
expect(subject.http_client).to receive(:post).
|
629
639
|
with('servers', {'FooBar' => 'foo_bar'}.to_json).
|
630
640
|
and_return(response)
|
631
641
|
subject.create_server(:foo_bar => 'foo_bar')
|
632
642
|
end
|
633
643
|
|
634
644
|
it 'formats the keys of returned response' do
|
635
|
-
|
645
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
636
646
|
keys = subject.create_server(:foo => 'bar').keys
|
637
647
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
638
648
|
end
|
@@ -659,21 +669,21 @@ describe Postmark::AccountApiClient do
|
|
659
669
|
}
|
660
670
|
|
661
671
|
it 'converts the server attribute names to camel case' do
|
662
|
-
|
672
|
+
expect(subject.http_client).to receive(:put).
|
663
673
|
with(an_instance_of(String), {'FooBar' => 'foo_bar'}.to_json).
|
664
674
|
and_return(response)
|
665
675
|
subject.update_server(42, :foo_bar => 'foo_bar')
|
666
676
|
end
|
667
677
|
|
668
678
|
it 'performs a PUT request to /servers/:id endpoint' do
|
669
|
-
|
679
|
+
expect(subject.http_client).to receive(:put).
|
670
680
|
with('servers/42', an_instance_of(String)).
|
671
681
|
and_return(response)
|
672
682
|
subject.update_server(42, :foo => 'bar')
|
673
683
|
end
|
674
684
|
|
675
685
|
it 'formats the keys of returned response' do
|
676
|
-
|
686
|
+
expect(subject.http_client).to receive(:put).and_return(response)
|
677
687
|
keys = subject.update_server(42, :foo => 'bar').keys
|
678
688
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
679
689
|
end
|
@@ -688,13 +698,13 @@ describe Postmark::AccountApiClient do
|
|
688
698
|
}
|
689
699
|
|
690
700
|
it 'performs a DELETE request to /servers/:id endpoint' do
|
691
|
-
|
701
|
+
expect(subject.http_client).to receive(:delete).
|
692
702
|
with('servers/42').and_return(response)
|
693
703
|
subject.delete_server(42)
|
694
704
|
end
|
695
705
|
|
696
706
|
it 'formats the keys of returned response' do
|
697
|
-
|
707
|
+
expect(subject.http_client).to receive(:delete).and_return(response)
|
698
708
|
keys = subject.delete_server(42).keys
|
699
709
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
700
710
|
end
|
@@ -711,7 +721,7 @@ describe Postmark::AccountApiClient do
|
|
711
721
|
let(:request_data) {{:source_server_id => 1, :destination_server_id => 2, :perform_changes => false}}
|
712
722
|
|
713
723
|
it 'gets templates info and converts it to ruby format' do
|
714
|
-
|
724
|
+
expect(subject.http_client).to receive(:put).and_return(response)
|
715
725
|
templates = subject.push_templates({:source_server_id => 1, :destination_server_id => 2, :perform_changes => false} )
|
716
726
|
|
717
727
|
expect(templates.size).to eq(2)
|
@@ -720,7 +730,7 @@ describe Postmark::AccountApiClient do
|
|
720
730
|
end
|
721
731
|
|
722
732
|
it 'formats the keys of returned response' do
|
723
|
-
|
733
|
+
expect(subject.http_client).to receive(:put).and_return(response)
|
724
734
|
templates = subject.push_templates({:source_server_id => 1, :destination_server_id => 2, :perform_changes => false} )
|
725
735
|
|
726
736
|
keys = templates.map { |template| template.keys }.flatten
|
@@ -737,13 +747,13 @@ describe Postmark::AccountApiClient do
|
|
737
747
|
}
|
738
748
|
|
739
749
|
it 'performs a GET request to /data-removals/:id endpoint' do
|
740
|
-
|
750
|
+
expect(subject.http_client).to receive(:get).
|
741
751
|
with('data-removals/42').and_return(response)
|
742
752
|
subject.get_data_removal_status(42)
|
743
753
|
end
|
744
754
|
|
745
755
|
it 'formats the keys of returned response' do
|
746
|
-
|
756
|
+
expect(subject.http_client).to receive(:get).and_return(response)
|
747
757
|
keys = subject.get_data_removal_status(42).keys
|
748
758
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
749
759
|
end
|
@@ -758,13 +768,13 @@ describe Postmark::AccountApiClient do
|
|
758
768
|
}
|
759
769
|
|
760
770
|
it 'performs a POST request to /data-removals endpoint' do
|
761
|
-
|
771
|
+
expect(subject.http_client).to receive(:post).
|
762
772
|
with('data-removals', an_instance_of(String)).and_return(response)
|
763
773
|
subject.request_data_removal(:foo => 'bar')
|
764
774
|
end
|
765
775
|
|
766
776
|
it 'formats the keys of returned response' do
|
767
|
-
|
777
|
+
expect(subject.http_client).to receive(:post).and_return(response)
|
768
778
|
keys = subject.request_data_removal(:foo => 'bar').keys
|
769
779
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
770
780
|
end
|
@@ -161,7 +161,7 @@ describe Postmark::ApiClient do
|
|
161
161
|
end
|
162
162
|
|
163
163
|
it "proxies errors" do
|
164
|
-
|
164
|
+
expect(http_client).to receive(:post).and_raise(Postmark::TimeoutError)
|
165
165
|
expect {subject}.to raise_error(Postmark::TimeoutError)
|
166
166
|
end
|
167
167
|
|
@@ -188,7 +188,7 @@ describe Postmark::ApiClient do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it "proxies errors" do
|
191
|
-
|
191
|
+
expect(http_client).to receive(:post).and_raise(Postmark::TimeoutError)
|
192
192
|
expect {subject}.to raise_error(Postmark::TimeoutError)
|
193
193
|
end
|
194
194
|
|
@@ -262,7 +262,7 @@ describe Postmark::ApiClient do
|
|
262
262
|
end
|
263
263
|
|
264
264
|
it 'loads outbound messages' do
|
265
|
-
|
265
|
+
expect(api_client.http_client).to receive(:get).
|
266
266
|
with('messages/outbound', an_instance_of(Hash)).and_return(response)
|
267
267
|
expect(api_client.messages.count).to eq(5)
|
268
268
|
end
|
@@ -276,7 +276,7 @@ describe Postmark::ApiClient do
|
|
276
276
|
end
|
277
277
|
|
278
278
|
it 'loads inbound messages' do
|
279
|
-
|
279
|
+
expect(api_client.http_client).to receive(:get).with('messages/inbound', an_instance_of(Hash)).and_return(response)
|
280
280
|
expect(api_client.messages(:inbound => true).count).to eq(5)
|
281
281
|
end
|
282
282
|
end
|
@@ -308,19 +308,22 @@ describe Postmark::ApiClient do
|
|
308
308
|
let(:response) {{'TotalCount' => 42}}
|
309
309
|
|
310
310
|
context 'given outbound' do
|
311
|
-
|
312
|
-
|
313
|
-
allow(api_client.http_client).to receive(:get).
|
311
|
+
it 'requests and returns outbound messages count by default' do
|
312
|
+
expect(api_client.http_client).to receive(:get).
|
314
313
|
with('messages/outbound', an_instance_of(Hash)).and_return(response)
|
315
314
|
expect(api_client.get_messages_count).to eq(42)
|
316
|
-
expect(api_client.get_messages_count(:inbound => false)).to eq(42)
|
317
315
|
end
|
318
316
|
|
317
|
+
it 'requests and returns outbound messages count when inbound => false' do
|
318
|
+
expect(api_client.http_client).to receive(:get).
|
319
|
+
with('messages/outbound', an_instance_of(Hash)).and_return(response)
|
320
|
+
expect(api_client.get_messages_count(:inbound => false)).to eq(42)
|
321
|
+
end
|
319
322
|
end
|
320
323
|
|
321
324
|
context 'given inbound' do
|
322
325
|
it 'requests and returns inbound messages count' do
|
323
|
-
|
326
|
+
expect(api_client.http_client).to receive(:get).
|
324
327
|
with('messages/inbound', an_instance_of(Hash)).and_return(response)
|
325
328
|
expect(api_client.get_messages_count(:inbound => true)).to eq(42)
|
326
329
|
end
|
@@ -382,7 +385,7 @@ describe Postmark::ApiClient do
|
|
382
385
|
end
|
383
386
|
|
384
387
|
it 'requests data at /bounces' do
|
385
|
-
|
388
|
+
expect(api_client.http_client).to receive(:get).
|
386
389
|
with('bounces', an_instance_of(Hash)).
|
387
390
|
and_return('TotalCount' => 1, 'Bounces' => [{}])
|
388
391
|
expect(api_client.bounces.first(5).count).to eq(1)
|
@@ -394,9 +397,10 @@ describe Postmark::ApiClient do
|
|
394
397
|
let(:response) {{"Bounces" => []}}
|
395
398
|
|
396
399
|
it 'requests data at /bounces' do
|
397
|
-
|
398
|
-
|
399
|
-
expect(
|
400
|
+
expect(http_client).to receive(:get).with("bounces", options) {response}
|
401
|
+
result = api_client.get_bounces(options)
|
402
|
+
expect(result).to be_an(Array)
|
403
|
+
expect(result.count).to be_zero
|
400
404
|
end
|
401
405
|
end
|
402
406
|
|
@@ -434,7 +438,7 @@ describe Postmark::ApiClient do
|
|
434
438
|
end
|
435
439
|
|
436
440
|
it 'performs a GET request to /opens/tags' do
|
437
|
-
|
441
|
+
expect(api_client.http_client).to receive(:get).
|
438
442
|
with('messages/outbound/opens', an_instance_of(Hash)).
|
439
443
|
and_return('TotalCount' => 1, 'Opens' => [{}])
|
440
444
|
expect(api_client.opens.first(5).count).to eq(1)
|
@@ -447,7 +451,7 @@ describe Postmark::ApiClient do
|
|
447
451
|
end
|
448
452
|
|
449
453
|
it 'performs a GET request to /clicks/tags' do
|
450
|
-
|
454
|
+
expect(api_client.http_client).to receive(:get).
|
451
455
|
with('messages/outbound/clicks', an_instance_of(Hash)).
|
452
456
|
and_return('TotalCount' => 1, 'Clicks' => [{}])
|
453
457
|
expect(api_client.clicks.first(5).count).to eq(1)
|
@@ -459,9 +463,10 @@ describe Postmark::ApiClient do
|
|
459
463
|
let(:response) {{'Opens' => [], 'TotalCount' => 0}}
|
460
464
|
|
461
465
|
it 'performs a GET request to /messages/outbound/opens' do
|
462
|
-
|
463
|
-
|
464
|
-
expect(
|
466
|
+
expect(http_client).to receive(:get).with('messages/outbound/opens', options) {response}
|
467
|
+
result = api_client.get_opens(options)
|
468
|
+
expect(result).to be_an(Array)
|
469
|
+
expect(result.count).to be_zero
|
465
470
|
end
|
466
471
|
end
|
467
472
|
|
@@ -470,9 +475,10 @@ describe Postmark::ApiClient do
|
|
470
475
|
let(:response) {{'Clicks' => [], 'TotalCount' => 0}}
|
471
476
|
|
472
477
|
it 'performs a GET request to /messages/outbound/clicks' do
|
473
|
-
|
474
|
-
|
475
|
-
expect(
|
478
|
+
expect(http_client).to receive(:get).with('messages/outbound/clicks', options) {response}
|
479
|
+
result = api_client.get_clicks(options)
|
480
|
+
expect(result).to be_an(Array)
|
481
|
+
expect(result.count).to be_zero
|
476
482
|
end
|
477
483
|
end
|
478
484
|
|
@@ -482,9 +488,10 @@ describe Postmark::ApiClient do
|
|
482
488
|
let(:response) {{'Opens' => [], 'TotalCount' => 0}}
|
483
489
|
|
484
490
|
it 'performs a GET request to /messages/outbound/opens' do
|
485
|
-
|
486
|
-
|
487
|
-
expect(
|
491
|
+
expect(http_client).to receive(:get).with("messages/outbound/opens/#{message_id}", options).and_return(response)
|
492
|
+
result = api_client.get_opens_by_message_id(message_id, options)
|
493
|
+
expect(result).to be_an(Array)
|
494
|
+
expect(result.count).to be_zero
|
488
495
|
end
|
489
496
|
end
|
490
497
|
|
@@ -494,9 +501,10 @@ describe Postmark::ApiClient do
|
|
494
501
|
let(:response) {{'Clicks' => [], 'TotalCount' => 0}}
|
495
502
|
|
496
503
|
it 'performs a GET request to /messages/outbound/clicks' do
|
497
|
-
|
498
|
-
|
499
|
-
expect(
|
504
|
+
expect(http_client).to receive(:get).with("messages/outbound/clicks/#{message_id}", options).and_return(response)
|
505
|
+
result = api_client.get_clicks_by_message_id(message_id, options)
|
506
|
+
expect(result).to be_an(Array)
|
507
|
+
expect(result.count).to be_zero
|
500
508
|
end
|
501
509
|
end
|
502
510
|
|
@@ -508,7 +516,7 @@ describe Postmark::ApiClient do
|
|
508
516
|
end
|
509
517
|
|
510
518
|
it 'performs a GET request to /opens/tags' do
|
511
|
-
|
519
|
+
expect(api_client.http_client).to receive(:get).
|
512
520
|
with("messages/outbound/opens/#{message_id}", an_instance_of(Hash)).
|
513
521
|
and_return('TotalCount' => 1, 'Opens' => [{}])
|
514
522
|
expect(api_client.opens_by_message_id(message_id).first(5).count).to eq(1)
|
@@ -523,7 +531,7 @@ describe Postmark::ApiClient do
|
|
523
531
|
end
|
524
532
|
|
525
533
|
it 'performs a GET request to /clicks/tags' do
|
526
|
-
|
534
|
+
expect(api_client.http_client).to receive(:get).
|
527
535
|
with("messages/outbound/clicks/#{message_id}", an_instance_of(Hash)).
|
528
536
|
and_return('TotalCount' => 1, 'Clicks' => [{}])
|
529
537
|
expect(api_client.clicks_by_message_id(message_id).first(5).count).to eq(1)
|
@@ -536,13 +544,13 @@ describe Postmark::ApiClient do
|
|
536
544
|
let(:response) {{'Rule' => 'example.com'}}
|
537
545
|
|
538
546
|
it 'performs a POST request to /triggers/inboundrules with given options' do
|
539
|
-
|
547
|
+
expect(http_client).to receive(:post).with('triggers/inboundrules',
|
540
548
|
{'Rule' => 'example.com'}.to_json)
|
541
549
|
api_client.create_trigger(:inbound_rules, options)
|
542
550
|
end
|
543
551
|
|
544
552
|
it 'symbolizes response keys' do
|
545
|
-
|
553
|
+
expect(http_client).to receive(:post).and_return(response)
|
546
554
|
expect(api_client.create_trigger(:inbound_rules, options)).to eq(:rule => 'example.com')
|
547
555
|
end
|
548
556
|
end
|
@@ -552,12 +560,12 @@ describe Postmark::ApiClient do
|
|
552
560
|
let(:id) {42}
|
553
561
|
|
554
562
|
it 'performs a GET request to /triggers/tags/:id' do
|
555
|
-
|
563
|
+
expect(http_client).to receive(:get).with("triggers/tags/#{id}")
|
556
564
|
api_client.get_trigger(:tags, id)
|
557
565
|
end
|
558
566
|
|
559
567
|
it 'symbolizes response keys' do
|
560
|
-
|
568
|
+
expect(http_client).to receive(:get).and_return('Foo' => 'Bar')
|
561
569
|
expect(api_client.get_trigger(:tags, id)).to eq(:foo => 'Bar')
|
562
570
|
end
|
563
571
|
end
|
@@ -567,12 +575,12 @@ describe Postmark::ApiClient do
|
|
567
575
|
let(:id) {42}
|
568
576
|
|
569
577
|
it 'performs a DELETE request to /triggers/tags/:id' do
|
570
|
-
|
578
|
+
expect(http_client).to receive(:delete).with("triggers/tags/#{id}")
|
571
579
|
api_client.delete_trigger(:tags, id)
|
572
580
|
end
|
573
581
|
|
574
582
|
it 'symbolizes response keys' do
|
575
|
-
|
583
|
+
expect(http_client).to receive(:delete).and_return('Foo' => 'Bar')
|
576
584
|
expect(api_client.delete_trigger(:tags, id)).to eq(:foo => 'Bar')
|
577
585
|
end
|
578
586
|
end
|
@@ -581,12 +589,12 @@ describe Postmark::ApiClient do
|
|
581
589
|
let(:id) {42}
|
582
590
|
|
583
591
|
it 'performs a DELETE request to /triggers/inboundrules/:id' do
|
584
|
-
|
592
|
+
expect(http_client).to receive(:delete).with("triggers/inboundrules/#{id}")
|
585
593
|
api_client.delete_trigger(:inbound_rules, id)
|
586
594
|
end
|
587
595
|
|
588
596
|
it 'symbolizes response keys' do
|
589
|
-
|
597
|
+
expect(http_client).to receive(:delete).and_return('Rule' => 'example.com')
|
590
598
|
expect(api_client.delete_trigger(:tags, id)).to eq(:rule => 'example.com')
|
591
599
|
end
|
592
600
|
end
|
@@ -599,9 +607,10 @@ describe Postmark::ApiClient do
|
|
599
607
|
let(:response) {{'InboundRules' => [], 'TotalCount' => 0}}
|
600
608
|
|
601
609
|
it 'performs a GET request to /triggers/inboundrules' do
|
602
|
-
|
603
|
-
|
604
|
-
expect(
|
610
|
+
expect(http_client).to receive(:get).with('triggers/inboundrules', options) {response}
|
611
|
+
result = api_client.get_triggers(:inbound_rules, options)
|
612
|
+
expect(result).to be_an(Array)
|
613
|
+
expect(result.count).to be_zero
|
605
614
|
end
|
606
615
|
end
|
607
616
|
end
|
@@ -612,7 +621,7 @@ describe Postmark::ApiClient do
|
|
612
621
|
end
|
613
622
|
|
614
623
|
it 'performs a GET request to /triggers/tags' do
|
615
|
-
|
624
|
+
expect(api_client.http_client).to receive(:get).
|
616
625
|
with('triggers/tags', an_instance_of(Hash)).
|
617
626
|
and_return('TotalCount' => 1, 'Tags' => [{}])
|
618
627
|
expect(api_client.triggers(:tags).first(5).count).to eq(1)
|
@@ -688,7 +697,7 @@ describe Postmark::ApiClient do
|
|
688
697
|
end
|
689
698
|
|
690
699
|
it 'requests data at /templates' do
|
691
|
-
|
700
|
+
expect(api_client.http_client).to receive(:get).
|
692
701
|
with('templates', an_instance_of(Hash)).
|
693
702
|
and_return('TotalCount' => 1, 'Templates' => [{}])
|
694
703
|
expect(api_client.templates.first(5).count).to eq(1)
|
@@ -1025,7 +1034,7 @@ describe Postmark::ApiClient do
|
|
1025
1034
|
subject(:result) { api_client.get_message_streams(:offset => 22, :count => 33) }
|
1026
1035
|
|
1027
1036
|
before do
|
1028
|
-
|
1037
|
+
expect(http_client).to receive(:get).
|
1029
1038
|
with('message-streams', :offset => 22, :count => 33).
|
1030
1039
|
and_return({ 'TotalCount' => 1, 'MessageStreams' => [{'Name' => 'abc'}]})
|
1031
1040
|
end
|
@@ -1045,7 +1054,7 @@ describe Postmark::ApiClient do
|
|
1045
1054
|
it { is_expected.to be_kind_of(Enumerable) }
|
1046
1055
|
|
1047
1056
|
it 'requests data at /message-streams' do
|
1048
|
-
|
1057
|
+
expect(http_client).to receive(:get).
|
1049
1058
|
with('message-streams', anything).
|
1050
1059
|
and_return('TotalCount' => 1, 'MessageStreams' => [{}])
|
1051
1060
|
expect(subject.first(5).count).to eq(1)
|
@@ -1056,7 +1065,7 @@ describe Postmark::ApiClient do
|
|
1056
1065
|
subject(:result) { api_client.get_message_stream(123) }
|
1057
1066
|
|
1058
1067
|
before do
|
1059
|
-
|
1068
|
+
expect(http_client).to receive(:get).
|
1060
1069
|
with('message-streams/123').
|
1061
1070
|
and_return({
|
1062
1071
|
'Id' => 'xxx',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.25.
|
4
|
+
version: 1.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomek Maszkowski
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: json
|
@@ -133,7 +133,8 @@ files:
|
|
133
133
|
homepage: https://postmarkapp.com
|
134
134
|
licenses:
|
135
135
|
- MIT
|
136
|
-
metadata:
|
136
|
+
metadata:
|
137
|
+
changelog_uri: https://github.com/ActiveCampaign/postmark-gem/blob/main/CHANGELOG.rdoc
|
137
138
|
post_install_message: "\n ==================\n Thanks for installing the postmark
|
138
139
|
gem. If you don't have an account, please\n sign up at https://postmarkapp.com/.\n\n
|
139
140
|
\ Review the README.md for implementation details and examples.\n ==================\n
|