mastercard_core_sdk 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -8
- data/lib/mastercard_core_sdk/api/access_token_api.rb +10 -3
- data/lib/mastercard_core_sdk/api/request_token_api.rb +5 -2
- data/lib/mastercard_core_sdk/client/api_client.rb +20 -4
- data/lib/mastercard_core_sdk/core/api_config.rb +6 -1
- data/lib/mastercard_core_sdk/core/api_config_builder.rb +8 -8
- data/lib/mastercard_core_sdk/core/configuration.rb +33 -43
- data/lib/mastercard_core_sdk/core/mastercard_api_configuration.rb +3 -3
- data/lib/mastercard_core_sdk/core/mastercard_authenticator.rb +3 -0
- data/lib/mastercard_core_sdk/core/query_params.rb +9 -0
- data/lib/mastercard_core_sdk/core/request_response_logger.rb +6 -4
- data/lib/mastercard_core_sdk/core/service_request.rb +1 -0
- data/lib/mastercard_core_sdk/exceptions/error_handler.rb +17 -3
- data/lib/mastercard_core_sdk/interceptors/api_tracker_builder.rb +1 -1
- data/lib/mastercard_core_sdk/version.rb +1 -1
- data/lib/mastercard_core_sdk.rb +16 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70baa13d8f8b4684d46d10f1447d213c1b4f79a9
|
4
|
+
data.tar.gz: 536119e0d246a3e11b01ee4fd1bae3440c42a12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5564f83d9186449a34d4a5ae88ee6f3b565e46a26c81182c8a8d0be2e4b7279265036fbd83df813b46eff66921738f9f2f3defaaf4b8f4aac22280cf74008463
|
7
|
+
data.tar.gz: 952f07b940667b6bf92bdf58617cc0207535aafbc76388f9cf9c3a593ba909470bcae7994af374936b39a69edfee22e8576b6f4a404533ccbbd1433ef490cd1f
|
data/README.md
CHANGED
@@ -1,10 +1,18 @@
|
|
1
1
|
# MastercardCoreSdk
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
|
3
|
+
This is core SDK containing the configuration part for checkout SDK.
|
4
|
+
|
5
|
+
The merchant checkout SDK - MastercardMasterpassMerchant requires this MastercardCoreSdk as dependency for calling the checkout API services.
|
6
|
+
|
7
|
+
Features include :
|
8
|
+
|
9
|
+
• Exception Handler - Exception handling features help you deal with any unexpected or exceptional situations that occur while calling the API services.
|
10
|
+
|
11
|
+
• Serializers - Serializer handles the request and responses for the API services.
|
12
|
+
|
13
|
+
• ApiTracker - ApiTracker tracks the details of SDK from which API services are called.
|
14
|
+
|
15
|
+
For more information, refer [mastercard's developer site](https://developer.mastercard.com).
|
8
16
|
|
9
17
|
## Installation
|
10
18
|
|
@@ -23,11 +31,21 @@ Or install it yourself as:
|
|
23
31
|
$ gem install mastercard_core_sdk
|
24
32
|
|
25
33
|
## Usage
|
26
|
-
|
34
|
+
|
35
|
+
Customize default settings for the SDK through Configuration class using block :
|
27
36
|
|
28
37
|
```
|
29
38
|
require 'mastercard_core_sdk'
|
30
39
|
|
40
|
+
MastercardCoreSdk.configure do |config|
|
41
|
+
# Since version 1.3.0, verify_ssl is set default to true.
|
42
|
+
config.ssl_ca_cert = <path to the certificate file to verify the peer>
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Set configurations for private key and consumer key to call API:
|
47
|
+
|
48
|
+
```
|
31
49
|
MasterCardApiConfiguration.consumer_key = <Consumer Key>
|
32
50
|
MasterCardApiConfiguration.private_key = OpenSSL::PKCS12.new(File.open(<Path to P12 file>), <Password>).key
|
33
51
|
MasterCardApiConfiguration.sandbox = false #By default SANDBOX environment is set, Set sandbox to false to use Production environment
|
@@ -35,7 +53,6 @@ MasterCardApiConfiguration.sandbox = false #By default SANDBOX environment is s
|
|
35
53
|
request_token_response = RequestTokenApi.create(<URL>)
|
36
54
|
```
|
37
55
|
|
38
|
-
|
39
56
|
## Copyright
|
40
57
|
Copyright (c) 2016, MasterCard International Incorporated. See LICENSE for details.
|
41
58
|
|
@@ -5,12 +5,19 @@ require_relative '../models/access_token_response'
|
|
5
5
|
|
6
6
|
module MastercardCoreSdk
|
7
7
|
module Api
|
8
|
+
# Invokes AccessTokenApi.
|
8
9
|
class AccessTokenApi
|
9
10
|
include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions, MastercardCoreSdk::Tracker
|
10
11
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# This API call is used to exchange a request token for a long access token from the Masterpass service.
|
13
|
+
# For Pairing during checkout, this service will need to be called twice:
|
14
|
+
# 1. To request the checkout access token, which is used to retrieve checkout data.
|
15
|
+
# 2. To request the long access token, which is used to retrieve precheckout data.
|
16
|
+
# You will need the Request Token (oauth_token) and Verifier (oauth_verifier) from the merchant callback to get an access token.
|
17
|
+
#
|
18
|
+
# @note Since version 1.2.0, the method signature for {create} has changed.
|
19
|
+
# @param oauth_token the oauth token, which is used to retrieve checkout data.
|
20
|
+
# @param oauth_verifier the oauth verifier.
|
14
21
|
# @param api_config Optional ApiConfig object.
|
15
22
|
# @return [AccessTokenResponse]
|
16
23
|
def self.create(oauth_token, oauth_verifier, api_config = nil)
|
@@ -5,11 +5,14 @@ require_relative '../models/request_token_response'
|
|
5
5
|
|
6
6
|
module MastercardCoreSdk
|
7
7
|
module Api
|
8
|
+
# Invokes RequestTokenApi.
|
8
9
|
class RequestTokenApi
|
9
10
|
include MastercardCoreSdk::Core, MastercardCoreSdk::Client, MastercardCoreSdk::Exceptions, MastercardCoreSdk::Tracker
|
10
11
|
|
11
|
-
#
|
12
|
-
#
|
12
|
+
# This api call used to get the request token.This must be executed when a
|
13
|
+
# consumer clicks Buy with MasterPass or Connect with MasterPass buttons on your site/app.
|
14
|
+
#
|
15
|
+
# @param oauth_callback_url the oauth callback URL.
|
13
16
|
# @param api_config Optional ApiConfig object.
|
14
17
|
# @return [RequestTokenResponse]
|
15
18
|
def self.create(oauth_callback_url, api_config = nil)
|
@@ -14,6 +14,7 @@ require_relative '../converters/sdk_converter_factory'
|
|
14
14
|
|
15
15
|
module MastercardCoreSdk
|
16
16
|
module Client
|
17
|
+
# ApiClient is the base class to invoke the API. It is responsible for to convert all request and response according to the content type.
|
17
18
|
class ApiClient
|
18
19
|
include MastercardCoreSdk::Core, MastercardCoreSdk::Interceptors, MastercardCoreSdk::Converters, MastercardCoreSdk::Tracker
|
19
20
|
|
@@ -38,6 +39,7 @@ module MastercardCoreSdk
|
|
38
39
|
# Defines the object that would handle error for all the requests.
|
39
40
|
attr_accessor :error_handler
|
40
41
|
|
42
|
+
# Adds the authorization header, tracking headers and also logs the request/response.
|
41
43
|
attr_accessor :mastercard_authenticator
|
42
44
|
|
43
45
|
# Initializing Api Client with user-agent, configuration and default headers.
|
@@ -61,7 +63,7 @@ module MastercardCoreSdk
|
|
61
63
|
# @param service_request Service Request object
|
62
64
|
# @param http_method Specifies HTTP method
|
63
65
|
# @param return_type Specifies response return type model
|
64
|
-
# @return [String]
|
66
|
+
# @return [String] Response body
|
65
67
|
def call(path, service_request, http_method, return_type)
|
66
68
|
request = build_request(http_method, path, service_request, @api_config)
|
67
69
|
response_body, response_code, response_headers = call_api(request, return_type)
|
@@ -97,7 +99,14 @@ module MastercardCoreSdk
|
|
97
99
|
|
98
100
|
return data, response.code, response.headers
|
99
101
|
end
|
100
|
-
|
102
|
+
|
103
|
+
# Builds the HTTP request
|
104
|
+
#
|
105
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
106
|
+
# @param [String] path URL path (e.g. /account/new)
|
107
|
+
# @param [Object] request ServiceRequest object
|
108
|
+
# @param [Object] api_config ApiConfig object
|
109
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
101
110
|
def build_request(http_method, path, request, api_config)
|
102
111
|
url = build_request_url(path, request, api_config)
|
103
112
|
http_method = http_method.to_sym.downcase
|
@@ -106,14 +115,21 @@ module MastercardCoreSdk
|
|
106
115
|
header_params = @default_headers.merge(content_type_header || {}).merge(request.headers || {}).merge(api_config_header)
|
107
116
|
query_params = request.query_params || {}
|
108
117
|
|
118
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
119
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
120
|
+
|
109
121
|
req_opts = {
|
110
122
|
:method => http_method,
|
111
123
|
:headers => header_params,
|
112
124
|
:params => query_params,
|
113
125
|
:timeout => @config.timeout,
|
114
|
-
:ssl_verifypeer => @config.verify_ssl
|
126
|
+
:ssl_verifypeer => @config.verify_ssl,
|
127
|
+
:ssl_verifyhost => _verify_ssl_host,
|
128
|
+
:sslcert => @config.cert_file,
|
129
|
+
:sslkey => @config.key_file
|
115
130
|
}
|
116
|
-
|
131
|
+
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
132
|
+
|
117
133
|
if [:post, :patch, :put, :delete].include?(http_method)
|
118
134
|
req_body = build_request_body(request)
|
119
135
|
req_opts.update :body => req_body
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module MastercardCoreSdk
|
2
2
|
module Core
|
3
|
-
#
|
3
|
+
# Set environment details require to call mastercard api.
|
4
4
|
class ApiConfig
|
5
5
|
|
6
6
|
CONFIG_NAME_HEADER = "__config_name__"
|
7
7
|
attr_accessor :name, :consumer_key, :private_key, :host_url
|
8
8
|
|
9
|
+
# Constructs ApiConfig object.
|
10
|
+
# @param name the environment name. e.g. "SANDBOX"
|
11
|
+
# @param consumer_key the consumer key (Generated from mastercard developer zone).
|
12
|
+
# @param private_key the private key, to be fetched from the certificate.
|
13
|
+
# @param host_url the environment host url. e.g. "https://sandbox.api.mastercard.com"
|
9
14
|
def initialize(name, consumer_key, private_key, host_url)
|
10
15
|
@name = name
|
11
16
|
@consumer_key = consumer_key
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module MastercardCoreSdk
|
2
2
|
module Core
|
3
|
-
#
|
3
|
+
# Set environment details require to call mastercard api.
|
4
4
|
class ApiConfigBuilder
|
5
5
|
|
6
6
|
# Sets environment name
|
7
|
-
# @param name
|
7
|
+
# @param name the environment name. e.g. SANDBOX.
|
8
8
|
# @return [ApiConfigBuilder]
|
9
9
|
def name(name)
|
10
10
|
@name = name
|
11
11
|
return self
|
12
12
|
end
|
13
13
|
|
14
|
-
#
|
15
|
-
# @param consumer_key
|
14
|
+
# Set the consumer key generated from mastercard developer zone.
|
15
|
+
# @param consumer_key the consumer key (Generated from mastercard developer zone).
|
16
16
|
# @return [ApiConfigBuilder]
|
17
17
|
def consumer_key(consumer_key)
|
18
18
|
@consumer_key = consumer_key
|
@@ -20,22 +20,22 @@ module MastercardCoreSdk
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Sets private key
|
23
|
-
# @param private_key
|
23
|
+
# @param private_key the private key, to be fetched from the certificate.
|
24
24
|
# @return [ApiConfigBuilder]
|
25
25
|
def private_key(private_key)
|
26
26
|
@private_key = private_key
|
27
27
|
return self
|
28
28
|
end
|
29
29
|
|
30
|
-
# Sets host URL
|
31
|
-
# @param host_url
|
30
|
+
# Sets host URL for the environment(Sandbox/Production)
|
31
|
+
# @param host_url the environment host url. e.g. sandbox - "https://sandbox.api.mastercard.com"
|
32
32
|
# @return [ApiConfigBuilder]
|
33
33
|
def host_url(host_url)
|
34
34
|
@host_url = host_url
|
35
35
|
return self
|
36
36
|
end
|
37
37
|
|
38
|
-
#
|
38
|
+
# Build and register the ApiConfig object.
|
39
39
|
# @return [ApiConfig]
|
40
40
|
def build
|
41
41
|
api_config = ApiConfig.new(@name, @consumer_key, @private_key, @host_url)
|
@@ -2,16 +2,9 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module MastercardCoreSdk
|
4
4
|
module Core
|
5
|
+
# Represents a set of configuration settings.
|
5
6
|
class Configuration
|
6
|
-
|
7
|
-
attr_accessor :scheme
|
8
|
-
|
9
|
-
# Defines url host
|
10
|
-
attr_accessor :host
|
11
|
-
|
12
|
-
# Defines url base path
|
13
|
-
attr_accessor :base_path
|
14
|
-
|
7
|
+
|
15
8
|
# The time limit for HTTP request in seconds.
|
16
9
|
# Default to 0 (never times out).
|
17
10
|
attr_accessor :timeout
|
@@ -20,29 +13,47 @@ module MastercardCoreSdk
|
|
20
13
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
21
14
|
# Default to true.
|
22
15
|
#
|
23
|
-
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
24
|
-
#
|
16
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. Since version 1.3.0, it is default to true.
|
17
|
+
#
|
25
18
|
# @return [true, false]
|
26
19
|
attr_accessor :verify_ssl
|
20
|
+
|
21
|
+
### TLS/SSL setting
|
22
|
+
# Set this to false to skip verifying SSL host name.
|
23
|
+
# Default to true.
|
24
|
+
#
|
25
|
+
# @return [true, false]
|
26
|
+
# @since 1.3.0
|
27
|
+
attr_accessor :verify_ssl_host
|
28
|
+
|
29
|
+
# Set this to customize the certificate file to verify the peer.
|
30
|
+
#
|
31
|
+
# @return [String] the path to the certificate file
|
32
|
+
#
|
33
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
34
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
35
|
+
# @since 1.3.0
|
36
|
+
attr_accessor :ssl_ca_cert
|
37
|
+
|
38
|
+
# Client certificate file (for client certificate)
|
39
|
+
# @since 1.3.0
|
40
|
+
attr_accessor :cert_file
|
27
41
|
|
28
|
-
|
29
|
-
|
30
|
-
attr_accessor :
|
42
|
+
# Client private key file (for client certificate)
|
43
|
+
# @since 1.3.0
|
44
|
+
attr_accessor :key_file
|
31
45
|
|
32
46
|
attr_accessor :format, :user_agent, :default_headers
|
33
47
|
|
34
|
-
|
35
48
|
def initialize
|
36
|
-
@scheme = 'https'
|
37
|
-
@host = 'api.mastercard.com'
|
38
|
-
@base_path = ''
|
39
49
|
@timeout = 0
|
40
|
-
@verify_ssl =
|
41
|
-
@
|
42
|
-
@
|
50
|
+
@verify_ssl = true
|
51
|
+
@verify_ssl_host = true
|
52
|
+
@cert_file = nil
|
53
|
+
@key_file = nil
|
43
54
|
@format = ""
|
44
55
|
@default_headers = {}
|
45
|
-
|
56
|
+
|
46
57
|
yield(self) if block_given?
|
47
58
|
end
|
48
59
|
|
@@ -55,27 +66,6 @@ module MastercardCoreSdk
|
|
55
66
|
yield(self) if block_given?
|
56
67
|
end
|
57
68
|
|
58
|
-
def scheme=(scheme)
|
59
|
-
# remove :// from scheme
|
60
|
-
@scheme = scheme.sub(/:\/\//, '')
|
61
|
-
end
|
62
|
-
|
63
|
-
def host=(host)
|
64
|
-
# remove http(s):// and anything after a slash
|
65
|
-
@host = host.sub(/https?:\/\//, '').split('/').first
|
66
|
-
end
|
67
|
-
|
68
|
-
def base_path=(base_path)
|
69
|
-
# Add leading and trailing slashes to base_path
|
70
|
-
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
71
|
-
@base_path = "" if @base_path == "/"
|
72
|
-
end
|
73
|
-
|
74
|
-
def base_url
|
75
|
-
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
76
|
-
URI.encode(url)
|
77
|
-
end
|
78
|
-
|
79
69
|
end
|
80
70
|
end
|
81
71
|
end
|
@@ -4,7 +4,7 @@ require_relative 'api_config_builder'
|
|
4
4
|
|
5
5
|
module MastercardCoreSdk
|
6
6
|
module Core
|
7
|
-
# Setting MasterCard API configuration parameters for API calls
|
7
|
+
# Setting MasterCard API configuration parameters for API calls.
|
8
8
|
class MasterCardApiConfiguration
|
9
9
|
|
10
10
|
@@logger = Logging.logger[self]
|
@@ -52,8 +52,8 @@ module MastercardCoreSdk
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
#
|
56
|
-
# @param api_config
|
55
|
+
# Register the ApiConfig object.
|
56
|
+
# @param api_config the ApiConfig object.
|
57
57
|
def register_config(api_config)
|
58
58
|
self.configs.merge!({ api_config.name => api_config })
|
59
59
|
end
|
@@ -13,6 +13,9 @@ module MastercardCoreSdk
|
|
13
13
|
|
14
14
|
attr_accessor :api_tracker
|
15
15
|
|
16
|
+
# Hook into before a request runs.
|
17
|
+
#
|
18
|
+
# Adds the Authorization, API tracking and user-agent information to request header and logs the request/response information.
|
16
19
|
def authenticate
|
17
20
|
Typhoeus.before do |request|
|
18
21
|
SignatureBuilder.build(request)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module MastercardCoreSdk
|
2
2
|
module Core
|
3
|
+
# Container for query string data used to make service request url.
|
3
4
|
class QueryParams
|
4
5
|
|
5
6
|
attr_reader :params
|
@@ -8,12 +9,20 @@ module MastercardCoreSdk
|
|
8
9
|
@params = {}
|
9
10
|
end
|
10
11
|
|
12
|
+
# Merge query string parameters as key,value pair into params hash.
|
13
|
+
#
|
14
|
+
# @param key the params key.
|
15
|
+
# @param value the params value.
|
16
|
+
# @return [Object] the QueryParams object.
|
11
17
|
def add(key, value)
|
12
18
|
key = key.to_sym if key.is_a?(String)
|
13
19
|
@params.merge!({ key => value })
|
14
20
|
return self
|
15
21
|
end
|
16
22
|
|
23
|
+
# Gets the query string parameters.
|
24
|
+
#
|
25
|
+
# @return [Hash] the params hash containing key value pair.
|
17
26
|
def params
|
18
27
|
@params
|
19
28
|
end
|
@@ -4,14 +4,15 @@ require_relative '../exceptions/sdk_validation_error'
|
|
4
4
|
|
5
5
|
module MastercardCoreSdk
|
6
6
|
module Core
|
7
|
-
#
|
7
|
+
# Logs the request and response content.
|
8
8
|
class RequestResponseLogger
|
9
9
|
include MastercardCoreSdk::Exceptions
|
10
10
|
|
11
11
|
NEWLINE = "\n"
|
12
12
|
@@logger = Logging.logger[self]
|
13
13
|
|
14
|
-
#
|
14
|
+
# Log the request content.
|
15
|
+
# @param request the typhoeus request content to be logged.
|
15
16
|
def self.log_request(request)
|
16
17
|
if request
|
17
18
|
|
@@ -41,7 +42,8 @@ module MastercardCoreSdk
|
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
|
-
#
|
45
|
+
# Log the response content.
|
46
|
+
# @param response the typhoeus response content to be logged.
|
45
47
|
def self.log_response(response)
|
46
48
|
if response
|
47
49
|
|
@@ -85,7 +87,7 @@ module MastercardCoreSdk
|
|
85
87
|
end
|
86
88
|
end
|
87
89
|
|
88
|
-
|
90
|
+
private
|
89
91
|
|
90
92
|
def self.mask_data(response_body)
|
91
93
|
xmldoc = Nokogiri::XML(response_body)
|
@@ -26,6 +26,7 @@ module MastercardCoreSdk
|
|
26
26
|
ERR_INTERNAL = "INTERNAL_PROCESSING_ERROR"
|
27
27
|
SEP_COLON = "]: "
|
28
28
|
ERR_MSG_RES_PARSE = "Exception occurred during response parsing."
|
29
|
+
ERR_SRC_UNREACHABLE = "Unreachable"
|
29
30
|
|
30
31
|
# Raise custom error as per response error object.
|
31
32
|
# @param error_response The Typheous::Response object containing error details.
|
@@ -36,9 +37,16 @@ module MastercardCoreSdk
|
|
36
37
|
response_status_code = error_response.response_code
|
37
38
|
|
38
39
|
if response_body.empty?
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
if response_status_code == 0
|
41
|
+
response = error_response.response
|
42
|
+
errors = get_errors_object(response.return_message, response.return_code.to_s.upcase, ERR_SRC_UNREACHABLE) if response.return_message && response.return_code
|
43
|
+
@@logger.error "0 #{ERR_SRC_UNREACHABLE}"
|
44
|
+
raise SDKResponseError.new(:errors_object => errors, :status_code => 0)
|
45
|
+
else
|
46
|
+
errors = get_errors_object(ERR_DESC_EMPTY_RES, ERR_REASON_EMPTY_BODY_RES, ERR_SRC_UNKN)
|
47
|
+
@@logger.error "400 #{ERR_SRC_UNKN}"
|
48
|
+
raise SDKResponseError.new(:errors_object => errors, :status_code => 400)
|
49
|
+
end
|
42
50
|
|
43
51
|
elsif response_status_code == 200
|
44
52
|
# In some cases, response code is 200 and response body is empty.
|
@@ -82,6 +90,12 @@ module MastercardCoreSdk
|
|
82
90
|
|
83
91
|
private
|
84
92
|
|
93
|
+
# Return new Errors object with error description, reason code, source.
|
94
|
+
#
|
95
|
+
# @param description the error description.
|
96
|
+
# @param reason_code the error reason code.
|
97
|
+
# @param source the error source.
|
98
|
+
# @return [Errors] the Errors object.
|
85
99
|
def get_errors_object(description, reason_code, source)
|
86
100
|
error = Error.new(:description => description, :reason_code => reason_code, :source => source, :recoverable => false)
|
87
101
|
return Errors.new(:error => [error])
|
@@ -3,7 +3,7 @@ require_relative '../exceptions/sdk_validation_error'
|
|
3
3
|
|
4
4
|
module MastercardCoreSdk
|
5
5
|
module Interceptors
|
6
|
-
#
|
6
|
+
# Interceptor to set SDK tracking information in each request header.
|
7
7
|
class ApiTrackerBuilder
|
8
8
|
include MastercardCoreSdk::Core, MastercardCoreSdk::Exceptions
|
9
9
|
|
data/lib/mastercard_core_sdk.rb
CHANGED
@@ -61,5 +61,20 @@ require_relative 'mastercard_core_sdk/core/api_config_builder'
|
|
61
61
|
|
62
62
|
|
63
63
|
module MastercardCoreSdk
|
64
|
-
#
|
64
|
+
# Core Sdk
|
65
|
+
class << self
|
66
|
+
# Customize default settings for the SDK using block.
|
67
|
+
# MastercardCoreSdk.configure do |config|
|
68
|
+
# config.ssl_ca_cert = <path to the certificate file to verify the peer>
|
69
|
+
# end
|
70
|
+
# If no block given, return the default Configuration object.
|
71
|
+
# @since 1.3.0
|
72
|
+
def configure
|
73
|
+
if block_given?
|
74
|
+
yield(Core::Configuration.default)
|
75
|
+
else
|
76
|
+
Core::Configuration.default
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
65
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastercard_core_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MasterCard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|