class ZeroSSL::Client

Public Class Methods

new() click to toggle source
# File lib/zerossl/client.rb, line 3
def initialize
  @config = ZeroSSL::Setup.config
  @http   = HTTP.new
end

Public Instance Methods

certificates() click to toggle source
# File lib/zerossl/client.rb, line 8
def certificates
  @http.get('certificates')
end
create(opts = {}) click to toggle source
# File lib/zerossl/client.rb, line 12
def create(opts = {})
  attributes = %w[
    certificate_domains
    certificate_validity_days
    certificate_csr
  ]

  options = opts.transform_keys(&:to_s).slice(*attributes)
  domains = options['certificate_domains']

  if domains.is_a?(Array)
    options['certificate_domains'] = domains.join(',')
  end
  @http.post('certificates', options)
end
download(id) click to toggle source
# File lib/zerossl/client.rb, line 37
def download(id)
  @http.get("certificates/#{id}/download/return")&.body
end
status(id) click to toggle source
# File lib/zerossl/client.rb, line 33
def status(id)
  !!@http.get("certificates/#{id}/status")&.body['validation_completed']
end
verify(id, validation_method) click to toggle source
# File lib/zerossl/client.rb, line 28
def verify(id, validation_method)
  opts = { validation_method: validation_method }
  @http.post("certificates/#{id}/challenges", opts)
end