mailgun-ruby 1.4.1 → 1.4.2
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/Gemfile +3 -1
- data/README.md +1 -1
- data/Rakefile +5 -3
- data/docs/AnalyticsTags.md +63 -0
- data/lib/mailgun/address.rb +5 -5
- data/lib/mailgun/chains.rb +2 -3
- data/lib/mailgun/client.rb +47 -51
- data/lib/mailgun/domains/domains.rb +7 -8
- data/lib/mailgun/events/events.rb +4 -3
- data/lib/mailgun/exceptions/exceptions.rb +12 -15
- data/lib/mailgun/helpers/api_version_checker.rb +6 -1
- data/lib/mailgun/lists/opt_in_handler.rb +4 -6
- data/lib/mailgun/logs/logs.rb +4 -2
- data/lib/mailgun/messages/batch_message.rb +8 -9
- data/lib/mailgun/messages/message_builder.rb +36 -24
- data/lib/mailgun/metrics/metrics.rb +6 -4
- data/lib/mailgun/response.rb +11 -9
- data/lib/mailgun/subaccounts/subaccounts.rb +13 -8
- data/lib/mailgun/suppressions.rb +36 -43
- data/lib/mailgun/tags/analytics_tags.rb +33 -2
- data/lib/mailgun/tags/tags.rb +25 -17
- data/lib/mailgun/templates/templates.rb +40 -29
- data/lib/mailgun/version.rb +3 -1
- data/lib/mailgun/webhooks/webhooks.rb +22 -19
- data/lib/mailgun-ruby.rb +2 -0
- data/lib/mailgun.rb +4 -4
- data/lib/railgun/attachment.rb +9 -14
- data/lib/railgun/errors.rb +2 -3
- data/lib/railgun/mailer.rb +35 -39
- data/lib/railgun/railtie.rb +2 -0
- data/lib/railgun.rb +2 -0
- data/mailgun.gemspec +12 -11
- data/spec/integration/analytics_tags_spec.rb +54 -0
- data/spec/integration/bounces_spec.rb +12 -11
- data/spec/integration/campaign_spec.rb +20 -18
- data/spec/integration/complaints_spec.rb +8 -6
- data/spec/integration/domains_spec.rb +6 -6
- data/spec/integration/email_validation_spec.rb +35 -34
- data/spec/integration/events_spec.rb +7 -5
- data/spec/integration/list_members_spec.rb +27 -26
- data/spec/integration/list_spec.rb +22 -21
- data/spec/integration/logs_spec.rb +48 -46
- data/spec/integration/mailer_spec.rb +7 -3
- data/spec/integration/mailgun_spec.rb +82 -90
- data/spec/integration/metrics_spec.rb +130 -130
- data/spec/integration/routes_spec.rb +41 -40
- data/spec/integration/stats_spec.rb +4 -2
- data/spec/integration/subaccounts_spec.rb +9 -10
- data/spec/integration/suppressions_spec.rb +21 -20
- data/spec/integration/templates_spec.rb +14 -12
- data/spec/integration/unsubscribes_spec.rb +8 -6
- data/spec/integration/webhook_spec.rb +13 -12
- data/spec/spec_helper.rb +8 -8
- data/spec/unit/connection/test_client.rb +61 -55
- data/spec/unit/events/events_spec.rb +25 -22
- data/spec/unit/exceptions/exceptions_spec.rb +8 -7
- data/spec/unit/lists/opt_in_handler_spec.rb +8 -6
- data/spec/unit/mailgun_spec.rb +64 -63
- data/spec/unit/messages/batch_message_spec.rb +15 -15
- data/spec/unit/messages/message_builder_spec.rb +98 -94
- data/spec/unit/railgun/content_type_spec.rb +24 -23
- data/spec/unit/railgun/mailer_spec.rb +58 -58
- data/vcr_cassettes/analytics_tags.yml +187 -0
- metadata +49 -33
- data/.rubocop.yml +0 -8
- data/.rubocop_todo.yml +0 -22
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
require 'mailgun'
|
|
3
5
|
|
|
@@ -10,11 +12,11 @@ describe Mailgun::Metrics, vcr: vcr_opts do
|
|
|
10
12
|
let(:options) do
|
|
11
13
|
{
|
|
12
14
|
resolution: 'hour',
|
|
13
|
-
metrics: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
metrics: %w[
|
|
16
|
+
accepted_count
|
|
17
|
+
delivered_count
|
|
18
|
+
clicked_rate
|
|
19
|
+
opened_rate
|
|
18
20
|
],
|
|
19
21
|
include_aggregates: true,
|
|
20
22
|
start: 'Tue, 26 Nov 2024 20:56:50 -0500',
|
|
@@ -42,48 +44,47 @@ describe Mailgun::Metrics, vcr: vcr_opts do
|
|
|
42
44
|
it 'responds with account metrics' do
|
|
43
45
|
expect(metrics.account_metrics(options)).to eq(
|
|
44
46
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
'start' => 'Fri, 01 Nov 2024 01:00:00 +0000',
|
|
48
|
+
'end' => 'Sun, 01 Dec 2024 01:00:00 +0000',
|
|
49
|
+
'resolution' => 'hour',
|
|
50
|
+
'duration' => '1m',
|
|
51
|
+
'dimensions' => ['time'],
|
|
52
|
+
'pagination' => {
|
|
53
|
+
'sort' => '', 'skip' => 0, 'limit' => 1500, 'total' => 3
|
|
52
54
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"dimensions" => [{
|
|
65
|
-
"dimension" => "time",
|
|
66
|
-
"value" => "Wed, 27 Nov 2024 13:00:00 +0000",
|
|
67
|
-
"display_value" => "Wed, 27 Nov 2024 13:00:00 +0000"
|
|
68
|
-
}],
|
|
69
|
-
"metrics" => {
|
|
70
|
-
"accepted_count" => 1, "delivered_count" => 1, "opened_rate" => "0.0000", "clicked_rate" => "0.0000"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"dimensions" => [{
|
|
75
|
-
"dimension" => "time",
|
|
76
|
-
"value" => "Thu, 28 Nov 2024 15:00:00 +0000",
|
|
77
|
-
"display_value" => "Thu, 28 Nov 2024 15:00:00 +0000"
|
|
78
|
-
}],
|
|
79
|
-
"metrics" => {
|
|
80
|
-
"accepted_count" => 1, "delivered_count" => 1, "opened_rate" => "0.0000", "clicked_rate" => "0.0000"
|
|
81
|
-
}
|
|
55
|
+
'items' => [{
|
|
56
|
+
'dimensions' => [{
|
|
57
|
+
'dimension' => 'time',
|
|
58
|
+
'value' => 'Wed, 27 Nov 2024 12:00:00 +0000',
|
|
59
|
+
'display_value' => 'Wed, 27 Nov 2024 12:00:00 +0000'
|
|
60
|
+
}],
|
|
61
|
+
'metrics' => {
|
|
62
|
+
'accepted_count' => 1, 'delivered_count' => 1, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
|
|
82
63
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
'dimensions' => [{
|
|
67
|
+
'dimension' => 'time',
|
|
68
|
+
'value' => 'Wed, 27 Nov 2024 13:00:00 +0000',
|
|
69
|
+
'display_value' => 'Wed, 27 Nov 2024 13:00:00 +0000'
|
|
70
|
+
}],
|
|
71
|
+
'metrics' => {
|
|
72
|
+
'accepted_count' => 1, 'delivered_count' => 1, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
'dimensions' => [{
|
|
77
|
+
'dimension' => 'time',
|
|
78
|
+
'value' => 'Thu, 28 Nov 2024 15:00:00 +0000',
|
|
79
|
+
'display_value' => 'Thu, 28 Nov 2024 15:00:00 +0000'
|
|
80
|
+
}],
|
|
81
|
+
'metrics' => {
|
|
82
|
+
'accepted_count' => 1, 'delivered_count' => 1, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
|
|
83
|
+
}
|
|
84
|
+
}],
|
|
85
|
+
'aggregates' => {
|
|
86
|
+
'metrics' => {
|
|
87
|
+
'accepted_count' => 3, 'delivered_count' => 3, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
@@ -95,21 +96,21 @@ describe Mailgun::Metrics, vcr: vcr_opts do
|
|
|
95
96
|
let(:options) do
|
|
96
97
|
{
|
|
97
98
|
resolution: 'hour',
|
|
98
|
-
metrics: [
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
99
|
+
metrics: %w[
|
|
100
|
+
email_preview_count
|
|
101
|
+
email_preview_failed_count
|
|
102
|
+
email_validation_bulk_count
|
|
103
|
+
email_validation_count
|
|
104
|
+
email_validation_list_count
|
|
105
|
+
email_validation_mailgun_count
|
|
106
|
+
email_validation_mailjet_count
|
|
107
|
+
email_validation_public_count
|
|
108
|
+
email_validation_single_count
|
|
109
|
+
email_validation_valid_count
|
|
110
|
+
link_validation_count
|
|
111
|
+
link_validation_failed_count
|
|
112
|
+
processed_count
|
|
113
|
+
seed_test_count
|
|
113
114
|
],
|
|
114
115
|
include_aggregates: true,
|
|
115
116
|
start: 'Tue, 26 Nov 2024 20:56:50 -0500',
|
|
@@ -137,78 +138,77 @@ describe Mailgun::Metrics, vcr: vcr_opts do
|
|
|
137
138
|
it 'responds with account usage metrics' do
|
|
138
139
|
expect(metrics.account_usage_metrics(options)).to eq(
|
|
139
140
|
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
'start' => 'Tue, 29 Oct 2024 01:00:00 +0000',
|
|
142
|
+
'end' => 'Fri, 29 Nov 2024 01:00:00 +0000',
|
|
143
|
+
'resolution' => 'hour',
|
|
144
|
+
'duration' => '1m',
|
|
145
|
+
'dimensions' => ['time'],
|
|
146
|
+
'pagination' => {
|
|
147
|
+
'sort' => '', 'skip' => 0, 'limit' => 1500, 'total' => 2
|
|
147
148
|
},
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"dimensions" => [{
|
|
173
|
-
"dimension" => "time",
|
|
174
|
-
"value" => "Thu, 28 Nov 2024 00:00:00 +0000",
|
|
175
|
-
"display_value" => "Thu, 28 Nov 2024 00:00:00 +0000"
|
|
176
|
-
}],
|
|
177
|
-
"metrics" => {
|
|
178
|
-
"processed_count" => 1,
|
|
179
|
-
"email_validation_count" => 0,
|
|
180
|
-
"email_validation_public_count" => 0,
|
|
181
|
-
"email_validation_valid_count" => 0,
|
|
182
|
-
"email_validation_single_count" => 0,
|
|
183
|
-
"email_validation_bulk_count" => 0,
|
|
184
|
-
"email_validation_list_count" => 0,
|
|
185
|
-
"email_validation_mailgun_count" => 0,
|
|
186
|
-
"email_validation_mailjet_count" => 0,
|
|
187
|
-
"email_preview_count" => 0,
|
|
188
|
-
"email_preview_failed_count" => 0,
|
|
189
|
-
"link_validation_count" => 0,
|
|
190
|
-
"link_validation_failed_count" => 0,
|
|
191
|
-
"seed_test_count" => 0
|
|
192
|
-
}
|
|
149
|
+
'items' => [{
|
|
150
|
+
'dimensions' => [{
|
|
151
|
+
'dimension' => 'time',
|
|
152
|
+
'value' => 'Wed, 27 Nov 2024 00:00:00 +0000',
|
|
153
|
+
'display_value' => 'Wed, 27 Nov 2024 00:00:00 +0000'
|
|
154
|
+
}],
|
|
155
|
+
'metrics' => {
|
|
156
|
+
'processed_count' => 2,
|
|
157
|
+
'email_validation_count' => 0,
|
|
158
|
+
'email_validation_public_count' => 0,
|
|
159
|
+
'email_validation_valid_count' => 0,
|
|
160
|
+
'email_validation_single_count' => 0,
|
|
161
|
+
'email_validation_bulk_count' => 0,
|
|
162
|
+
'email_validation_list_count' => 0,
|
|
163
|
+
'email_validation_mailgun_count' => 0,
|
|
164
|
+
'email_validation_mailjet_count' => 0,
|
|
165
|
+
'email_preview_count' => 0,
|
|
166
|
+
'email_preview_failed_count' => 0,
|
|
167
|
+
'link_validation_count' => 0,
|
|
168
|
+
'link_validation_failed_count' => 0,
|
|
169
|
+
'seed_test_count' => 0
|
|
193
170
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
'dimensions' => [{
|
|
174
|
+
'dimension' => 'time',
|
|
175
|
+
'value' => 'Thu, 28 Nov 2024 00:00:00 +0000',
|
|
176
|
+
'display_value' => 'Thu, 28 Nov 2024 00:00:00 +0000'
|
|
177
|
+
}],
|
|
178
|
+
'metrics' => {
|
|
179
|
+
'processed_count' => 1,
|
|
180
|
+
'email_validation_count' => 0,
|
|
181
|
+
'email_validation_public_count' => 0,
|
|
182
|
+
'email_validation_valid_count' => 0,
|
|
183
|
+
'email_validation_single_count' => 0,
|
|
184
|
+
'email_validation_bulk_count' => 0,
|
|
185
|
+
'email_validation_list_count' => 0,
|
|
186
|
+
'email_validation_mailgun_count' => 0,
|
|
187
|
+
'email_validation_mailjet_count' => 0,
|
|
188
|
+
'email_preview_count' => 0,
|
|
189
|
+
'email_preview_failed_count' => 0,
|
|
190
|
+
'link_validation_count' => 0,
|
|
191
|
+
'link_validation_failed_count' => 0,
|
|
192
|
+
'seed_test_count' => 0
|
|
193
|
+
}
|
|
194
|
+
}],
|
|
195
|
+
'aggregates' => {
|
|
196
|
+
'metrics' => {
|
|
197
|
+
'permanent_failed_count' => 0,
|
|
198
|
+
'processed_count' => 3,
|
|
199
|
+
'email_validation_count' => 0,
|
|
200
|
+
'email_validation_public_count' => 0,
|
|
201
|
+
'email_validation_valid_count' => 0,
|
|
202
|
+
'email_validation_single_count' => 0,
|
|
203
|
+
'email_validation_bulk_count' => 0,
|
|
204
|
+
'email_validation_list_count' => 0,
|
|
205
|
+
'email_validation_mailgun_count' => 0,
|
|
206
|
+
'email_validation_mailjet_count' => 0,
|
|
207
|
+
'email_preview_count' => 0,
|
|
208
|
+
'email_preview_failed_count' => 0,
|
|
209
|
+
'link_validation_count' => 0,
|
|
210
|
+
'link_validation_failed_count' => 0,
|
|
211
|
+
'seed_test_count' => 0
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
require 'mailgun'
|
|
3
5
|
|
|
4
|
-
vcr_opts = { :
|
|
6
|
+
vcr_opts = { cassette_name: 'routes', match_requests_on: %i[uri method body] }
|
|
5
7
|
|
|
6
8
|
describe 'For the Routes endpoint', order: :defined, vcr: vcr_opts do
|
|
7
9
|
before(:all) do
|
|
@@ -12,79 +14,78 @@ describe 'For the Routes endpoint', order: :defined, vcr: vcr_opts do
|
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
it 'creates a route' do
|
|
15
|
-
result = @mg_obj.post(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
result = @mg_obj.post('routes', { priority: 10,
|
|
18
|
+
description: 'Integration Test Route',
|
|
19
|
+
expression: "match_recipient(\"#{@forward_to}\")",
|
|
20
|
+
action: "forward(\"#{@recipient}\")" })
|
|
19
21
|
|
|
20
22
|
result.to_h!
|
|
21
|
-
expect(result.body[
|
|
22
|
-
expect(result.body[
|
|
23
|
-
expect(result.body[
|
|
24
|
-
expect(result.body[
|
|
25
|
-
expect(result.body[
|
|
23
|
+
expect(result.body['message']).to eq('Route has been created')
|
|
24
|
+
expect(result.body['route']['description']).to eq('Integration Test Route')
|
|
25
|
+
expect(result.body['route']['actions']).to include("forward(\"#{@recipient}\")")
|
|
26
|
+
expect(result.body['route']['expression']).to include("match_recipient(\"#{@forward_to}\")")
|
|
27
|
+
expect(result.body['route']['priority']).to eq(10)
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
it 'creates a route with multiple actions' do
|
|
29
|
-
result = @mg_obj.post(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
result = @mg_obj.post('routes', { priority: 10,
|
|
32
|
+
description: 'Integration Test Route',
|
|
33
|
+
expression: "match_recipient(\"#{@forward_to}\")",
|
|
34
|
+
action: ["forward(\"#{@recipient}\")", 'stop()'] })
|
|
33
35
|
|
|
34
36
|
result.to_h!
|
|
35
|
-
expect(result.body[
|
|
36
|
-
expect(result.body[
|
|
37
|
-
expect(result.body[
|
|
38
|
-
expect(result.body[
|
|
39
|
-
expect(result.body[
|
|
40
|
-
expect(result.body[
|
|
41
|
-
expect(result.body[
|
|
37
|
+
expect(result.body['message']).to eq('Route has been created')
|
|
38
|
+
expect(result.body['route']['description']).to eq('Integration Test Route')
|
|
39
|
+
expect(result.body['route']['actions'].count).to eq 2
|
|
40
|
+
expect(result.body['route']['actions'][0]).to include("forward(\"#{@recipient}\")")
|
|
41
|
+
expect(result.body['route']['actions'][1]).to include('stop()')
|
|
42
|
+
expect(result.body['route']['expression']).to include("match_recipient(\"#{@forward_to}\")")
|
|
43
|
+
expect(result.body['route']['priority']).to eq(10)
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
it 'gets a list of all routes.' do
|
|
45
|
-
result = @mg_obj.get(
|
|
47
|
+
result = @mg_obj.get('routes', { limit: 50 })
|
|
46
48
|
|
|
47
49
|
result.to_h!
|
|
48
|
-
expect(result.body[
|
|
50
|
+
expect(result.body['total_count']).to be > 0
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
it 'gets the route.' do
|
|
52
|
-
result = @mg_obj.get(
|
|
54
|
+
result = @mg_obj.get('routes', { limit: 1 })
|
|
53
55
|
route_id = result.to_h['items'].first['id']
|
|
54
56
|
|
|
55
57
|
result = @mg_obj.get("routes/#{route_id}")
|
|
56
58
|
|
|
57
59
|
result.to_h!
|
|
58
|
-
expect(result.body[
|
|
59
|
-
expect(result.body[
|
|
60
|
-
expect(result.body[
|
|
61
|
-
expect(result.body[
|
|
60
|
+
expect(result.body['route']['description']).to eq('Integration Test Route')
|
|
61
|
+
expect(result.body['route']['actions']).to include("forward(\"#{@recipient}\")")
|
|
62
|
+
expect(result.body['route']['expression']).to include("match_recipient(\"#{@forward_to}\")")
|
|
63
|
+
expect(result.body['route']['priority']).to eq(10)
|
|
62
64
|
end
|
|
63
65
|
|
|
64
66
|
it 'updates the route.' do
|
|
65
|
-
result = @mg_obj.get(
|
|
67
|
+
result = @mg_obj.get('routes', { limit: 1 })
|
|
66
68
|
route_id = result.to_h['items'].first['id']
|
|
67
69
|
|
|
68
|
-
result = @mg_obj.put("routes/#{route_id}",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
result = @mg_obj.put("routes/#{route_id}", { priority: 10,
|
|
71
|
+
description: 'Integration Test Route Update',
|
|
72
|
+
expression: "match_recipient(\"#{@forward_to}\")",
|
|
73
|
+
action: "forward(\"#{@recipient}\")" })
|
|
72
74
|
|
|
73
75
|
result.to_h!
|
|
74
|
-
expect(result.body[
|
|
75
|
-
expect(result.body[
|
|
76
|
-
expect(result.body[
|
|
77
|
-
expect(result.body[
|
|
78
|
-
expect(result.body[
|
|
76
|
+
expect(result.body['message']).to eq('Route has been updated')
|
|
77
|
+
expect(result.body['description']).to eq('Integration Test Route Update')
|
|
78
|
+
expect(result.body['actions']).to include("forward(\"#{@recipient}\")")
|
|
79
|
+
expect(result.body['expression']).to include("match_recipient(\"#{@forward_to}\")")
|
|
80
|
+
expect(result.body['priority']).to eq(10)
|
|
79
81
|
end
|
|
80
82
|
|
|
81
83
|
it 'removes a route' do
|
|
82
|
-
result = @mg_obj.get(
|
|
84
|
+
result = @mg_obj.get('routes', { limit: 1 })
|
|
83
85
|
route_id = result.to_h['items'].first['id']
|
|
84
86
|
|
|
85
87
|
@mg_obj.delete("routes/#{route_id}")
|
|
86
88
|
|
|
87
89
|
result.to_h!
|
|
88
90
|
end
|
|
89
|
-
|
|
90
91
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
require 'mailgun'
|
|
3
5
|
|
|
4
|
-
vcr_opts = { :
|
|
6
|
+
vcr_opts = { cassette_name: 'stats' }
|
|
5
7
|
|
|
6
8
|
describe 'For the Stats endpoint', vcr: vcr_opts do
|
|
7
9
|
before(:all) do
|
|
@@ -10,6 +12,6 @@ describe 'For the Stats endpoint', vcr: vcr_opts do
|
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it 'get some stats.' do
|
|
13
|
-
@mg_obj.get("#{@domain}/stats", {:
|
|
15
|
+
@mg_obj.get("#{@domain}/stats", { limit: 50, skip: 10, event: 'sent' })
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
require 'mailgun'
|
|
3
5
|
|
|
4
|
-
vcr_opts = { :
|
|
6
|
+
vcr_opts = { cassette_name: 'subaccounts' }
|
|
5
7
|
|
|
6
8
|
describe 'For the subaccounts endpoints', vcr: vcr_opts do
|
|
7
9
|
let(:name) { 'test.subaccount' }
|
|
@@ -16,7 +18,8 @@ describe 'For the subaccounts endpoints', vcr: vcr_opts do
|
|
|
16
18
|
it 'returns a list of templates' do
|
|
17
19
|
result = @mg_obj.list
|
|
18
20
|
|
|
19
|
-
expect(result).to eq({
|
|
21
|
+
expect(result).to eq({ 'subaccounts' => [{ 'id' => 'xxx', 'name' => 'test-ruby-lib', 'status' => 'open' }],
|
|
22
|
+
'total' => 1 })
|
|
20
23
|
end
|
|
21
24
|
end
|
|
22
25
|
|
|
@@ -24,26 +27,23 @@ describe 'For the subaccounts endpoints', vcr: vcr_opts do
|
|
|
24
27
|
it 'creates the subaccount' do
|
|
25
28
|
result = @mg_obj.create(name)
|
|
26
29
|
|
|
27
|
-
expect(result).to eq({
|
|
30
|
+
expect(result).to eq({ 'subaccount' => { 'id' => 'xxx', 'name' => 'test.subaccount', 'status' => 'open' } })
|
|
28
31
|
end
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
|
|
32
34
|
describe '#info' do
|
|
33
35
|
it 'gets the templates info' do
|
|
34
36
|
result = @mg_obj.info(subaccount_id)
|
|
35
37
|
|
|
36
|
-
expect(result).to eq({
|
|
38
|
+
expect(result).to eq({ 'subaccount' => { 'id' => 'xxx', 'name' => 'test-ruby-lib', 'status' => 'open' } })
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
42
|
describe '#enable' do
|
|
43
43
|
it 'enables the subaccount' do
|
|
44
44
|
result = @mg_obj.enable(subaccount_id)
|
|
45
45
|
|
|
46
|
-
expect(result).to eq({
|
|
46
|
+
expect(result).to eq({ 'subaccount' => { 'id' => 'xxx', 'name' => 'test-ruby-lib', 'status' => 'open' } })
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
@@ -51,8 +51,7 @@ describe 'For the subaccounts endpoints', vcr: vcr_opts do
|
|
|
51
51
|
it 'disables the subaccount' do
|
|
52
52
|
result = @mg_obj.disable(subaccount_id)
|
|
53
53
|
|
|
54
|
-
expect(result).to eq({
|
|
54
|
+
expect(result).to eq({ 'subaccount' => { 'id' => 'xxx', 'name' => 'test-ruby-lib', 'status' => 'disabled' } })
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
|
-
|
|
58
57
|
end
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
require 'mailgun'
|
|
4
6
|
require 'mailgun/suppressions'
|
|
5
7
|
|
|
6
|
-
vcr_opts = { :
|
|
8
|
+
vcr_opts = { cassette_name: 'suppressions' }
|
|
7
9
|
|
|
8
10
|
describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts do
|
|
9
|
-
|
|
10
11
|
before(:all) do
|
|
11
12
|
@mg_obj = Mailgun::Client.new(APIKEY)
|
|
12
13
|
@suppress = Mailgun::Suppressions.new(@mg_obj, TESTDOMAIN)
|
|
@@ -18,10 +19,10 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
18
19
|
bounces = []
|
|
19
20
|
@addresses.each do |addr|
|
|
20
21
|
bounces.push({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
address: addr,
|
|
23
|
+
code: 500,
|
|
24
|
+
error: 'integration testing'
|
|
25
|
+
})
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
response, nested = @suppress.create_bounces bounces
|
|
@@ -35,9 +36,9 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
35
36
|
it 'raises ParameterError if no bounce[:address] is present' do
|
|
36
37
|
bounces = []
|
|
37
38
|
bounces.push({
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
code: 500,
|
|
40
|
+
error: 'integration testing'
|
|
41
|
+
})
|
|
41
42
|
|
|
42
43
|
expect { @suppress.create_bounces bounces }.to raise_error(Mailgun::ParameterError)
|
|
43
44
|
end
|
|
@@ -56,9 +57,9 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
56
57
|
unsubscribes = []
|
|
57
58
|
@addresses.each do |addr|
|
|
58
59
|
unsubscribes.push({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
address: addr,
|
|
61
|
+
tag: 'integration'
|
|
62
|
+
})
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
response, nested = @suppress.create_unsubscribes unsubscribes
|
|
@@ -73,9 +74,9 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
73
74
|
unsubscribes = []
|
|
74
75
|
@addresses.each do |addr|
|
|
75
76
|
unsubscribes.push({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
address: addr,
|
|
78
|
+
tags: ['integration']
|
|
79
|
+
})
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
response, nested = @suppress.create_unsubscribes unsubscribes
|
|
@@ -89,8 +90,8 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
89
90
|
it 'raises ParameterError if no unsubscribe[:address] is present' do
|
|
90
91
|
unsubscribes = []
|
|
91
92
|
unsubscribes.push({
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
tag: 'integration'
|
|
94
|
+
})
|
|
94
95
|
|
|
95
96
|
expect { @suppress.create_unsubscribes unsubscribes }.to raise_error(Mailgun::ParameterError)
|
|
96
97
|
end
|
|
@@ -108,7 +109,7 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
108
109
|
it 'can batch-add complaints' do
|
|
109
110
|
complaints = []
|
|
110
111
|
@addresses.each do |addr|
|
|
111
|
-
complaints.push :
|
|
112
|
+
complaints.push address: addr
|
|
112
113
|
end
|
|
113
114
|
|
|
114
115
|
response, nested = @suppress.create_complaints complaints
|
|
@@ -122,8 +123,8 @@ describe 'For the suppressions handling class', order: :defined, vcr: vcr_opts d
|
|
|
122
123
|
it 'raises ParameterError if no complaint[:address] is present' do
|
|
123
124
|
complaints = []
|
|
124
125
|
complaints.push({
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
tag: 'integration'
|
|
127
|
+
})
|
|
127
128
|
|
|
128
129
|
expect { @suppress.create_complaints complaints }.to raise_error(Mailgun::ParameterError)
|
|
129
130
|
end
|