Class: Dnsimple::Client::CertificatesService

Inherits:
ClientService
  • Object
show all
Defined in:
lib/dnsimple/client/certificates_service.rb

Instance Attribute Summary

Attributes inherited from ClientService

#client

Instance Method Summary collapse

Instance Method Details

#configure(domain, certificate_id) ⇒ Certificate

Configures a certificate.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • certificate_id (Fixnum)

    The certificate ID.

Returns:

Raises:



74
75
76
77
78
# File 'lib/dnsimple/client/certificates_service.rb', line 74

def configure(domain, certificate_id)
  response = client.put("v1/domains/#{domain}/certificates/#{certificate_id}/configure")

  Certificate.new(response["certificate"])
end

#find(domain, certificate_id) ⇒ Certificate

Gets a certificate for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • certificate_id (Fixnum)

    The certificate ID.

Returns:

Raises:

See Also:



31
32
33
34
35
# File 'lib/dnsimple/client/certificates_service.rb', line 31

def find(domain, certificate_id)
  response = client.get("v1/domains/#{domain}/certificates/#{certificate_id}")

  Certificate.new(response["certificate"])
end

#list(domain, options = {}) ⇒ Array<Certificate>

Lists the certificates for a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • options (Hash) (defaults to: {})

Returns:

Raises:

See Also:



15
16
17
18
19
# File 'lib/dnsimple/client/certificates_service.rb', line 15

def list(domain, options = {})
  response = client.get("v1/domains/#{domain}/certificates", options)

  response.map { |r| Certificate.new(r["certificate"]) }
end

#purchase(domain, name, contact_id, options = {}) ⇒ Certificate

Purchases a certificate under the given domain with the given name.

The name will be appended to the domain name, and thus should only be the subdomain part.

Invoking this method DNSimple will immediately charge your credit card on file at DNSimple for the full certificate price.

For wildcard certificates an asterisk must appear in the name.

Examples:

Purchase a single-hostname certificate

Dnsimple::Certificate.purchase(domain, 'www', contact)

Purchase a wildcard certificate

Dnsimple::Certificate.purchase(domain, '*', contact)

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • name (String)

    The certificate name.

  • contact_id (Fixnum)

    The ID of the contact associated to the certificate.

Returns:

Raises:



59
60
61
62
63
64
# File 'lib/dnsimple/client/certificates_service.rb', line 59

def purchase(domain, name, contact_id, options = {})
  options  = Extra.deep_merge(options, { certificate: { name: name, contact_id: contact_id }})
  response = client.post("v1/domains/#{domain}/certificates", options)

  Certificate.new(response["certificate"])
end

#submit(domain, certificate_id, email) ⇒ Certificate

Submits a certificate for approval.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • certificate_id (Fixnum)

    The certificate ID.

  • email (Fixnum)

    The approver email.

Returns:

Raises:



89
90
91
92
93
94
# File 'lib/dnsimple/client/certificates_service.rb', line 89

def submit(domain, certificate_id, email)
  options = { certificate: { approver_email: email }}
  response = client.put("v1/domains/#{domain}/certificates/#{certificate_id}/submit", options)

  Certificate.new(response["certificate"])
end