class Acme::Client::Resources::Authorization

Attributes

domain[R]
expires[R]
identifier[R]
status[R]
url[R]
wildcard[R]

Public Class Methods

new(client, **arguments) click to toggle source
# File lib/acme/client/resources/authorization.rb, line 6
def initialize(client, **arguments)
  @client = client
  assign_attributes(**arguments)
end

Public Instance Methods

challenges() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 21
def challenges
  @challenges.map do |challenge|
    initialize_challenge(challenge)
  end
end
deactivate() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 11
def deactivate
  assign_attributes(**@client.deactivate_authorization(url: url).to_h)
  true
end
dns()
Alias for: dns01
dns01() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 34
def dns01
  @dns01 ||= challenges.find { |challenge|
    challenge.is_a?(Acme::Client::Resources::Challenges::DNS01)
  }
end
Also aliased as: dns
http()
Alias for: http01
http01() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 27
def http01
  @http01 ||= challenges.find { |challenge|
    challenge.is_a?(Acme::Client::Resources::Challenges::HTTP01)
  }
end
Also aliased as: http
reload() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 16
def reload
  assign_attributes(**@client.authorization(url: url).to_h)
  true
end
to_h() click to toggle source
# File lib/acme/client/resources/authorization.rb, line 41
def to_h
  {
    url: url,
    identifier: identifier,
    status: status,
    expires: expires,
    challenges: @challenges,
    wildcard: wildcard
  }
end

Private Instance Methods

assign_attributes(url:, status:, expires:, challenges:, identifier:, wildcard: false) click to toggle source
# File lib/acme/client/resources/authorization.rb, line 65
def assign_attributes(url:, status:, expires:, challenges:, identifier:, wildcard: false)
  @url = url
  @identifier = identifier
  @domain = identifier.fetch('value')
  @status = status
  @expires = expires
  @challenges = challenges
  @wildcard = wildcard
end
initialize_challenge(attributes) click to toggle source
# File lib/acme/client/resources/authorization.rb, line 54
def initialize_challenge(attributes)
  arguments = {
    type: attributes.fetch('type'),
    status: attributes.fetch('status'),
    url: attributes.fetch('url'),
    token: attributes.fetch('token', nil),
    error: attributes['error']
  }
  Acme::Client::Resources::Challenges.new(@client, **arguments)
end