Class: MastercardCoreSdk::Core::ApiConfigBuilder

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

Overview

Set environment details require to call mastercard api.

Instance Method Summary collapse

Instance Method Details

#additional_properties(additional_properties = {}) ⇒ ApiConfigBuilder

Parameters:

  • additional_properties (Hash) (defaults to: {})

    the plugin details as hash with plugin_version as key.

Returns:



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

def additional_properties(additional_properties = {})
  @additional_properties= additional_properties
  return self
end

#buildApiConfig

Register the ApiConfig with MasterCardApiConfiguration.

Returns:



48
49
50
51
52
# File 'lib/mastercard_core_sdk/core/api_config_builder.rb', line 48

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

#consumer_key(consumer_key) ⇒ ApiConfigBuilder

Set the consumer key generated from mastercard developer zone.

Parameters:

  • consumer_key

    the consumer key (Generated from mastercard developer zone).

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 for the environment(Sandbox/Production)

Parameters:

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

    the environment name. e.g. SANDBOX.

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

    the private key, to be fetched from the certificate.

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