mailgun-ruby 1.3.10 → 1.4.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/.github/workflows/ci.yml +2 -3
- data/CHANGELOG.md +11 -2
- data/README.md +1 -1
- data/docs/Domains.md +71 -18
- data/docs/MessageBuilder.md +1 -1
- data/lib/mailgun/address.rb +0 -2
- data/lib/mailgun/client.rb +36 -21
- data/lib/mailgun/domains/domains.rb +187 -176
- data/lib/mailgun/events/events.rb +0 -2
- data/lib/mailgun/exceptions/exceptions.rb +2 -0
- data/lib/mailgun/helpers/api_version_checker.rb +41 -0
- data/lib/mailgun/lists/opt_in_handler.rb +0 -3
- data/lib/mailgun/logs/logs.rb +0 -2
- data/lib/mailgun/messages/batch_message.rb +0 -2
- data/lib/mailgun/messages/message_builder.rb +0 -4
- data/lib/mailgun/metrics/metrics.rb +0 -2
- data/lib/mailgun/subaccounts/subaccounts.rb +0 -2
- data/lib/mailgun/suppressions.rb +2 -6
- data/lib/mailgun/tags/analytics_tags.rb +32 -0
- data/lib/mailgun/tags/tags.rb +11 -2
- data/lib/mailgun/templates/templates.rb +0 -2
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun-ruby.rb +2 -2
- data/lib/mailgun.rb +34 -18
- data/lib/railgun/mailer.rb +0 -6
- data/lib/railgun/railtie.rb +9 -2
- data/lib/railgun.rb +12 -5
- data/mailgun.gemspec +7 -7
- data/spec/integration/domains_spec.rb +218 -192
- data/spec/spec_helper.rb +1 -5
- data/vcr_cassettes/domains.yml +152 -0
- metadata +32 -20
- data/lib/railgun/message.rb +0 -18
- data/spec/integration/tags.rb +0 -139
- data/vcr_cassettes/tags.yml +0 -417
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0f7b6ece85b0a809a90ea79e6836b55bc5a97cfe8cd036c1567acff92b8053c5
|
|
4
|
+
data.tar.gz: 277f0def30a104f86beef2c8ef3012b877fa94e35e415a9beff328cc76247280
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3a419c6c2c8fbb7efa2ed08ad51da87441befe54e00e3a70db6626b82f353932827c5ebdd933f32edfe06ba043ea2dcba99cacd93a445f078ff089ad58af96ea
|
|
7
|
+
data.tar.gz: c910105de443193207c67c5afaa24b2d423dfb7b7e995466a95b8192d967f244f36e45142d78f97a46fb893809a633e793d75366ea206f83338b8f138a4ed3af
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -11,14 +11,13 @@ permissions:
|
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
13
|
test:
|
|
14
|
-
|
|
15
14
|
runs-on: ubuntu-latest
|
|
16
15
|
strategy:
|
|
17
16
|
matrix:
|
|
18
|
-
ruby-version: [ '
|
|
17
|
+
ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
|
|
19
18
|
|
|
20
19
|
steps:
|
|
21
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v6
|
|
22
21
|
- name: Set up Ruby
|
|
23
22
|
uses: ruby/setup-ruby@v1
|
|
24
23
|
with:
|
data/CHANGELOG.md
CHANGED
|
@@ -2,10 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.4.0] - 2025-09-22
|
|
6
|
+
|
|
7
|
+
- Domains - Add missing endpoints and refactor existing ones in (https://github.com/mailgun/mailgun-ruby/pull/365)
|
|
8
|
+
|
|
9
|
+
## [1.3.10] - 2025-08-28
|
|
10
|
+
|
|
11
|
+
- Switch to mini_mime for memory savings in (https://github.com/mailgun/mailgun-ruby/pull/363)
|
|
12
|
+
- Add backwards compatibility for previous ruby versions in (https://github.com/mailgun/mailgun-ruby/pull/364)
|
|
13
|
+
|
|
5
14
|
## [1.3.9] - 2025-07-28
|
|
6
15
|
|
|
7
|
-
- Fix messages.mime broken
|
|
8
|
-
- Fix BatchMessage modifies stored test deliveries
|
|
16
|
+
- Fix messages.mime broken in (https://github.com/mailgun/mailgun-ruby/pull/361)
|
|
17
|
+
- Fix BatchMessage modifies stored test deliveries in (https://github.com/mailgun/mailgun-ruby/pull/362)
|
|
9
18
|
|
|
10
19
|
## [1.3.8] - 2025-07-23
|
|
11
20
|
|
data/README.md
CHANGED
data/docs/Domains.md
CHANGED
|
@@ -9,49 +9,102 @@ all calls except credentials.
|
|
|
9
9
|
|
|
10
10
|
Usage - Domains
|
|
11
11
|
-----------------------
|
|
12
|
-
|
|
12
|
+
First, instantiate the Mailgun Client with your API key
|
|
13
13
|
```ruby
|
|
14
|
-
# First, instantiate the Mailgun Client with your API key
|
|
15
14
|
mg_client = Mailgun::Client.new('your-api-key')
|
|
16
15
|
domainer = Mailgun::Domains.new(mg_client)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Core Domain methods:
|
|
17
19
|
|
|
20
|
+
```ruby
|
|
18
21
|
# Get a list of current domains.
|
|
19
22
|
domainer.list
|
|
20
23
|
|
|
21
|
-
# View details of a domain
|
|
22
|
-
domainer.info 'my.perfect.domain'
|
|
23
|
-
|
|
24
24
|
# Add a new domain
|
|
25
25
|
domainer.create 'my.new.moreness'
|
|
26
26
|
# or with options
|
|
27
27
|
domainer.create 'my.new.moreness', { some: 'options' }
|
|
28
28
|
|
|
29
|
-
#
|
|
30
|
-
domainer.
|
|
29
|
+
# View details of a domain
|
|
30
|
+
domainer.get 'my.perfect.domain'
|
|
31
31
|
|
|
32
32
|
# Update a domain
|
|
33
33
|
domainer.update 'my.new.moreness', { some: 'options' }
|
|
34
|
+
|
|
35
|
+
# Verify a domain
|
|
36
|
+
domainer.verify 'my.perfect.domain'
|
|
37
|
+
|
|
38
|
+
# Remove a domain
|
|
39
|
+
domainer.remove 'this.one.is.not.needed.'
|
|
40
|
+
|
|
41
|
+
|
|
34
42
|
```
|
|
35
43
|
|
|
36
|
-
|
|
37
|
-
|
|
44
|
+
Domain Keys methods:
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
# List keys for all domains
|
|
48
|
+
domainer.list_domain_keys { some: 'options' }
|
|
49
|
+
|
|
50
|
+
# Create a domain key
|
|
51
|
+
domainer.create_domain_key { some: 'options' }
|
|
52
|
+
|
|
53
|
+
# Delete a domain key
|
|
54
|
+
domainer.delete_domain_key { some: 'options' }
|
|
55
|
+
|
|
56
|
+
# Activate a domain key
|
|
57
|
+
domainer.activate_domain_key 'my.perfect.domain', 'selector'
|
|
58
|
+
|
|
59
|
+
# List domain keys
|
|
60
|
+
domainer.get_domain_keys 'my.perfect.domain'
|
|
61
|
+
|
|
62
|
+
# Deactivate a domain key
|
|
63
|
+
domainer.deactivate_domain_key 'my.perfect.domain', 'selector'
|
|
38
64
|
|
|
39
|
-
|
|
40
|
-
|
|
65
|
+
# Update DKIM authority
|
|
66
|
+
domainer.update_domain_dkim_authority 'my.perfect.domain', { some: 'options' }
|
|
67
|
+
|
|
68
|
+
# Update a DKIM selector
|
|
69
|
+
domainer.update_domain_dkim_selector 'my.perfect.domain', { some: 'options' }
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Domain Tracking methods:
|
|
41
73
|
|
|
42
74
|
```ruby
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
supp_client = mg_client.suppressions('example.org')
|
|
75
|
+
# Get tracking settings
|
|
76
|
+
domainer.get_domain_tracking_settings 'my.perfect.domain'
|
|
46
77
|
|
|
47
|
-
#
|
|
78
|
+
# Update click tracking settings
|
|
79
|
+
domainer.update_domain_tracking_click_settings 'my.perfect.domain', { some: 'options' }
|
|
80
|
+
|
|
81
|
+
# Update open tracking settings
|
|
82
|
+
domainer.update_domain_tracking_open_settings 'my.perfect.domain', { some: 'options' }
|
|
83
|
+
|
|
84
|
+
# Update unsubscribe tracking settings
|
|
85
|
+
domainer.update_domain_tracking_unsubscribe_settings 'my.perfect.domain', { some: 'options' }
|
|
86
|
+
|
|
87
|
+
# Tracking Certificate: Get certificate and status
|
|
88
|
+
domainer.get_domain_tracking_certificate 'my.perfect.domain'
|
|
89
|
+
|
|
90
|
+
# Tracking Certificate: Regenerate expired certificate
|
|
91
|
+
domainer.regenerate_domain_tracking_certificate 'my.perfect.domain', { some: 'options' }
|
|
92
|
+
|
|
93
|
+
# Tracking Certificate: Generate
|
|
94
|
+
domainer.generate_domain_tracking_certificate 'my.perfect.domain', { some: 'options' }
|
|
48
95
|
```
|
|
49
96
|
|
|
50
|
-
|
|
51
|
-
|
|
97
|
+
DKIM Security methods:
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
# Update Automatic Sender Security DKIM key rotation for a domain
|
|
101
|
+
domainer.dkim_rotation 'my.perfect.domain', true, { some: 'options' }
|
|
52
102
|
|
|
103
|
+
# Rotate Automatic Sender Security DKIM key for a domain
|
|
104
|
+
domainer.dkim_rotate 'my.perfect.domain'
|
|
105
|
+
```
|
|
53
106
|
|
|
54
107
|
More Documentation
|
|
55
108
|
------------------
|
|
56
|
-
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/
|
|
109
|
+
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domains)
|
|
57
110
|
for more information
|
data/docs/MessageBuilder.md
CHANGED
|
@@ -50,7 +50,7 @@ mb_obj.message_id("<20141014000000.11111.11111@example.com>")
|
|
|
50
50
|
mb_obj.message_id(nil)
|
|
51
51
|
mb_obj.message_id('')
|
|
52
52
|
|
|
53
|
-
# Set the Message-tags at most
|
|
53
|
+
# Set the Message-tags at most 10.
|
|
54
54
|
mb_obj.add_tag("You can track mails as tag-units!")
|
|
55
55
|
|
|
56
56
|
# Campaigns and headers.
|
data/lib/mailgun/address.rb
CHANGED
data/lib/mailgun/client.rb
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
require 'mailgun/chains'
|
|
2
|
-
require 'mailgun/suppressions'
|
|
3
|
-
require 'mailgun/exceptions/exceptions'
|
|
4
|
-
|
|
5
1
|
module Mailgun
|
|
6
2
|
# A Mailgun::Client object is used to communicate with the Mailgun API. It is a
|
|
7
3
|
# wrapper around Faraday so you don't have to worry about the HTTP aspect
|
|
@@ -15,7 +11,7 @@ module Mailgun
|
|
|
15
11
|
api_host = Mailgun.api_host || 'api.mailgun.net',
|
|
16
12
|
api_version = Mailgun.api_version || 'v3',
|
|
17
13
|
ssl = true,
|
|
18
|
-
test_mode =
|
|
14
|
+
test_mode = !!Mailgun.test_mode,
|
|
19
15
|
timeout = nil,
|
|
20
16
|
proxy_url = Mailgun.proxy_url)
|
|
21
17
|
|
|
@@ -32,14 +28,7 @@ module Mailgun
|
|
|
32
28
|
}
|
|
33
29
|
request_options.merge!(request: {timeout: timeout}) if timeout
|
|
34
30
|
|
|
35
|
-
@http_client =
|
|
36
|
-
conn.request :multipart
|
|
37
|
-
conn.request :authorization, :basic, 'api', api_key
|
|
38
|
-
conn.request :url_encoded
|
|
39
|
-
conn.response :raise_error, include_request: true
|
|
40
|
-
conn.adapter Faraday.default_adapter
|
|
41
|
-
conn.options.params_encoder = Faraday::FlatParamsEncoder
|
|
42
|
-
end
|
|
31
|
+
@http_client = build_http_client(api_key, request_options)
|
|
43
32
|
|
|
44
33
|
@test_mode = test_mode
|
|
45
34
|
@api_version = api_version
|
|
@@ -173,8 +162,16 @@ module Mailgun
|
|
|
173
162
|
# @param [Hash] data This should be a standard Hash
|
|
174
163
|
# containing required parameters for the requested resource.
|
|
175
164
|
# @return [Mailgun::Response] A Mailgun::Response object.
|
|
176
|
-
def put(resource_path,
|
|
177
|
-
response =
|
|
165
|
+
def put(resource_path, params, body_params = false)
|
|
166
|
+
response =
|
|
167
|
+
if body_params
|
|
168
|
+
@http_client.put(resource_path) do |request|
|
|
169
|
+
request['Content-Type'] = 'application/json'
|
|
170
|
+
request.params = params.to_json
|
|
171
|
+
end
|
|
172
|
+
else
|
|
173
|
+
@http_client.put(resource_path, params)
|
|
174
|
+
end
|
|
178
175
|
Response.new(response)
|
|
179
176
|
rescue => err
|
|
180
177
|
raise communication_error err
|
|
@@ -185,12 +182,19 @@ module Mailgun
|
|
|
185
182
|
# @param [String] resource_path This is the API resource you wish to interact
|
|
186
183
|
# with. Be sure to include your domain, where necessary.
|
|
187
184
|
# @return [Mailgun::Response] A Mailgun::Response object.
|
|
188
|
-
def delete(resource_path, params = nil)
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
def delete(resource_path, params = nil, body_params = false)
|
|
186
|
+
response =
|
|
187
|
+
if params
|
|
188
|
+
if body_params
|
|
189
|
+
@http_client.delete(resource_path) do |request|
|
|
190
|
+
request.body = params.to_json
|
|
191
|
+
end
|
|
192
|
+
else
|
|
193
|
+
@http_client.delete(resource_path, params: params)
|
|
194
|
+
end
|
|
195
|
+
else
|
|
196
|
+
@http_client.delete(resource_path)
|
|
197
|
+
end
|
|
194
198
|
Response.new(response)
|
|
195
199
|
rescue => err
|
|
196
200
|
raise communication_error err
|
|
@@ -262,5 +266,16 @@ module Mailgun
|
|
|
262
266
|
working_domain
|
|
263
267
|
) if message.fetch('from', []).empty? && message.fetch(:from, []).empty?
|
|
264
268
|
end
|
|
269
|
+
|
|
270
|
+
def build_http_client(api_key, request_options)
|
|
271
|
+
Faraday.new(request_options) do |conn|
|
|
272
|
+
conn.request :multipart
|
|
273
|
+
conn.request :authorization, :basic, 'api', api_key
|
|
274
|
+
conn.request :url_encoded
|
|
275
|
+
conn.response :raise_error, include_request: true
|
|
276
|
+
conn.adapter Faraday.default_adapter
|
|
277
|
+
conn.options.params_encoder = Faraday::FlatParamsEncoder
|
|
278
|
+
end
|
|
279
|
+
end
|
|
265
280
|
end
|
|
266
281
|
end
|