Class: MultiAuthSample::ApiKeyCredentials

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

Overview

Data class for ApiKeyCredentials. Data class for ApiKeyCredentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, api_key:) ⇒ ApiKeyCredentials

Returns a new instance of ApiKeyCredentials.

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
# File 'lib/multi_auth_sample/http/auth/api_key.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_key.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_key.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_key.rb', line 40

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

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