class Acme::Client::Resources::Challenges::Base

def assign_attributes(attributes)

def assign_attributes(attributes)
  @status = attributes.fetch('status', 'pending')
  @uri = attributes.fetch('uri')
  @token = attributes.fetch('token')
end

def authorization_key

def authorization_key
  "#{token}.#{crypto.thumbprint}"
end

def challenge_type

def challenge_type
  self.class::CHALLENGE_TYPE
end

def crypto

def crypto
  @crypto ||= Acme::Client::Crypto.new(@client.private_key)
end

def initialize(client, attributes)

def initialize(client, attributes)
  @client = client
  assign_attributes(attributes)
end

def request_verification

def request_verification
  response = @client.connection.post(@uri, resource: 'challenge', type: challenge_type, keyAuthorization: authorization_key)
  response.success?
end

def to_h

def to_h
  { 'token' => token, 'uri' => uri, 'type' => challenge_type }
end

def verify_status

def verify_status
  response = @client.connection.get(@uri)
  assign_attributes(response.body)
  @error = response.body['error']
  status
end