Sha256: a6de00fbe4aadd755d2dfb118551d77e1f0150479f602256826b731d809ef600

Contents?: true

Size: 953 Bytes

Versions: 13

Compression:

Stored size: 953 Bytes

Contents

# frozen_string_literal: true

class Acme::Client::Resources::Account
  attr_reader :url, :status, :contact, :term_of_service, :orders_url

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

  def kid
    url
  end

  def update(contact: nil, terms_of_service_agreed: nil)
    assign_attributes(**@client.account_update(
      contact: contact, terms_of_service_agreed: term_of_service
    ).to_h)
    true
  end

  def deactivate
    assign_attributes(**@client.account_deactivate.to_h)
    true
  end

  def reload
    assign_attributes(**@client.account.to_h)
    true
  end

  def to_h
    {
      url: url,
      term_of_service: term_of_service,
      status: status,
      contact: contact
    }
  end

  private

  def assign_attributes(url:, term_of_service:, status:, contact:)
    @url = url
    @term_of_service = term_of_service
    @status = status
    @contact = Array(contact)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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