Sha256: 8e69cefa503c634c4fa3819dfec2131fef43466662c94a84c8f1347b50c76527

Contents?: true

Size: 897 Bytes

Versions: 22

Compression:

Stored size: 897 Bytes

Contents

class Acme::Client::Resources::Registration
  attr_reader :id, :key, :contact, :uri, :next_uri, :recover_uri, :term_of_service_uri

  def initialize(client, response)
    @client = client
    @uri = response.headers['location']
    assign_links(response.headers['Link'])
    assign_attributes(response.body)
  end

  def get_terms
    return unless @term_of_service_uri

    @client.connection.get(@term_of_service_uri).body
  end

  def agree_terms
    return true unless @term_of_service_uri

    response = @client.connection.post(@uri, resource: 'reg', agreement: @term_of_service_uri)
    response.success?
  end

  private

  def assign_links(links)
    @next_uri = links['next']
    @recover_uri = links['recover']
    @term_of_service_uri = links['terms-of-service']
  end

  def assign_attributes(body)
    @id = body['id']
    @key = body['key']
    @contact = body['contact']
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
acme-client-1.0.0 lib/acme/client/resources/registration.rb
acme-client-0.6.3 lib/acme/client/resources/registration.rb
acme-client-0.6.2 lib/acme/client/resources/registration.rb
acme-client-0.6.1 lib/acme/client/resources/registration.rb
acme-client-0.6.0 lib/acme/client/resources/registration.rb
acme-client-0.5.5 lib/acme/client/resources/registration.rb
acme-client-0.5.4 lib/acme/client/resources/registration.rb
acme-client-0.5.3 lib/acme/client/resources/registration.rb
acme-client-0.5.2 lib/acme/client/resources/registration.rb
acme-client-0.5.1 lib/acme/client/resources/registration.rb
acme-client-0.5.0 lib/acme/client/resources/registration.rb
leap_cli-1.9 vendor/acme-client/lib/acme/client/resources/registration.rb
acme-client-0.4.1 lib/acme/client/resources/registration.rb
acme-client-0.4.0 lib/acme/client/resources/registration.rb
acme-client-0.3.7 lib/acme/client/resources/registration.rb
acme-client-0.3.6 lib/acme/client/resources/registration.rb
acme-client-0.3.5 lib/acme/client/resources/registration.rb
acme-client-0.3.4 lib/acme/client/resources/registration.rb
acme-client-0.3.3 lib/acme/client/resources/registration.rb
acme-client-0.3.2 lib/acme/client/resources/registration.rb