Class: CheckoutSdk::Previous::PreviousStaticKeysSdkCredentials

Inherits:
SdkCredentials
  • Object
show all
Defined in:
lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(secret_key, public_key) ⇒ PreviousStaticKeysSdkCredentials

Parameters:

  • secret_key (String)
  • public_key (String)


15
16
17
18
# File 'lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb', line 15

def initialize(secret_key, public_key)
  @secret_key = secret_key
  @public_key = public_key
end

Instance Attribute Details

#public_keyString

Returns:

  • (String)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb', line 9

class PreviousStaticKeysSdkCredentials < SdkCredentials
  attr_reader :secret_key, :public_key

  # @param [String] secret_key
  # @param [String] public_key
  # @return [PreviousStaticKeysSdkCredentials]
  def initialize(secret_key, public_key)
    @secret_key = secret_key
    @public_key = public_key
  end

  # @param [String] authorization_type
  # @return [CheckoutSdk::SdkAuthorization]
  def get_authorization(authorization_type)
    case authorization_type
    when AuthorizationType::SECRET_KEY, AuthorizationType::SECRET_KEY_OR_OAUTH
      raise CheckoutAuthorizationException.invalid_key AuthorizationType::SECRET_KEY if secret_key.nil?

      SdkAuthorization.new(PlatformType::PREVIOUS, @secret_key)
    when AuthorizationType::PUBLIC_KEY, AuthorizationType::PUBLIC_KEY_OR_OAUTH
      raise CheckoutAuthorizationException.invalid_key AuthorizationType::PUBLIC_KEY if public_key.nil?

      SdkAuthorization.new(PlatformType::PREVIOUS, @public_key)
    else
      raise CheckoutAuthorizationException.invalid_authorization authorization_type
    end
  end
end

#secret_keyString

Returns:

  • (String)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb', line 9

class PreviousStaticKeysSdkCredentials < SdkCredentials
  attr_reader :secret_key, :public_key

  # @param [String] secret_key
  # @param [String] public_key
  # @return [PreviousStaticKeysSdkCredentials]
  def initialize(secret_key, public_key)
    @secret_key = secret_key
    @public_key = public_key
  end

  # @param [String] authorization_type
  # @return [CheckoutSdk::SdkAuthorization]
  def get_authorization(authorization_type)
    case authorization_type
    when AuthorizationType::SECRET_KEY, AuthorizationType::SECRET_KEY_OR_OAUTH
      raise CheckoutAuthorizationException.invalid_key AuthorizationType::SECRET_KEY if secret_key.nil?

      SdkAuthorization.new(PlatformType::PREVIOUS, @secret_key)
    when AuthorizationType::PUBLIC_KEY, AuthorizationType::PUBLIC_KEY_OR_OAUTH
      raise CheckoutAuthorizationException.invalid_key AuthorizationType::PUBLIC_KEY if public_key.nil?

      SdkAuthorization.new(PlatformType::PREVIOUS, @public_key)
    else
      raise CheckoutAuthorizationException.invalid_authorization authorization_type
    end
  end
end

Instance Method Details

#get_authorization(authorization_type) ⇒ CheckoutSdk::SdkAuthorization

Parameters:

  • authorization_type (String)

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/checkout_sdk/previous/previous_static_keys_sdk_credentials.rb', line 22

def get_authorization(authorization_type)
  case authorization_type
  when AuthorizationType::SECRET_KEY, AuthorizationType::SECRET_KEY_OR_OAUTH
    raise CheckoutAuthorizationException.invalid_key AuthorizationType::SECRET_KEY if secret_key.nil?

    SdkAuthorization.new(PlatformType::PREVIOUS, @secret_key)
  when AuthorizationType::PUBLIC_KEY, AuthorizationType::PUBLIC_KEY_OR_OAUTH
    raise CheckoutAuthorizationException.invalid_key AuthorizationType::PUBLIC_KEY if public_key.nil?

    SdkAuthorization.new(PlatformType::PREVIOUS, @public_key)
  else
    raise CheckoutAuthorizationException.invalid_authorization authorization_type
  end
end