Class: HerokuDnsimpleCert::DnsimpleCertificate

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku_dnsimple_cert/dnsimple_certificate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, account_id:, domain:, common_name:, client: nil) ⇒ DnsimpleCertificate

Returns a new instance of DnsimpleCertificate.



7
8
9
10
11
12
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 7

def initialize(token:, account_id:, domain:, common_name:, client: nil)
  @client = client || Dnsimple::Client.new(access_token: token)
  @account_id = .to_i
  @domain = domain
  @common_name = common_name
end

Instance Attribute Details

#account_idObject (readonly)

Returns the value of attribute account_id.



5
6
7
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5

def 
  @account_id
end

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5

def client
  @client
end

#common_nameObject (readonly)

Returns the value of attribute common_name.



5
6
7
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5

def common_name
  @common_name
end

#domainObject (readonly)

Returns the value of attribute domain.



5
6
7
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 5

def domain
  @domain
end

Instance Method Details

#certificateObject



29
30
31
32
33
34
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 29

def certificate
  @certificate ||= client
    .certificates.certificates(, domain)
    .data.select { |certificate| certificate_for_common_name?(certificate) }
    .first
end

#certificate_chainObject



14
15
16
17
18
19
20
21
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 14

def certificate_chain
  @certificate_key ||= begin
    cert = client.certificates
      .download_certificate(, domain, certificate.id).data

    [cert.server, cert.root, cert.chain].join("\n")
  end
end

#private_keyObject



23
24
25
26
27
# File 'lib/heroku_dnsimple_cert/dnsimple_certificate.rb', line 23

def private_key
  @certificate_private_key ||= client.certificates
    .certificate_private_key(, domain, certificate.id)
    .data.private_key
end