mailgun-ruby 1.4.3 → 1.4.5
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_changelog_generator +1 -0
- data/CHANGELOG.md +705 -71
- data/README.md +3 -1
- data/docs/AccountWebhooks.md +55 -0
- data/docs/ApiKeys.md +65 -0
- data/docs/DomainKeys.md +49 -0
- data/docs/Domains.md +0 -28
- data/docs/Webhooks.md +28 -5
- data/lib/mailgun/api_keys/api_keys.rb +65 -0
- data/lib/mailgun/client.rb +2 -2
- data/lib/mailgun/domains/domain_keys.rb +107 -0
- data/lib/mailgun/domains/domains.rb +3 -100
- data/lib/mailgun/helpers/api_version_checker.rb +4 -4
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun/webhooks/account_webhooks.rb +85 -0
- data/lib/mailgun/webhooks/webhooks.rb +115 -34
- data/lib/mailgun.rb +1 -0
- data/spec/integration/account_webhooks_spec.rb +57 -0
- data/spec/integration/api_keys_spec.rb +50 -0
- data/spec/integration/domain_keys_spec.rb +124 -0
- data/spec/integration/domains_spec.rb +0 -113
- data/spec/integration/webhook_spec.rb +53 -34
- data/spec/spec_helper.rb +3 -0
- data/spec/unit/client_spec.rb +24 -0
- data/spec/unit/webhooks_spec.rb +121 -0
- data/vcr_cassettes/account_webhooks.yml +269 -0
- data/vcr_cassettes/api_keys.yml +212 -0
- data/vcr_cassettes/domains.yml +1 -1
- data/vcr_cassettes/webhooks_v4.yml +275 -0
- metadata +19 -1
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.
|
|
22
|
+
gem 'mailgun-ruby', '~>1.4.5'
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Usage
|
|
@@ -186,6 +186,8 @@ 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)
|
|
190
|
+
- [API Keys](docs/ApiKeys.md)
|
|
189
191
|
- [Events](docs/Events.md)
|
|
190
192
|
- [Snippets](docs/Snippets.md)
|
|
191
193
|
- [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
|
data/docs/ApiKeys.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Mailgun - API Keys
|
|
2
|
+
====================
|
|
3
|
+
|
|
4
|
+
This is the Mailgun Ruby *API Keys* 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 - API Keys
|
|
10
|
+
-----------------------
|
|
11
|
+
|
|
12
|
+
```ruby
|
|
13
|
+
# First, instantiate the Mailgun Client with your API key
|
|
14
|
+
mg_client = Mailgun::Client.new('your-api-key', 'api.mailgun.net', 'v1')
|
|
15
|
+
api_keys = Mailgun::ApiKeys.new(mg_client)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
API Keys methods:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
# List API keys
|
|
22
|
+
api_keys.list
|
|
23
|
+
|
|
24
|
+
# List API keys filtered by kind and domain
|
|
25
|
+
api_keys.list(kind: 'domain', domain_name: 'my.perfect.domain')
|
|
26
|
+
|
|
27
|
+
# Create a user API key
|
|
28
|
+
api_keys.create(
|
|
29
|
+
kind: 'user',
|
|
30
|
+
role: 'admin',
|
|
31
|
+
description: 'desc'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# Create a sending key for a domain, expiring in 1 day
|
|
35
|
+
api_keys.create(
|
|
36
|
+
kind: 'domain',
|
|
37
|
+
domain_name: 'my.perfect.domain',
|
|
38
|
+
role: 'sending',
|
|
39
|
+
expiration: 86_400
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Delete an API key
|
|
43
|
+
api_keys.remove('key-id')
|
|
44
|
+
|
|
45
|
+
# Regenerate the public API key
|
|
46
|
+
api_keys.regenerate
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Supported `create` options:
|
|
50
|
+
|
|
51
|
+
| Option | Description |
|
|
52
|
+
|---------------|-------------|
|
|
53
|
+
| `kind` | Type of API key: `domain`, `user` or `web`. Defaults to `user` |
|
|
54
|
+
| `role` | Key role: `admin`, `basic`, `sending` (for `domain` keys) or `developer` |
|
|
55
|
+
| `domain_name` | Domain to associate with the key, for `domain` keys |
|
|
56
|
+
| `description` | Key description |
|
|
57
|
+
| `expiration` | Key lifetime in seconds, must be greater than 0 if set |
|
|
58
|
+
| `user_id` | API key user's ID, should be provided for `web` keys |
|
|
59
|
+
| `user_name` | API key user's name |
|
|
60
|
+
| `email` | API key user's email address, should be provided for `web` keys |
|
|
61
|
+
|
|
62
|
+
More Documentation
|
|
63
|
+
------------------
|
|
64
|
+
See the official [Mailgun API Keys Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/keys)
|
|
65
|
+
for more information
|
data/docs/DomainKeys.md
ADDED
|
@@ -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
|
@@ -18,25 +18,48 @@ hook = Mailgun::Webhooks.new(mg_client)
|
|
|
18
18
|
hook.list 'my.perfect.domain'
|
|
19
19
|
|
|
20
20
|
# View a single webhook detail
|
|
21
|
-
hook.info 'my.perfect.domain', '
|
|
21
|
+
hook.info 'my.perfect.domain', 'delivered'
|
|
22
22
|
|
|
23
23
|
# Add a single url for all webhooks
|
|
24
24
|
hook.create_all 'my.perfect.domain', 'https://the.webhook.url/'
|
|
25
25
|
|
|
26
26
|
# Add a url for a specific webhook
|
|
27
|
-
hook.create 'my.perfect.domain', '
|
|
27
|
+
hook.create 'my.perfect.domain', 'delivered', 'https://the.webhook.url/'
|
|
28
28
|
|
|
29
29
|
# Update the url for a specific webhook
|
|
30
|
-
hook.update 'my.perfect.domain', '
|
|
30
|
+
hook.update 'my.perfect.domain', 'delivered', 'https://the.webhook.url/'
|
|
31
31
|
|
|
32
32
|
# Remove a url for a specific webhook
|
|
33
|
-
hook.remove 'my.perfect.domain', '
|
|
33
|
+
hook.remove 'my.perfect.domain', 'delivered'
|
|
34
34
|
|
|
35
35
|
# Remove all webhooks for a domain
|
|
36
36
|
hook.remove_all 'my.perfect.domain'
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
Usage - Webhooks (v4)
|
|
40
|
+
-----------------------
|
|
41
|
+
|
|
42
|
+
The v4 endpoints work with a URL across multiple event types in a single request.
|
|
43
|
+
They require a client configured for the `v4` API.
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
mg_client = Mailgun::Client.new('your-api-key', 'api.mailgun.net', 'v4')
|
|
47
|
+
hook = Mailgun::Webhooks.new(mg_client)
|
|
48
|
+
|
|
49
|
+
# Associate a url with one or more event types
|
|
50
|
+
hook.create_v4 'my.perfect.domain', url: 'https://the.webhook.url/', event_types: %w[delivered opened]
|
|
51
|
+
|
|
52
|
+
# Replace the event types associated with a url
|
|
53
|
+
hook.update_v4 'my.perfect.domain', url: 'https://the.webhook.url/', event_types: %w[clicked]
|
|
54
|
+
|
|
55
|
+
# Remove one or more urls from all event types they are associated with
|
|
56
|
+
hook.remove_v4 'my.perfect.domain', url: 'https://the.webhook.url/'
|
|
57
|
+
hook.remove_v4 'my.perfect.domain', url: ['https://the.webhook.url/', 'https://another.webhook.url/']
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Each v4 method returns a Hash of the domain's webhooks keyed by event type.
|
|
61
|
+
|
|
39
62
|
More Documentation
|
|
40
63
|
------------------
|
|
41
|
-
See the official [Mailgun
|
|
64
|
+
See the official [Mailgun Webhooks Docs](https://documentation.mailgun.com/docs/mailgun/api-reference/send/mailgun/domain-webhooks)
|
|
42
65
|
for more information
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Mailgun
|
|
4
|
+
# A Mailgun::ApiKeys object is a simple CRUD interface to Mailgun Api Keys.
|
|
5
|
+
# Uses Mailgun
|
|
6
|
+
class ApiKeys
|
|
7
|
+
include ApiVersionChecker
|
|
8
|
+
|
|
9
|
+
# Public creates a new Mailgun::ApiKeys 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 Mailgun API keys
|
|
16
|
+
#
|
|
17
|
+
# options - [Hash] of
|
|
18
|
+
# domain_name - [String] Domain name filter for domain keys
|
|
19
|
+
# kind - [String] Key kind filter ('domain', 'user', or 'web')
|
|
20
|
+
#
|
|
21
|
+
# Retrieve filtered api keys.
|
|
22
|
+
def list(options = {})
|
|
23
|
+
res = @client.get('keys', options)
|
|
24
|
+
res.to_h['items']
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Public: Create Mailgun API key
|
|
28
|
+
|
|
29
|
+
# options - [Hash] of
|
|
30
|
+
# domain_name - [String] Web domain to associate with the key, for keys of 'domain' kind
|
|
31
|
+
# kind - [String] Type of API key ('domain', 'user', or 'web'). Defaults to 'user' if not provided.
|
|
32
|
+
# description - [String] Key description
|
|
33
|
+
# expiration - [String] Key lifetime in seconds, must be greater than 0 if set
|
|
34
|
+
# role - [String] Key role ('admin', 'basic' [use in place of analyst],
|
|
35
|
+
# 'sending' [use with keys of domain kind], or 'developer')
|
|
36
|
+
# user_id - [String] API Key user's string user ID; should be provided for all keys of 'web' kind
|
|
37
|
+
# user_name - [String] API Key user's name
|
|
38
|
+
# email - [String] API Key user's email address; should be provided for all keys of 'web' kind
|
|
39
|
+
#
|
|
40
|
+
# Returns the Api Key object
|
|
41
|
+
def create(options = {})
|
|
42
|
+
res = @client.post('keys', options)
|
|
43
|
+
res.to_h['key']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Public: Delete Mailgun API key
|
|
47
|
+
#
|
|
48
|
+
# key_id - [String] The Key ID generated by Mailgun on key creation
|
|
49
|
+
#
|
|
50
|
+
# Returns a Boolean of the success
|
|
51
|
+
def remove(key_id)
|
|
52
|
+
@client.delete("keys/#{key_id}").status == 200
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Public: Regenerate Mailgun Public API key
|
|
56
|
+
#
|
|
57
|
+
# Returns new Mailgun Public API key.
|
|
58
|
+
def regenerate
|
|
59
|
+
res = @client.post('keys/public', {})
|
|
60
|
+
res.to_h['key']
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
enforces_api_version 'v1', :list, :create, :remove, :regenerate
|
|
64
|
+
end
|
|
65
|
+
end
|
data/lib/mailgun/client.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Mailgun
|
|
|
13
13
|
api_host = Mailgun.api_host || 'api.mailgun.net',
|
|
14
14
|
api_version = Mailgun.api_version || 'v3',
|
|
15
15
|
ssl = true,
|
|
16
|
-
test_mode =
|
|
16
|
+
test_mode = Mailgun.test_mode ? true : false,
|
|
17
17
|
timeout = nil,
|
|
18
18
|
proxy_url = Mailgun.proxy_url)
|
|
19
19
|
endpoint = endpoint_generator(api_host, api_version, ssl)
|
|
@@ -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
|
|
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', :
|
|
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, :
|
|
357
|
-
|
|
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
|
data/lib/mailgun/version.rb
CHANGED