Sha256: 17db9bf1346a30fc5ef54cb7d6226d6b356eb14275d0b08a69bd315b0c530f86

Contents?: true

Size: 903 Bytes

Versions: 13

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

class Acme::Client::Resources::Challenges::Base
  attr_reader :status, :url, :token, :error

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

  def challenge_type
    self.class::CHALLENGE_TYPE
  end

  def key_authorization
    "#{token}.#{@client.jwk.thumbprint}"
  end

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

  def request_validation
    assign_attributes(**send_challenge_validation(
      url: url
    ))
    true
  end

  def to_h
    { status: status, url: url, token: token, error: error }
  end

  private

  def send_challenge_validation(url:)
    @client.request_challenge_validation(
      url: url
    ).to_h
  end

  def assign_attributes(status:, url:, token:, error: nil)
    @status = status
    @url = url
    @token = token
    @error = error
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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