mailgun-ruby 1.4.5 → 1.4.6

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.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/README.md +3 -1
  4. data/lib/mailgun/api_keys/api_keys.rb +2 -2
  5. data/lib/mailgun/client.rb +1 -1
  6. data/lib/mailgun/domains/domain_keys.rb +5 -5
  7. data/lib/mailgun/domains/domains.rb +12 -9
  8. data/lib/mailgun/events/events.rb +1 -1
  9. data/lib/mailgun/helpers/api_version_checker.rb +23 -12
  10. data/lib/mailgun/helpers/deprecation.rb +32 -0
  11. data/lib/mailgun/lists/mailing_lists.rb +250 -0
  12. data/lib/mailgun/messages/message_builder.rb +17 -7
  13. data/lib/mailgun/response.rb +1 -1
  14. data/lib/mailgun/routes/routes.rb +98 -0
  15. data/lib/mailgun/tags/analytics_tags.rb +2 -2
  16. data/lib/mailgun/tags/tags.rb +16 -8
  17. data/lib/mailgun/version.rb +1 -1
  18. data/lib/mailgun/webhooks/account_webhooks.rb +2 -2
  19. data/lib/mailgun/webhooks/webhooks.rb +17 -9
  20. data/lib/mailgun.rb +1 -0
  21. metadata +6 -326
  22. data/.github/workflows/ci.yml +0 -49
  23. data/.github_changelog_generator +0 -1
  24. data/.gitignore +0 -24
  25. data/.rubocop.yml +0 -68
  26. data/.ruby-env.yml.example +0 -13
  27. data/Gemfile +0 -9
  28. data/Rakefile +0 -32
  29. data/docs/AccountWebhooks.md +0 -55
  30. data/docs/AnalyticsTags.md +0 -63
  31. data/docs/ApiKeys.md +0 -65
  32. data/docs/DomainKeys.md +0 -49
  33. data/docs/Domains.md +0 -82
  34. data/docs/EmailValidation.md +0 -34
  35. data/docs/Events.md +0 -48
  36. data/docs/Logs.md +0 -67
  37. data/docs/MessageBuilder.md +0 -120
  38. data/docs/Metrics.md +0 -108
  39. data/docs/OptInHandler.md +0 -103
  40. data/docs/Snippets.md +0 -519
  41. data/docs/Subaccounts.md +0 -68
  42. data/docs/Suppressions.md +0 -92
  43. data/docs/Templates.md +0 -92
  44. data/docs/Webhooks.md +0 -65
  45. data/docs/railgun/EmailValidation.md +0 -34
  46. data/docs/railgun/Overview.md +0 -11
  47. data/docs/railgun/Parameters.md +0 -83
  48. data/mailgun.gemspec +0 -47
  49. data/spec/integration/account_webhooks_spec.rb +0 -57
  50. data/spec/integration/analytics_tags_spec.rb +0 -54
  51. data/spec/integration/api_keys_spec.rb +0 -50
  52. data/spec/integration/bounces_spec.rb +0 -45
  53. data/spec/integration/campaign_spec.rb +0 -62
  54. data/spec/integration/complaints_spec.rb +0 -40
  55. data/spec/integration/domain_keys_spec.rb +0 -124
  56. data/spec/integration/domains_spec.rb +0 -201
  57. data/spec/integration/email_validation_spec.rb +0 -73
  58. data/spec/integration/events_spec.rb +0 -28
  59. data/spec/integration/list_members_spec.rb +0 -64
  60. data/spec/integration/list_spec.rb +0 -59
  61. data/spec/integration/logs_spec.rb +0 -105
  62. data/spec/integration/mailer_spec.rb +0 -65
  63. data/spec/integration/mailgun_spec.rb +0 -198
  64. data/spec/integration/messages/sample_data/mime.txt +0 -38
  65. data/spec/integration/metrics_spec.rb +0 -224
  66. data/spec/integration/routes_spec.rb +0 -91
  67. data/spec/integration/stats_spec.rb +0 -17
  68. data/spec/integration/subaccounts_spec.rb +0 -57
  69. data/spec/integration/suppressions_spec.rb +0 -320
  70. data/spec/integration/templates_spec.rb +0 -137
  71. data/spec/integration/unsubscribes_spec.rb +0 -44
  72. data/spec/integration/webhook_spec.rb +0 -79
  73. data/spec/spec_helper.rb +0 -53
  74. data/spec/unit/client_spec.rb +0 -448
  75. data/spec/unit/connection/test_client.rb +0 -169
  76. data/spec/unit/events/events_spec.rb +0 -88
  77. data/spec/unit/exceptions/exceptions_spec.rb +0 -31
  78. data/spec/unit/helpers/api_version_checker_spec.rb +0 -206
  79. data/spec/unit/lists/opt_in_handler_spec.rb +0 -28
  80. data/spec/unit/mailgun_spec.rb +0 -171
  81. data/spec/unit/messages/batch_message_spec.rb +0 -148
  82. data/spec/unit/messages/message_builder_spec.rb +0 -745
  83. data/spec/unit/messages/sample_data/mailgun_icon.png +0 -0
  84. data/spec/unit/messages/sample_data/mime.txt +0 -38
  85. data/spec/unit/messages/sample_data/rackspace_logo.jpg +0 -0
  86. data/spec/unit/messages/sample_data/unknown.type +0 -0
  87. data/spec/unit/railgun/content_type_spec.rb +0 -89
  88. data/spec/unit/railgun/mailer_spec.rb +0 -391
  89. data/spec/unit/response_spec.rb +0 -225
  90. data/spec/unit/webhooks_spec.rb +0 -121
  91. data/vcr_cassettes/For_the_suppressions_handling_class/creates_a_single_bounce.yml +0 -55
  92. data/vcr_cassettes/account_webhooks.yml +0 -269
  93. data/vcr_cassettes/analytics_tags.yml +0 -187
  94. data/vcr_cassettes/api_keys.yml +0 -212
  95. data/vcr_cassettes/bounces.yml +0 -136
  96. data/vcr_cassettes/complaints.yml +0 -315
  97. data/vcr_cassettes/domains.todo.yml +0 -42
  98. data/vcr_cassettes/domains.yml +0 -1243
  99. data/vcr_cassettes/email_validation.yml +0 -152
  100. data/vcr_cassettes/events.yml +0 -69
  101. data/vcr_cassettes/exceptions-invalid-api-key.yml +0 -52
  102. data/vcr_cassettes/exceptions-invalid-data.yml +0 -52
  103. data/vcr_cassettes/exceptions-not-allowed.yml +0 -54
  104. data/vcr_cassettes/exceptions.yml +0 -92
  105. data/vcr_cassettes/list_members.yml +0 -328
  106. data/vcr_cassettes/logs.yml +0 -53
  107. data/vcr_cassettes/mailer_invalid_domain.yml +0 -109
  108. data/vcr_cassettes/mailing_list.todo.yml +0 -43
  109. data/vcr_cassettes/mailing_list.yml +0 -682
  110. data/vcr_cassettes/message_deliver.yml +0 -149
  111. data/vcr_cassettes/metrics.yml +0 -116
  112. data/vcr_cassettes/routes.yml +0 -359
  113. data/vcr_cassettes/send_message.yml +0 -158
  114. data/vcr_cassettes/stats.yml +0 -48
  115. data/vcr_cassettes/subaccounts.yml +0 -270
  116. data/vcr_cassettes/suppressions.yml +0 -1392
  117. data/vcr_cassettes/templates.yml +0 -1065
  118. data/vcr_cassettes/unsubscribes.yml +0 -401
  119. data/vcr_cassettes/webhooks.yml +0 -246
  120. data/vcr_cassettes/webhooks_v4.yml +0 -275
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'json'
5
- require 'logger'
6
- require 'railgun'
7
- require 'mailgun'
8
- require 'mailgun/exceptions/exceptions'
9
-
10
- ActionMailer::Base.raise_delivery_errors = true
11
- Rails.logger = Logger.new('/dev/null')
12
- Rails.logger.level = Logger::DEBUG
13
-
14
- class IntegrationUnitTestMailer < ActionMailer::Base
15
- default from: 'unittest@example.org'
16
-
17
- def plain_message(address, from, subject, headers)
18
- headers(headers)
19
- mail(to: address, from: from, subject: subject) do |format|
20
- format.text { render plain: 'Test!' }
21
- format.html { render html: '<p>Test!</p>'.html_safe }
22
- end
23
- end
24
- end
25
-
26
- vcr_opts = { cassette_name: 'message_deliver' }
27
-
28
- describe 'Message deliver', vcr: vcr_opts do
29
- let(:domain) { TESTDOMAIN || 'DOMAIN.TEST' }
30
- let(:config) do
31
- {
32
- api_key: APIKEY,
33
- domain: domain
34
- }
35
- end
36
- let!(:mail) { IntegrationUnitTestMailer.plain_message("bob@#{domain}", "bob@#{domain}", 'subject', {}) }
37
-
38
- it 'successfully delivers message' do
39
- result = Railgun::Mailer.new(config).deliver!(mail)
40
- result.to_h!
41
-
42
- expect(result.body['message']).to eq('Queued. Thank you.')
43
- expect(result.body).to include('id')
44
- expect(result.code).to eq(200)
45
- end
46
- end
47
-
48
- vcr_opts = { cassette_name: 'mailer_invalid_domain' }
49
-
50
- describe 'Invalid domain', vcr: vcr_opts do
51
- let(:domain) { 'not-our-doma.in' }
52
- let(:config) do
53
- {
54
- api_key: APIKEY,
55
- domain: domain
56
- }
57
- end
58
- let(:mail) { IntegrationUnitTestMailer.plain_message('sally@not-our-doma.in', "bob@#{domain}", 'subject', {}) }
59
-
60
- it 'raises expected error' do
61
- expect do
62
- Railgun::Mailer.new(config).deliver!(mail)
63
- end.to raise_error Mailgun::Unauthorized, /Invalid Domain or API key/
64
- end
65
- end
@@ -1,198 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'mailgun'
5
- require 'mailgun/exceptions/exceptions'
6
-
7
- describe 'Mailgun instantiation', vcr: { cassette_name: 'instance' } do
8
- it 'instantiates an HttpClient object' do
9
- expect { @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL) }.not_to raise_error
10
- end
11
- end
12
-
13
- describe 'Client exceptions', vcr: { cassette_name: 'exceptions' } do
14
- before(:all) do
15
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
16
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
17
- end
18
-
19
- it 'display useful error information' do
20
- @mg_obj.send_message('not-our-doma.in', {
21
- from: 'sally@not-our-doma.in',
22
- to: "bob@#{@domain}",
23
- subject: 'Exception Integration Test',
24
- text: 'INTEGRATION TESTING'
25
- })
26
- rescue Mailgun::CommunicationError => e
27
- expect(e.message).to include('404')
28
- expect(e.message).to include('Domain not found: not-our-doma.in')
29
- else
30
- raise
31
- end
32
- end
33
-
34
- describe 'Client exceptions', vcr: { cassette_name: 'exceptions-invalid-api-key' } do
35
- before(:all) do
36
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
37
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
38
- end
39
-
40
- it 'displays error information that API key is invalid' do
41
- @mg_obj.send_message(@domain, {
42
- from: "sally@#{@domain}",
43
- to: "sally@#{@domain}",
44
- subject: 'Exception Integration Test',
45
- text: 'INTEGRATION TESTING'
46
- })
47
- rescue Mailgun::Unauthorized => e
48
- expect(e.message).to include('401')
49
- expect(e.message).to include('Invalid Domain or API key')
50
- else
51
- raise
52
- end
53
- end
54
-
55
- describe 'Client exceptions', vcr: { cassette_name: 'exceptions-invalid-data' } do
56
- before(:all) do
57
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
58
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
59
- end
60
-
61
- it 'display useful error information' do
62
- @mg_obj.send_message(@domain, {
63
- from: "sally@#{@domain}",
64
- to: "sally#{@domain}",
65
- subject: 'Exception Integration Test',
66
- text: 'INTEGRATION TESTING'
67
- })
68
- rescue Mailgun::BadRequest => e
69
- expect(e.message).to include('400')
70
- expect(e.message).to include('to parameter is not a valid address. please check documentation')
71
- else
72
- raise
73
- end
74
- end
75
-
76
- describe 'Client exceptions', vcr: { cassette_name: 'exceptions-not-allowed' } do
77
- before(:all) do
78
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
79
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
80
- end
81
-
82
- it 'display useful error information' do
83
- @mg_obj.send_message(@domain, {
84
- from: "invalid@#{@domain}",
85
- to: "invalid#{@domain}",
86
- subject: 'Exception Integration Test',
87
- text: 'INTEGRATION TESTING'
88
- })
89
- rescue Mailgun::CommunicationError => e
90
- expect(e.message).to include('403')
91
- else
92
- raise
93
- end
94
- end
95
-
96
- describe 'The method send_message()', vcr: { cassette_name: 'send_message' } do
97
- before(:all) do
98
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
99
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
100
- end
101
-
102
- it 'sends a standard message in test mode.' do
103
- @mg_obj.enable_test_mode!
104
- result = @mg_obj.send_message(@domain, { :from => "bob@#{@domain}",
105
- :to => "sally@#{@domain}",
106
- :subject => 'Hash Integration Test',
107
- :text => 'INTEGRATION TESTING',
108
- 'o:testmode' => true })
109
- result.to_h!
110
- expect(result.body).to include('message')
111
- expect(result.body).to include('id')
112
- expect(Mailgun::Client.deliveries.size).to eq(1)
113
- end
114
-
115
- it 'fakes message send while in *client* test mode' do
116
- @mg_obj.enable_test_mode!
117
-
118
- expect(@mg_obj.test_mode?).to be(true)
119
-
120
- data = { from: "joe@#{@domain}",
121
- to: "bob@#{@domain}",
122
- subject: 'Test',
123
- text: 'Test Data' }
124
- uuid = 'uuid'
125
-
126
- allow(SecureRandom).to receive(:uuid).and_return(uuid)
127
-
128
- result = @mg_obj.send_message(@domain, data)
129
-
130
- result.to_h!
131
-
132
- expect(result.body).to include('message')
133
- expect(result.body).to include('id')
134
-
135
- expect(result.code).to eq(200)
136
- expect(result.body['id']).to eq("test-mode-mail-#{uuid}@localhost")
137
- expect(result.body['message']).to eq('Queued. Thank you.')
138
- end
139
-
140
- it 'sends a message builder message in test mode.' do
141
- mb_obj = Mailgun::MessageBuilder.new
142
- mb_obj.from("sender@#{@domain}", { 'first' => 'Sending', 'last' => 'User' })
143
- mb_obj.add_recipient(:to, "recipient@#{@domain}", { 'first' => 'Recipient', 'last' => 'User' })
144
- mb_obj.subject('Message Builder Integration Test')
145
- mb_obj.body_text('This is the text body.')
146
- mb_obj.test_mode(true)
147
-
148
- result = @mg_obj.send_message(@domain, mb_obj)
149
-
150
- result.to_h!
151
- expect(result.body).to include('message')
152
- expect(result.body).to include('id')
153
- end
154
-
155
- it 'sends a custom MIME message in test mode.' do
156
- mime_string = 'Delivered-To: mgbox01@gmail.com
157
- Received: by luna.mailgun.net with HTTP; Tue, 26 Nov 2013 17:59:11 +0000
158
- Mime-Version: 1.0
159
- Content-Type: text/plain; charset="ascii"
160
- Subject: Hello
161
- From: Excited User <me@samples.mailgun.org>
162
- To: sally@example.com
163
- Message-Id: <20131126175911.25310.92289@samples.mailgun.org>
164
- Content-Transfer-Encoding: 7bit
165
- X-Mailgun-Sid: WyI2NTU4MSIsICJtZ2JveDAxQGdtYWlsLmNvbSIsICIxZmYiXQ==
166
- Date: Tue, 26 Nov 2013 17:59:22 +0000
167
- X-Mailgun-Drop-Message: yes
168
- Sender: me@samples.mailgun.org
169
-
170
- Testing some Mailgun awesomness!'
171
-
172
- message_params = { from: "bobby@#{@domain}",
173
- to: "sally@#{@domain}",
174
- message: mime_string }
175
-
176
- result = @mg_obj.send_message(@domain, message_params)
177
-
178
- result.to_h!
179
- expect(result.body).to include('message')
180
- expect(result.body).to include('id')
181
- end
182
-
183
- it 'receives success response code' do
184
- @mg_obj.enable_test_mode!
185
-
186
- expect(@mg_obj.test_mode?).to be(true)
187
-
188
- data = { from: "joe@#{@domain}",
189
- to: "bob@#{@domain}",
190
- subject: 'Test',
191
- text: 'Test Data' }
192
-
193
- result = @mg_obj.send_message(@domain, data)
194
- result.to_h!
195
-
196
- expect(result.success?).to be(true)
197
- end
198
- end
@@ -1,38 +0,0 @@
1
- X-SBRS: 5.6
2
- X-SenderGroup: WHITELIST
3
- X-MailFlowPolicy: $TRUSTED
4
- DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=trstx.com; q=dns/txt; s=mx;
5
- t=1381182797; h=Mime-Version: Content-Type: Subject: From: To:
6
- Message-Id: Date: Sender: Content-Transfer-Encoding;
7
- bh=r6P1omjKL3m7gDuZC6dZEJU6trgWm1IRwAJb8h4wtfg=; b=UPFaFGiuDx2yZjCmiMEji0fIXvGMNwXUsuaX4Ss9p5EUkqE25eYjeJaJZ5w5FK+t0jsUPZqu
8
- FIH6sftQv7GBEbSktY6sv7dgv5q2yVlY8YNG7CXvUZdWmvwfQVvfL9j1RHJo9H3QpXT9c8bZ
9
- p9rpYmqZtZEz2ZesPj4kzUaB0lU=
10
- DomainKey-Signature: a=rsa-sha1; c=nofws; d=trstx.com; s=mx; q=dns;
11
- h=Mime-Version: Content-Type: Subject: From: To: Message-Id: Date:
12
- Sender: Content-Transfer-Encoding;
13
- b=QUYQf9OP16DphNAjeF95+G7V6DaqL4FA+m1sjIEWHdLzrGTQkiYTpzJdne3lzSypB0DwaG
14
- AT9zOhjjN64DWFOkJD2Ce5t6vfHa/GC3FCUMq3xz/Big94g+kOciawkHyUhCrmPyh/D7kWx1
15
- J75UIAdmE9XQ9bCSPhZ2MRaOv7b8c=
16
- Received: by luna.mailgun.net with HTTP; Mon, 07 Oct 2013 21:53:16 +0000
17
- Content-Type: text/plain; charset="ascii"
18
- Subject: Test Subject
19
- From: <joe@example.com>
20
- To: <bob@sample.com>
21
- Message-ID: <20131007215316.27052.7818@example.com>
22
- X-Mailgun-Sid: WyI4MzY1OSIsICJ0cmF2aXMuc3dpZW50ZWtAcmFja3NwYWasdfewNvbSIsICJjZjQ4Il0=
23
- Date: Mon, 7 Oct 2013 21:53:17 +0000
24
- Sender: <joe@example.com>
25
- Content-Transfer-Encoding: 7bit
26
- MIME-Version: 1.0
27
-
28
- --3a8c26e9f23c4ac193606295aa17fa6f
29
- Content-Type: text/plain; charset="ascii"
30
- Content-Transfer-Encoding: 7bit
31
-
32
- Testing some Mailgun awesomness!
33
- --3a8c26e9f23c4ac193606295aa17fa6f
34
- Content-Type: text/html; charset="ascii"
35
- Content-Transfer-Encoding: 7bit
36
-
37
- <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">Test
38
- --3a8c26e9f23c4ac193606295aa17fa6f--
@@ -1,224 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'mailgun'
5
-
6
- vcr_opts = { cassette_name: 'metrics' }
7
-
8
- describe Mailgun::Metrics, vcr: vcr_opts do
9
- let(:metrics) { described_class.new(Mailgun::Client.new(APIKEY, APIHOST, 'v1')) }
10
-
11
- describe '#account_metrics' do
12
- let(:options) do
13
- {
14
- resolution: 'hour',
15
- metrics: %w[
16
- accepted_count
17
- delivered_count
18
- clicked_rate
19
- opened_rate
20
- ],
21
- include_aggregates: true,
22
- start: 'Tue, 26 Nov 2024 20:56:50 -0500',
23
- duration: '1m',
24
- filter: {
25
- AND: [
26
- {
27
- attribute: 'domain',
28
- comparator: '!=',
29
- values: [
30
- {
31
- label: 'example.com',
32
- value: 'example.com'
33
- }
34
- ]
35
- }
36
- ]
37
- },
38
- dimensions: ['time'],
39
- end: 'Tue, 30 Nov 2024 20:56:50 -0500',
40
- include_subaccounts: true
41
- }
42
- end
43
-
44
- it 'responds with account metrics' do
45
- expect(metrics.account_metrics(options)).to eq(
46
- {
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
54
- },
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'
63
- }
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,
73
- 'delivered_count' => 1,
74
- 'opened_rate' => '0.0000',
75
- 'clicked_rate' => '0.0000'
76
- }
77
- },
78
- {
79
- 'dimensions' => [{
80
- 'dimension' => 'time',
81
- 'value' => 'Thu, 28 Nov 2024 15:00:00 +0000',
82
- 'display_value' => 'Thu, 28 Nov 2024 15:00:00 +0000'
83
- }],
84
- 'metrics' => {
85
- 'accepted_count' => 1,
86
- 'delivered_count' => 1,
87
- 'opened_rate' => '0.0000',
88
- 'clicked_rate' => '0.0000'
89
- }
90
- }],
91
- 'aggregates' => {
92
- 'metrics' => {
93
- 'accepted_count' => 3, 'delivered_count' => 3, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
94
- }
95
- }
96
- }
97
- )
98
- end
99
- end
100
-
101
- describe '#account_usage_metrics' do
102
- let(:options) do
103
- {
104
- resolution: 'hour',
105
- metrics: %w[
106
- email_preview_count
107
- email_preview_failed_count
108
- email_validation_bulk_count
109
- email_validation_count
110
- email_validation_list_count
111
- email_validation_mailgun_count
112
- email_validation_mailjet_count
113
- email_validation_public_count
114
- email_validation_single_count
115
- email_validation_valid_count
116
- link_validation_count
117
- link_validation_failed_count
118
- processed_count
119
- seed_test_count
120
- ],
121
- include_aggregates: true,
122
- start: 'Tue, 26 Nov 2024 20:56:50 -0500',
123
- duration: '1m',
124
- filter: {
125
- AND: [
126
- {
127
- attribute: 'subaccount',
128
- comparator: '!=',
129
- values: [
130
- {
131
- label: '12345',
132
- value: '12345'
133
- }
134
- ]
135
- }
136
- ]
137
- },
138
- dimensions: ['time'],
139
- end: 'Tue, 28 Nov 2024 20:56:50 -0500',
140
- include_subaccounts: true
141
- }
142
- end
143
-
144
- it 'responds with account usage metrics' do
145
- expect(metrics.account_usage_metrics(options)).to eq(
146
- {
147
- 'start' => 'Tue, 29 Oct 2024 01:00:00 +0000',
148
- 'end' => 'Fri, 29 Nov 2024 01:00:00 +0000',
149
- 'resolution' => 'hour',
150
- 'duration' => '1m',
151
- 'dimensions' => ['time'],
152
- 'pagination' => {
153
- 'sort' => '', 'skip' => 0, 'limit' => 1500, 'total' => 2
154
- },
155
- 'items' => [{
156
- 'dimensions' => [{
157
- 'dimension' => 'time',
158
- 'value' => 'Wed, 27 Nov 2024 00:00:00 +0000',
159
- 'display_value' => 'Wed, 27 Nov 2024 00:00:00 +0000'
160
- }],
161
- 'metrics' => {
162
- 'processed_count' => 2,
163
- 'email_validation_count' => 0,
164
- 'email_validation_public_count' => 0,
165
- 'email_validation_valid_count' => 0,
166
- 'email_validation_single_count' => 0,
167
- 'email_validation_bulk_count' => 0,
168
- 'email_validation_list_count' => 0,
169
- 'email_validation_mailgun_count' => 0,
170
- 'email_validation_mailjet_count' => 0,
171
- 'email_preview_count' => 0,
172
- 'email_preview_failed_count' => 0,
173
- 'link_validation_count' => 0,
174
- 'link_validation_failed_count' => 0,
175
- 'seed_test_count' => 0
176
- }
177
- },
178
- {
179
- 'dimensions' => [{
180
- 'dimension' => 'time',
181
- 'value' => 'Thu, 28 Nov 2024 00:00:00 +0000',
182
- 'display_value' => 'Thu, 28 Nov 2024 00:00:00 +0000'
183
- }],
184
- 'metrics' => {
185
- 'processed_count' => 1,
186
- 'email_validation_count' => 0,
187
- 'email_validation_public_count' => 0,
188
- 'email_validation_valid_count' => 0,
189
- 'email_validation_single_count' => 0,
190
- 'email_validation_bulk_count' => 0,
191
- 'email_validation_list_count' => 0,
192
- 'email_validation_mailgun_count' => 0,
193
- 'email_validation_mailjet_count' => 0,
194
- 'email_preview_count' => 0,
195
- 'email_preview_failed_count' => 0,
196
- 'link_validation_count' => 0,
197
- 'link_validation_failed_count' => 0,
198
- 'seed_test_count' => 0
199
- }
200
- }],
201
- 'aggregates' => {
202
- 'metrics' => {
203
- 'permanent_failed_count' => 0,
204
- 'processed_count' => 3,
205
- 'email_validation_count' => 0,
206
- 'email_validation_public_count' => 0,
207
- 'email_validation_valid_count' => 0,
208
- 'email_validation_single_count' => 0,
209
- 'email_validation_bulk_count' => 0,
210
- 'email_validation_list_count' => 0,
211
- 'email_validation_mailgun_count' => 0,
212
- 'email_validation_mailjet_count' => 0,
213
- 'email_preview_count' => 0,
214
- 'email_preview_failed_count' => 0,
215
- 'link_validation_count' => 0,
216
- 'link_validation_failed_count' => 0,
217
- 'seed_test_count' => 0
218
- }
219
- }
220
- }
221
- )
222
- end
223
- end
224
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'mailgun'
5
-
6
- vcr_opts = { cassette_name: 'routes', match_requests_on: %i[uri method body] }
7
-
8
- describe 'For the Routes endpoint', order: :defined, vcr: vcr_opts do
9
- before(:all) do
10
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
11
- @domain = TESTDOMAIN
12
- @forward_to = "alice@#{@domain}"
13
- @recipient = ".*@#{@domain}"
14
- end
15
-
16
- it 'creates a route' do
17
- result = @mg_obj.post('routes', { priority: 10,
18
- description: 'Integration Test Route',
19
- expression: "match_recipient(\"#{@forward_to}\")",
20
- action: "forward(\"#{@recipient}\")" })
21
-
22
- result.to_h!
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)
28
- end
29
-
30
- it 'creates a route with multiple actions' do
31
- result = @mg_obj.post('routes', { priority: 10,
32
- description: 'Integration Test Route',
33
- expression: "match_recipient(\"#{@forward_to}\")",
34
- action: ["forward(\"#{@recipient}\")", 'stop()'] })
35
-
36
- result.to_h!
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)
44
- end
45
-
46
- it 'gets a list of all routes.' do
47
- result = @mg_obj.get('routes', { limit: 50 })
48
-
49
- result.to_h!
50
- expect(result.body['total_count']).to be > 0
51
- end
52
-
53
- it 'gets the route.' do
54
- result = @mg_obj.get('routes', { limit: 1 })
55
- route_id = result.to_h['items'].first['id']
56
-
57
- result = @mg_obj.get("routes/#{route_id}")
58
-
59
- result.to_h!
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)
64
- end
65
-
66
- it 'updates the route.' do
67
- result = @mg_obj.get('routes', { limit: 1 })
68
- route_id = result.to_h['items'].first['id']
69
-
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}\")" })
74
-
75
- result.to_h!
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)
81
- end
82
-
83
- it 'removes a route' do
84
- result = @mg_obj.get('routes', { limit: 1 })
85
- route_id = result.to_h['items'].first['id']
86
-
87
- @mg_obj.delete("routes/#{route_id}")
88
-
89
- result.to_h!
90
- end
91
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'mailgun'
5
-
6
- vcr_opts = { cassette_name: 'stats' }
7
-
8
- describe 'For the Stats endpoint', vcr: vcr_opts do
9
- before(:all) do
10
- @mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
11
- @domain = TESTDOMAIN || 'DOMAIN.TEST'
12
- end
13
-
14
- it 'get some stats.' do
15
- @mg_obj.get("#{@domain}/stats", { limit: 50, skip: 10, event: 'sent' })
16
- end
17
- end