Sha256: f23fbe8a677f67b0cfad825eda41c5cba5543f8a7907cdd4d90abfb39574d738

Contents?: true

Size: 951 Bytes

Versions: 5

Compression:

Stored size: 951 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

5 entries across 5 versions & 1 rubygems

Version Path
acme-client-2.0.6 lib/acme/client/resources/account.rb
acme-client-2.0.5 lib/acme/client/resources/account.rb
acme-client-2.0.4 lib/acme/client/resources/account.rb
acme-client-2.0.3 lib/acme/client/resources/account.rb
acme-client-2.0.2 lib/acme/client/resources/account.rb