Class: MultiAuthSample::ApiHeaderCredentials

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_auth_sample/http/auth/api_header.rb

Overview

Data class for ApiHeaderCredentials. Data class for ApiHeaderCredentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, api_key:) ⇒ ApiHeaderCredentials

Returns a new instance of ApiHeaderCredentials.

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 32

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

  @token = token
  @api_key = api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



30
31
32
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 30

def api_key
  @api_key
end

#tokenObject (readonly)

Returns the value of attribute token.



30
31
32
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 30

def token
  @token
end

Instance Method Details

#clone_with(token: nil, api_key: nil) ⇒ Object



40
41
42
43
44
45
# File 'lib/multi_auth_sample/http/auth/api_header.rb', line 40

def clone_with(token: nil, api_key: nil)
  token ||= self.token
  api_key ||= self.api_key

  ApiHeaderCredentials.new(token: token, api_key: api_key)
end