Sha256: 806c491c5cfa20c5b81e4f4e15638cf54fcb34429272428e05a89d00fb7c0e8d

Contents?: true

Size: 1.43 KB

Versions: 13

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

class Acme::Client::Resources::Order
  attr_reader :url, :status, :contact, :finalize_url, :identifiers, :authorization_urls, :expires, :certificate_url

  def initialize(client, **arguments)
    @client = client
    assign_attributes(**arguments)
  end

  def reload
    assign_attributes(**@client.order(url: url).to_h)
    true
  end

  def authorizations
    @authorization_urls.map do |authorization_url|
      @client.authorization(url: authorization_url)
    end
  end

  def finalize(csr:)
    assign_attributes(**@client.finalize(url: finalize_url, csr: csr).to_h)
    true
  end

  def certificate(force_chain: nil)
    if certificate_url
      @client.certificate(url: certificate_url, force_chain: force_chain)
    else
      raise Acme::Client::Error::CertificateNotReady, 'No certificate_url to collect the order'
    end
  end

  def to_h
    {
      url: url,
      status: status,
      expires: expires,
      finalize_url: finalize_url,
      authorization_urls: authorization_urls,
      identifiers: identifiers,
      certificate_url: certificate_url
    }
  end

  private

  def assign_attributes(url:, status:, expires:, finalize_url:, authorization_urls:, identifiers:, certificate_url: nil)
    @url = url
    @status = status
    @expires = expires
    @finalize_url = finalize_url
    @authorization_urls = authorization_urls
    @identifiers = identifiers
    @certificate_url = certificate_url
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
acme-client-2.0.19 lib/acme/client/resources/order.rb
acme-client-2.0.18 lib/acme/client/resources/order.rb
acme-client-2.0.17 lib/acme/client/resources/order.rb
acme-client-2.0.16 lib/acme/client/resources/order.rb
acme-client-2.0.15 lib/acme/client/resources/order.rb
acme-client-2.0.14 lib/acme/client/resources/order.rb
acme-client-2.0.13 lib/acme/client/resources/order.rb
acme-client-2.0.12 lib/acme/client/resources/order.rb
acme-client-2.0.11 lib/acme/client/resources/order.rb
acme-client-2.0.10 lib/acme/client/resources/order.rb
acme-client-2.0.9 lib/acme/client/resources/order.rb
acme-client-2.0.8 lib/acme/client/resources/order.rb
acme-client-2.0.7 lib/acme/client/resources/order.rb