Class: Mailgun::DomainKeys

Inherits:
Object
  • Object
show all
Includes:
ApiVersionChecker
Defined in:
lib/mailgun/domains/domain_keys.rb

Overview

A Mailgun::Domains object is a simple CRUD interface to Mailgun DomainsKeys. Uses Mailgun

Instance Method Summary collapse

Methods included from ApiVersionChecker

included

Constructor Details

#initialize(client = Mailgun::Client.new) ⇒ DomainKeys

Returns a new instance of DomainKeys.



9
10
11
# File 'lib/mailgun/domains/domain_keys.rb', line 9

def initialize(client = Mailgun::Client.new)
  @client = client
end

Instance Method Details

#activate_domain_key(domain, selector) ⇒ Object

Public: Activate a domain key for a specified authority and selector.

domain - [String] Name of the domain (ex. domain.com) selector - [String] The selector you want to activate for the domain key

Returns [Hash] with message key and autority + selector data



56
57
58
# File 'lib/mailgun/domains/domain_keys.rb', line 56

def activate_domain_key(domain, selector)
  @client.put("domains/#{domain}/keys/#{selector}/activate", {}).to_h
end

#create_domain_key(options = {}) ⇒ Object

Public: Create a domain key

options - [Hash] of

signing_domain  - [String] Name of the domain (ex. domain.com)
selector - [String] Selector to be used for the new domain key
bits - [Integer] Key size, can be 1024 or 2048
pem - [String] Private key PEM

Returns [Hash] with message key



35
36
37
# File 'lib/mailgun/domains/domain_keys.rb', line 35

def create_domain_key(options = {})
  @client.post('dkim/keys', options).to_h
end

#deactivate_domain_key(domain, selector) ⇒ Object

Public: Deactivate a domain key for a specified authority and selector

domain - [String] Name of the domain (ex. domain.com) selector - [String] The selector you want to activate for the domain key

Returns [Hash] with message key and autority + selector data



75
76
77
# File 'lib/mailgun/domains/domain_keys.rb', line 75

def deactivate_domain_key(domain, selector)
  @client.put("domains/#{domain}/keys/#{selector}/deactivate", {}).to_h
end

#delete_domain_key(options = {}) ⇒ Object

Public: Delete a domain key.

options - [Hash] of

signing_domain - [Integer] Name of the domain (ex. domain.com)
selector - [String] Name of the selector

Returns [Hash] with message key



46
47
48
# File 'lib/mailgun/domains/domain_keys.rb', line 46

def delete_domain_key(options = {})
  @client.delete('dkim/keys', options).to_h
end

#get_domain_keys(domain) ⇒ Object

Public: Lists the domain keys for a specified signing domain / authority

domain - [String] Name of the domain (ex. domain.com)

Returns [Hash] with domain keys data



65
66
67
# File 'lib/mailgun/domains/domain_keys.rb', line 65

def get_domain_keys(domain)
  @client.get("domains/#{domain}/keys").to_h
end

#list_domain_keys(options = {}) ⇒ Object

Public: List keys for all domains

options - [Hash] of

page - [String] Encoded paging information, provided via 'next', 'previous' links
limit - [Integer] Limits the number of items returned in a request
signing_domain  - [String] Filter by signing domain
selector - [String] Filter by selector

Returns [Hash] with message key



22
23
24
# File 'lib/mailgun/domains/domain_keys.rb', line 22

def list_domain_keys(options = {})
  @client.get('dkim/keys', options).to_h
end

#update_domain_dkim_authority(domain, options = {}) ⇒ Object

Public: Change the DKIM authority for a domain.

domain - [String] Name of the domain (ex. domain.com) options - [Hash] of

self  - [Boolean] true - the domain will be the DKIM authority for itself even
        if the root domain is registered on the same mailgun account

Returns [Hash] Information on the DKIM authority



87
88
89
# File 'lib/mailgun/domains/domain_keys.rb', line 87

def update_domain_dkim_authority(domain, options = {})
  @client.put("domains/#{domain}/dkim_authority", options).to_h
end

#update_domain_dkim_selector(domain, options = {}) ⇒ Object

Public: Update the DKIM selector for a domains

domain - [String] Name of the domain (ex. domain.com) options - [Hash] of

dkim_selector  - [String] change the DKIM selector for a domain.

Returns [Hash] with message key



98
99
100
# File 'lib/mailgun/domains/domain_keys.rb', line 98

def update_domain_dkim_selector(domain, options = {})
  @client.put("domains/#{domain}/dkim_selector", options).to_h
end