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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3824447d13539969e56a4f92c0758acaa3ed8d83107d32400158e86cef25ca7b
4
- data.tar.gz: efb48ecdc22f5beeff51484a2e5453797cd7d8f66c3913009d9e614cb37ecb91
3
+ metadata.gz: 0f7b6ece85b0a809a90ea79e6836b55bc5a97cfe8cd036c1567acff92b8053c5
4
+ data.tar.gz: 277f0def30a104f86beef2c8ef3012b877fa94e35e415a9beff328cc76247280
5
5
  SHA512:
6
- metadata.gz: 32bf21cc891b61b3afb61f89648d3f000068d81c0edd0b2a9b928b0ce748a9224fa3ce86a28eeabb73247f1762a689fc93b957dfaa85f8f3b976a5bb070eddd5
7
- data.tar.gz: b74850e669c2b90b8e7433a390a7a69aa0db9b9ae73758cc743a72040137f629246bbd11cf29234273d13ae833392c3890047601532689756201ad702dd3ae84
6
+ metadata.gz: 3a419c6c2c8fbb7efa2ed08ad51da87441befe54e00e3a70db6626b82f353932827c5ebdd933f32edfe06ba043ea2dcba99cacd93a445f078ff089ad58af96ea
7
+ data.tar.gz: c910105de443193207c67c5afaa24b2d423dfb7b7e995466a95b8192d967f244f36e45142d78f97a46fb893809a633e793d75366ea206f83338b8f138a4ed3af
@@ -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: [ '2.6', '2.7', '3.0', '3.1', '3.4' ]
17
+ ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
19
18
 
20
19
  steps:
21
- - uses: actions/checkout@v4
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 by @alex-leb in (https://github.com/mailgun/mailgun-ruby/pull/361)
8
- - Fix BatchMessage modifies stored test deliveries by @alex-leb in (https://github.com/mailgun/mailgun-ruby/pull/362)
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
@@ -19,7 +19,7 @@ gem install mailgun-ruby
19
19
  Gemfile:
20
20
 
21
21
  ```ruby
22
- gem 'mailgun-ruby', '~>1.3.9'
22
+ gem 'mailgun-ruby', '~>1.4.1'
23
23
  ```
24
24
 
25
25
  Usage
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
- # Remove a domain
30
- domainer.remove 'this.one.is.not.needed.'
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
- Suppressions for a Domain
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
- You can manage domain suppressions (bounces, unsubscribes, complaints) using the
40
- [`Mailgun::Suppressions`](/docs/Suppressions.md) client:
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
- # Instantiate the Mailgun Client with your API key
44
- mg_client = Mailgun::Client.new('your-api-key')
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
- See the [Suppressions](/docs/Suppressions.md) for usage samples and
51
- [suppressions.rb](/lib/mailgun/suppressions.rb) for suppressions client API.
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/en/latest/api-domains.html)
109
+ See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domains)
57
110
  for more information
@@ -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 3.
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.
@@ -1,5 +1,3 @@
1
- require 'mailgun/exceptions/exceptions'
2
-
3
1
  module Mailgun
4
2
 
5
3
  # Mailgun::Address is a simple interface to the Email Validation API.
@@ -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 = false,
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 = Faraday.new(request_options) do |conn|
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, data)
177
- response = @http_client.put(resource_path, data)
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
- if params
190
- response = @http_client.delete(resource_path, params: params)
191
- else
192
- response = @http_client.delete(resource_path)
193
- end
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