Class: Mailgun::Domain

Inherits:
Object show all
Defined in:
lib/mailgun/domain.rb

Overview

Interface to manage domains

Instance Method Summary collapse

Constructor Details

#initialize(mailgun) ⇒ Domain

Used internally, called from Mailgun::Base



6
7
8
# File 'lib/mailgun/domain.rb', line 6

def initialize(mailgun)
  @mailgun = mailgun
end

Instance Method Details

#create(domain, opts = {}) ⇒ Object

Add domain to account



21
22
23
24
# File 'lib/mailgun/domain.rb', line 21

def create(domain, opts = {})
  opts = {name: domain}.merge(opts)
  Mailgun.submit :post, domain_url, opts
end

#delete(domain) ⇒ Object

Remves a domain from account



27
28
29
# File 'lib/mailgun/domain.rb', line 27

def delete(domain)
  Mailgun.submit :delete, domain_url(domain)
end

#find(domain) ⇒ Object

Find domain by name



16
17
18
# File 'lib/mailgun/domain.rb', line 16

def find(domain)
  Mailgun.submit :get, domain_url(domain)
end

#list(options = {}) ⇒ Object

List all domains on the account



11
12
13
# File 'lib/mailgun/domain.rb', line 11

def list(options={})
  Mailgun.submit(:get, domain_url, options)["items"] || []
end

#verify(domain) ⇒ Object

Verifies a domain from account (Check DNS Records Now from Mailgun Web UI) The method is still in beta and you will need access from Mailgun to use it



34
35
36
# File 'lib/mailgun/domain.rb', line 34

def verify(domain)
  Mailgun.submit :put, "#{domain_url(domain)}/verify"
end