Class: ReportingSettlementResearchApi::CustomHeaderAuthenticationCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/reporting_settlement_research_api/http/auth/custom_header_authentication.rb

Overview

Data class for CustomHeaderAuthenticationCredentials. Data class for CustomHeaderAuthenticationCredentials.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorization:) ⇒ CustomHeaderAuthenticationCredentials

Returns a new instance of CustomHeaderAuthenticationCredentials.

Raises:

  • (ArgumentError)


30
31
32
33
34
# File 'lib/reporting_settlement_research_api/http/auth/custom_header_authentication.rb', line 30

def initialize(authorization:)
  raise ArgumentError, 'authorization cannot be nil' if authorization.nil?

  @authorization = authorization
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



28
29
30
# File 'lib/reporting_settlement_research_api/http/auth/custom_header_authentication.rb', line 28

def authorization
  @authorization
end

Class Method Details

.from_envObject



36
37
38
39
40
41
42
43
44
# File 'lib/reporting_settlement_research_api/http/auth/custom_header_authentication.rb', line 36

def self.from_env
  authorization = ENV['AUTHORIZATION']
  all_nil = [
    authorization
  ].all?(&:nil?)
  return nil if all_nil

  new(authorization: authorization)
end

Instance Method Details

#clone_with(authorization: nil) ⇒ Object



46
47
48
49
50
# File 'lib/reporting_settlement_research_api/http/auth/custom_header_authentication.rb', line 46

def clone_with(authorization: nil)
  authorization ||= self.authorization

  CustomHeaderAuthenticationCredentials.new(authorization: authorization)
end