mailgun-ruby 1.4.3 → 1.4.4

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: e4ebcbb3e9a3ff18a06515ffca7027ffa893d0250ad4f6491cd896a78e035428
4
- data.tar.gz: 27750827e497452d5ea7276601a01621164d9a4decfb3e6f43b1d32c51b7aa62
3
+ metadata.gz: c32fbe02cb160ca73a1f278217357f922e9dbdf70605f00314e8f8031ead4361
4
+ data.tar.gz: 59a3c18c5955237dc99bf821d522fa7530f0ba91d8608c7ed0e62389b776d04f
5
5
  SHA512:
6
- metadata.gz: 7432da86b0a9b20ddaea5e0cb049c0fac6b7f8e37cc907d79bbcd5aa642550a8c8067bdd40e3c87f49679306d662906ede13c9bdbb4fd70ea19498f4325c9d92
7
- data.tar.gz: 8691eac12d6cd590d8735a60965376ee7f751fe700c6533dc61cab987917292ef21d03e22d0c35c2c58584288602396b5201b8d5b55bdf9834693819a10185cc
6
+ metadata.gz: baf3cb978859c99d99c0b1ec3a470313a29bbeb57b5a38175be79abe3f8d8f5ce65302d407dbc759c892bd0c676d8d2ee9e1dfacf1bd4a91baeda3dce54f1d35
7
+ data.tar.gz: 450c77f5dc1de40e84a52f98dea1219ba0f4664b41de3396574ddef20baff7ef35d97c21406ca5d8f8b414a875d3bff48bcfb68a8a467ea5333c8b60eb0bc5f2
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.4.3'
22
+ gem 'mailgun-ruby', '~>1.4.4'
23
23
  ```
24
24
 
25
25
  Usage
@@ -186,6 +186,7 @@ This SDK includes the following components:
186
186
  - [Opt-In Handler](docs/OptInHandler.md)
187
187
  - [Domains](docs/Domains.md)
188
188
  - [Webhooks](docs/Webhooks.md)
189
+ - [Account Webhooks](docs/AccountWebhooks.md)
189
190
  - [Events](docs/Events.md)
190
191
  - [Snippets](docs/Snippets.md)
191
192
  - [Subaccounts](docs/Subaccounts.md)
@@ -0,0 +1,55 @@
1
+ Mailgun - Account Webhooks
2
+ ====================
3
+
4
+ This is the Mailgun Ruby *Account Webhook* utilities.
5
+
6
+ The below assumes you've already installed the Mailgun Ruby SDK in to your
7
+ project. If not, go back to the master README for instructions.
8
+
9
+ Usage - Account Webhooks
10
+ -----------------------
11
+
12
+ ```ruby
13
+ # First, instantiate the Mailgun Client with your API key
14
+ mg_client = Mailgun::Client.new('your-api-key')
15
+ hook = Mailgun::AccountWebhooks.new(mg_client)
16
+
17
+ ```
18
+
19
+ Account Webhooks methods:
20
+
21
+ ```ruby
22
+ # List account-level webhooks
23
+ hook.list
24
+ hook.list('id1, id2')
25
+
26
+ # Create an account-level webhook
27
+ hook.create(
28
+ description: 'desc',
29
+ event_types: 'accepted',
30
+ url: 'https://the.webhook.url/'
31
+ )
32
+
33
+ # Delete account-level webhooks
34
+ hook.remove(all: true)
35
+ hook.remove('id1, id2')
36
+
37
+ # Get account-level webhook by ID
38
+ hook.get('id1')
39
+
40
+ # Update an account-level webhook
41
+ hook.update(
42
+ 'hook',
43
+ description: 'desc',
44
+ event_types: 'accepted',
45
+ url: 'https://the.webhook.url/'
46
+ )
47
+
48
+ # Delete account-level webhook by ID
49
+ hook.remove_by_id('id1')
50
+ ```
51
+
52
+ More Documentation
53
+ ------------------
54
+ See the official [Mailgun Account Webhooks Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/account-webhooks)
55
+ for more information
@@ -0,0 +1,49 @@
1
+ Mailgun - DomainKeys
2
+ ====================
3
+
4
+ This is the Mailgun Ruby *DomainKeys* utilities.
5
+
6
+ The below assumes you've already installed the Mailgun Ruby SDK in to your
7
+ project. If not, go back to the master README for instructions. It currently supports
8
+ all calls except credentials.
9
+
10
+ Usage - DomainKeys
11
+ -----------------------
12
+ First, instantiate the Mailgun Client with your API key
13
+ ```ruby
14
+ mg_client = Mailgun::Client.new('your-api-key')
15
+ domainer = Mailgun::DomainKeys.new(mg_client)
16
+ ```
17
+
18
+ Domain Keys methods:
19
+
20
+ ```ruby
21
+ # List keys for all domains
22
+ domainer.list_domain_keys { some: 'options' }
23
+
24
+ # Create a domain key
25
+ domainer.create_domain_key { some: 'options' }
26
+
27
+ # Delete a domain key
28
+ domainer.delete_domain_key { some: 'options' }
29
+
30
+ # Activate a domain key
31
+ domainer.activate_domain_key 'my.perfect.domain', 'selector'
32
+
33
+ # List domain keys
34
+ domainer.get_domain_keys 'my.perfect.domain'
35
+
36
+ # Deactivate a domain key
37
+ domainer.deactivate_domain_key 'my.perfect.domain', 'selector'
38
+
39
+ # Update DKIM authority
40
+ domainer.update_domain_dkim_authority 'my.perfect.domain', { some: 'options' }
41
+
42
+ # Update a DKIM selector
43
+ domainer.update_domain_dkim_selector 'my.perfect.domain', { some: 'options' }
44
+ ```
45
+
46
+ More Documentation
47
+ ------------------
48
+ See the official [Mailgun Domain Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-keys)
49
+ for more information
data/docs/Domains.md CHANGED
@@ -41,34 +41,6 @@ domainer.remove 'this.one.is.not.needed.'
41
41
 
42
42
  ```
43
43
 
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'
64
-
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
44
  Domain Tracking methods:
73
45
 
74
46
  ```ruby
data/docs/Webhooks.md CHANGED
@@ -38,5 +38,5 @@ hook.remove_all 'my.perfect.domain'
38
38
 
39
39
  More Documentation
40
40
  ------------------
41
- See the official [Mailgun Domain Docs](https://documentation.mailgun.com/en/latest/api-webhooks.html)
41
+ See the official [Mailgun Webhooks Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-webhooks)
42
42
  for more information
@@ -185,7 +185,7 @@ module Mailgun
185
185
  request.body = params.to_json
186
186
  end
187
187
  else
188
- @http_client.delete(resource_path, params: params)
188
+ @http_client.delete(resource_path, params)
189
189
  end
190
190
  else
191
191
  @http_client.delete(resource_path)
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailgun
4
+ # A Mailgun::Domains object is a simple CRUD interface to Mailgun DomainsKeys.
5
+ # Uses Mailgun
6
+ class DomainKeys
7
+ include ApiVersionChecker
8
+
9
+ def initialize(client = Mailgun::Client.new)
10
+ @client = client
11
+ end
12
+
13
+ # Public: List keys for all domains
14
+ #
15
+ # options - [Hash] of
16
+ # page - [String] Encoded paging information, provided via 'next', 'previous' links
17
+ # limit - [Integer] Limits the number of items returned in a request
18
+ # signing_domain - [String] Filter by signing domain
19
+ # selector - [String] Filter by selector
20
+ #
21
+ # Returns [Hash] with message key
22
+ def list_domain_keys(options = {})
23
+ @client.get('dkim/keys', options).to_h
24
+ end
25
+
26
+ # Public: Create a domain key
27
+ #
28
+ # options - [Hash] of
29
+ # signing_domain - [String] Name of the domain (ex. domain.com)
30
+ # selector - [String] Selector to be used for the new domain key
31
+ # bits - [Integer] Key size, can be 1024 or 2048
32
+ # pem - [String] Private key PEM
33
+ #
34
+ # Returns [Hash] with message key
35
+ def create_domain_key(options = {})
36
+ @client.post('dkim/keys', options).to_h
37
+ end
38
+
39
+ # Public: Delete a domain key.
40
+ #
41
+ # options - [Hash] of
42
+ # signing_domain - [Integer] Name of the domain (ex. domain.com)
43
+ # selector - [String] Name of the selector
44
+ #
45
+ # Returns [Hash] with message key
46
+ def delete_domain_key(options = {})
47
+ @client.delete('dkim/keys', options).to_h
48
+ end
49
+
50
+ # Public: Activate a domain key for a specified authority and selector.
51
+ #
52
+ # domain - [String] Name of the domain (ex. domain.com)
53
+ # selector - [String] The selector you want to activate for the domain key
54
+ #
55
+ # Returns [Hash] with message key and autority + selector data
56
+ def activate_domain_key(domain, selector)
57
+ @client.put("domains/#{domain}/keys/#{selector}/activate", {}).to_h
58
+ end
59
+
60
+ # Public: Lists the domain keys for a specified signing domain / authority
61
+ #
62
+ # domain - [String] Name of the domain (ex. domain.com)
63
+ #
64
+ # Returns [Hash] with domain keys data
65
+ def get_domain_keys(domain)
66
+ @client.get("domains/#{domain}/keys").to_h
67
+ end
68
+
69
+ # Public: Deactivate a domain key for a specified authority and selector
70
+ #
71
+ # domain - [String] Name of the domain (ex. domain.com)
72
+ # selector - [String] The selector you want to activate for the domain key
73
+ #
74
+ # Returns [Hash] with message key and autority + selector data
75
+ def deactivate_domain_key(domain, selector)
76
+ @client.put("domains/#{domain}/keys/#{selector}/deactivate", {}).to_h
77
+ end
78
+
79
+ # Public: Change the DKIM authority for a domain.
80
+ #
81
+ # domain - [String] Name of the domain (ex. domain.com)
82
+ # options - [Hash] of
83
+ # self - [Boolean] true - the domain will be the DKIM authority for itself even
84
+ # if the root domain is registered on the same mailgun account
85
+ #
86
+ # Returns [Hash] Information on the DKIM authority
87
+ def update_domain_dkim_authority(domain, options = {})
88
+ @client.put("domains/#{domain}/dkim_authority", options).to_h
89
+ end
90
+
91
+ # Public: Update the DKIM selector for a domains
92
+ #
93
+ # domain - [String] Name of the domain (ex. domain.com)
94
+ # options - [Hash] of
95
+ # dkim_selector - [String] change the DKIM selector for a domain.
96
+ #
97
+ # Returns [Hash] with message key
98
+ def update_domain_dkim_selector(domain, options = {})
99
+ @client.put("domains/#{domain}/dkim_selector", options).to_h
100
+ end
101
+
102
+ enforces_api_version 'v1', :list_domain_keys, :create_domain_key, :delete_domain_key
103
+ enforces_api_version 'v3', :update_domain_dkim_authority, :update_domain_dkim_selector
104
+ enforces_api_version 'v4', :activate_domain_key, :deactivate_domain_key
105
+ enforces_api_version 'v4', :get_domain_keys
106
+ end
107
+ end
@@ -88,100 +88,6 @@ module Mailgun
88
88
 
89
89
  # ==== End of Core Domains methods ====
90
90
 
91
- # ==== Domain::Keys methods ====
92
-
93
- # Public: List keys for all domains
94
- #
95
-
96
- # options - [Hash] of
97
- # page - [String] Encoded paging information, provided via 'next', 'previous' links
98
- # limit - [Integer] Limits the number of items returned in a request
99
- # signing_domain - [String] Filter by signing domain
100
- # selector - [String] Filter by selector
101
- #
102
- # Returns [Hash] with message key
103
- def list_domain_keys(options = {})
104
- @client.get('dkim/keys', options).to_h
105
- end
106
-
107
- # Public: Create a domain key
108
- #
109
- # options - [Hash] of
110
- # signing_domain - [String] Name of the domain (ex. domain.com)
111
- # selector - [String] Selector to be used for the new domain key
112
- # bits - [Integer] Key size, can be 1024 or 2048
113
- # pem - [String] Private key PEM
114
- #
115
- # Returns [Hash] with message key
116
- def create_domain_key(options = {})
117
- @client.post('dkim/keys', options).to_h
118
- end
119
-
120
- # Public: Delete a domain key.
121
- #
122
- # options - [Hash] of
123
- # signing_domain - [Integer] Name of the domain (ex. domain.com)
124
- # selector - [String] Name of the selector
125
- #
126
- # Returns [Hash] with message key
127
- def delete_domain_key(options = {})
128
- @client.delete('dkim/keys', options).to_h
129
- end
130
-
131
- # Public: Activate a domain key for a specified authority and selector.
132
- #
133
- # domain - [String] Name of the domain (ex. domain.com)
134
- # selector - [String] The selector you want to activate for the domain key
135
- #
136
- # Returns [Hash] with message key and autority + selector data
137
- def activate_domain_key(domain, selector)
138
- @client.put("domains/#{domain}/keys/#{selector}/activate", {}).to_h
139
- end
140
-
141
- # Public: Lists the domain keys for a specified signing domain / authority
142
- #
143
- # domain - [String] Name of the domain (ex. domain.com)
144
- #
145
- # Returns [Hash] with domain keys data
146
- def get_domain_keys(domain)
147
- @client.get("domains/#{domain}/keys").to_h
148
- end
149
-
150
- # Public: Deactivate a domain key for a specified authority and selector
151
- #
152
- # domain - [String] Name of the domain (ex. domain.com)
153
- # selector - [String] The selector you want to activate for the domain key
154
- #
155
- # Returns [Hash] with message key and autority + selector data
156
- def deactivate_domain_key(domain, selector)
157
- @client.put("domains/#{domain}/keys/#{selector}/deactivate", {}).to_h
158
- end
159
-
160
- # Public: Change the DKIM authority for a domain.
161
- #
162
- # domain - [String] Name of the domain (ex. domain.com)
163
- # options - [Hash] of
164
- # self - [Boolean] true - the domain will be the DKIM authority for itself even
165
- # if the root domain is registered on the same mailgun account
166
- #
167
- # Returns [Hash] Information on the DKIM authority
168
- def update_domain_dkim_authority(domain, options = {})
169
- @client.put("domains/#{domain}/dkim_authority", options).to_h
170
- end
171
-
172
- # Public: Update the DKIM selector for a domains
173
- #
174
- # domain - [String] Name of the domain (ex. domain.com)
175
- # options - [Hash] of
176
- # dkim_selector - [String] change the DKIM selector for a domain.
177
- #
178
- # Returns [Hash] with message key
179
- def update_domain_dkim_selector(domain, options = {})
180
- @client.put("domains/#{domain}/dkim_selector", options).to_h
181
- end
182
-
183
- # ==== End of Domain::Keys methods ====
184
-
185
91
  # ==== Domain::Tracking methods ====
186
92
 
187
93
  # Public: Returns tracking settings for the defined domain.
@@ -346,16 +252,13 @@ module Mailgun
346
252
 
347
253
  # ==== End of Reporting::Stats methods ====
348
254
 
349
- enforces_api_version 'v1', :list_domain_keys, :create_domain_key, :delete_domain_key, :dkim_rotation,
350
- :dkim_rotate
255
+ enforces_api_version 'v1', :dkim_rotation, :dkim_rotate
351
256
  enforces_api_version 'v2', :get_domain_tracking_certificate, :regenerate_domain_tracking_certificate,
352
257
  :generate_domain_tracking_certificate
353
258
  enforces_api_version 'v3', :remove, :create_smtp_credentials, :update_smtp_credentials,
354
259
  :delete_smtp_credentials, :get_domain_tracking_settings,
355
260
  :update_domain_tracking_open_settings, :update_domain_tracking_click_settings,
356
- :update_domain_tracking_unsubscribe_settings, :update_domain_dkim_authority,
357
- :update_domain_dkim_selector, :get_domain_stats
358
- enforces_api_version 'v4', :get_domain_keys, :activate_domain_key, :deactivate_domain_key,
359
- :list, :verify, :create, :update
261
+ :update_domain_tracking_unsubscribe_settings, :get_domain_stats
262
+ enforces_api_version 'v4', :list, :verify, :create, :update
360
263
  end
361
264
  end
@@ -11,9 +11,9 @@ module Mailgun
11
11
  method_names.each do |method_name|
12
12
  original_method = instance_method(method_name)
13
13
 
14
- define_method(method_name) do |*args, &block|
14
+ define_method(method_name) do |*args, **kwargs, &block|
15
15
  warn_unless_api_version(version)
16
- original_method.bind(self).call(*args, &block)
16
+ original_method.bind(self).call(*args, **kwargs, &block)
17
17
  end
18
18
  end
19
19
  end
@@ -22,9 +22,9 @@ module Mailgun
22
22
  method_names.each do |method_name|
23
23
  original_method = instance_method(method_name)
24
24
 
25
- define_method(method_name) do |*args, &block|
25
+ define_method(method_name) do |*args, **kwargs, &block|
26
26
  require_api_version(version)
27
- original_method.bind(self).call(*args, &block)
27
+ original_method.bind(self).call(*args, **kwargs, &block)
28
28
  end
29
29
  end
30
30
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # It's the version. Yeay!
4
4
  module Mailgun
5
- VERSION = '1.4.3'
5
+ VERSION = '1.4.4'
6
6
  end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mailgun
4
+ # A Mailgun::AccountWebhooks object is a simple CRUD interface to Account Mailgun Webhooks.
5
+ # Uses Mailgun
6
+ class AccountWebhooks
7
+ include ApiVersionChecker
8
+
9
+ # Public creates a new Mailgun::Webhooks instance.
10
+ # Defaults to Mailgun::Client
11
+ def initialize(client = Mailgun::Client.new(Mailgun.api_key, Mailgun.api_host || 'api.mailgun.net', 'v1'))
12
+ @client = client
13
+ end
14
+
15
+ # Public: List account-level webhooks
16
+ #
17
+ # webhook_ids - [String] Comma-separated list of webhook IDs to filter results. If specified,
18
+ # only webhooks with matching IDs will be returned.
19
+ #
20
+ # Retrieve all account-level webhooks or filter by specific webhook IDs.
21
+ # Returns webhook details including associated event types.
22
+ def list(webhook_ids = '')
23
+ res = @client.get('webhooks', webhook_ids: webhook_ids)
24
+ res.to_h['webhooks']
25
+ end
26
+
27
+ # Public: Create an account-level webhook
28
+ #
29
+ # description - [String] Description for the webhook
30
+ # event_types - [String] Event types to subscribe to. Use multiple times to specify multiple event types.
31
+ # Maximum of 3 unique URLs per event type.
32
+ # url - [String] URL for webhook to be sent to
33
+ #
34
+ # Returns the Unique identifier for the webhook
35
+ def create(description:, event_types:, url:)
36
+ res = @client.post('webhooks', { description: description, event_types: event_types, url: url })
37
+ res.to_h
38
+ end
39
+
40
+ # Public: Delete account-level webhooks
41
+ #
42
+ # webhook_ids - [String] Comma-separated list of webhook IDs to delete.
43
+ # If provided, only these specific webhooks will be deleted.
44
+ # all - [Boolean] The required String of the webhook action to delete
45
+ #
46
+ # Returns a Boolean of the success
47
+ def remove(webhook_ids = nil, all: false)
48
+ @client.delete('webhooks', { webhook_ids: webhook_ids, all: all }.compact).status == 204
49
+ end
50
+
51
+ # Public: Get account-level webhook by ID
52
+ #
53
+ # webhook_id - [String] The webhook ID to retrieve
54
+ #
55
+ # Returns webhook details including associated event types.
56
+ def get(webhook_id)
57
+ res = @client.get("webhooks/#{webhook_id}")
58
+ res.to_h
59
+ end
60
+
61
+ # Public: Update an account-level webhook
62
+ #
63
+ # description - [String] Description for the webhook
64
+ # event_types - [String] Event types to subscribe to. Use multiple times to specify multiple event types.
65
+ # Maximum of 3 unique URLs per event type.
66
+ # url - [String] URL for webhook to be sent to
67
+ #
68
+ # Returns a Boolean of the success
69
+ def update(webhook_id, description:, event_types:, url:)
70
+ @client.put("webhooks/#{webhook_id}",
71
+ { description: description, event_types: event_types, url: url }).status == 204
72
+ end
73
+
74
+ # Public: Delete account-level webhook by ID
75
+ #
76
+ # webhook_id - [String] The webhook ID to delete
77
+ #
78
+ # Returns a Boolean of the success
79
+ def remove_by_id(webhook_id)
80
+ @client.delete("webhooks/#{webhook_id}").status == 204
81
+ end
82
+
83
+ enforces_api_version 'v1', :list, :create, :remove, :get, :update, :remove_by_id
84
+ end
85
+ end