Class: MastercardCoreSdk::Core::ApiConfigBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/mastercard_core_sdk/core/api_config_builder.rb

Overview

To be defined by application developer : environment name, consumer key, private key and host URL.

Instance Method Summary collapse

Instance Method Details

#buildApiConfig

Register the ApiConfig with MasterCardApiConfiguration.

Returns:



40
41
42
43
44
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 40

def build
  api_config = ApiConfig.new(@name, @consumer_key, @private_key, @host_url)
  MasterCardApiConfiguration.register_config(api_config)
  return api_config
end

#consumer_key(consumer_key) ⇒ ApiConfigBuilder

Sets consumer key

Parameters:

  • consumer_key

    Consumer key from developer’s site.

Returns:



17
18
19
20
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 17

def consumer_key(consumer_key)
  @consumer_key = consumer_key
  return self
end

#host_url(host_url) ⇒ ApiConfigBuilder

Sets host URL as per environment(Sandbox/Production)

Parameters:

  • host_url

    Host URL for the environment.

Returns:



33
34
35
36
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 33

def host_url(host_url)
  @host_url = host_url
  return self
end

#name(name) ⇒ ApiConfigBuilder

Sets environment name

Parameters:

  • name

    Environment.

Returns:



9
10
11
12
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 9

def name(name)
  @name = name
  return self
end

#private_key(private_key) ⇒ ApiConfigBuilder

Sets private key

Parameters:

  • private_key

    Private key from developer’s site.

Returns:



25
26
27
28
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 25

def private_key(private_key)
  @private_key = private_key
  return self
end