Class: CheckoutSdk::SdkAuthorization

Inherits:
Object
  • Object
show all
Defined in:
lib/checkout_sdk/sdk_authorization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform_type, credential) ⇒ SdkAuthorization

Returns a new instance of SdkAuthorization.

Parameters:

  • platform_type (String)
  • credential (String)


9
10
11
12
# File 'lib/checkout_sdk/sdk_authorization.rb', line 9

def initialize(platform_type, credential)
  @platform_type = platform_type
  @credential = credential
end

Instance Attribute Details

#credentialObject

Returns the value of attribute credential.



5
6
7
# File 'lib/checkout_sdk/sdk_authorization.rb', line 5

def credential
  @credential
end

#platform_typeObject

Returns the value of attribute platform_type.



5
6
7
# File 'lib/checkout_sdk/sdk_authorization.rb', line 5

def platform_type
  @platform_type
end

Instance Method Details

#authorization_headerObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/checkout_sdk/sdk_authorization.rb', line 14

def authorization_header
  case @platform_type
  when PlatformType::PREVIOUS, PlatformType::CUSTOM
    @credential
  when PlatformType::DEFAULT, PlatformType::OAUTH
    "Bearer #{@credential}"
  else
    raise CheckoutAuthorizationException, 'Invalid platform type'
  end
end