Class: MastercardCoreSdk::Core::Configuration
- Inherits:
-
Object
- Object
- MastercardCoreSdk::Core::Configuration
- Defined in:
- lib/mastercard_core_sdk/core/configuration.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
Defines url base path.
-
#default_headers ⇒ Object
Returns the value of attribute default_headers.
-
#force_ending_format ⇒ Object
Returns the value of attribute force_ending_format.
-
#format ⇒ Object
Returns the value of attribute format.
-
#host ⇒ Object
Defines url host.
-
#inject_format ⇒ Object
Returns the value of attribute inject_format.
-
#scheme ⇒ Object
Defines url scheme.
-
#timeout ⇒ Object
The time limit for HTTP request in seconds.
-
#user_agent ⇒ Object
Returns the value of attribute user_agent.
-
#verify_ssl ⇒ true, false
TLS/SSL Set this to false to skip verifying SSL certificate when calling API from https server.
Class Method Summary collapse
-
.default ⇒ Object
The default Configuration object.
Instance Method Summary collapse
- #base_url ⇒ Object
- #configure {|_self| ... } ⇒ Object
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 35 def initialize @scheme = 'https' @host = 'api.mastercard.com' @base_path = '' @timeout = 0 @verify_ssl = false #To be set to true for production @inject_format = false @force_ending_format = false @format = "" @default_headers = {} yield(self) if block_given? end |
Instance Attribute Details
#base_path ⇒ Object
Defines url base path
13 14 15 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 13 def base_path @base_path end |
#default_headers ⇒ Object
Returns the value of attribute default_headers.
32 33 34 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 32 def default_headers @default_headers end |
#force_ending_format ⇒ Object
Returns the value of attribute force_ending_format.
30 31 32 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 30 def force_ending_format @force_ending_format end |
#format ⇒ Object
Returns the value of attribute format.
32 33 34 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 32 def format @format end |
#host ⇒ Object
Defines url host
10 11 12 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 10 def host @host end |
#inject_format ⇒ Object
Returns the value of attribute inject_format.
28 29 30 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 28 def inject_format @inject_format end |
#scheme ⇒ Object
Defines url scheme
7 8 9 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 7 def scheme @scheme end |
#timeout ⇒ Object
The time limit for HTTP request in seconds. Default to 0 (never times out).
17 18 19 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 17 def timeout @timeout end |
#user_agent ⇒ Object
Returns the value of attribute user_agent.
32 33 34 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 32 def user_agent @user_agent end |
#verify_ssl ⇒ true, false
Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
TLS/SSL Set this to false to skip verifying SSL certificate when calling API from https server. Default to true.
26 27 28 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 26 def verify_ssl @verify_ssl end |
Class Method Details
.default ⇒ Object
The default Configuration object.
50 51 52 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 50 def self.default @@default ||= Configuration.new end |
Instance Method Details
#base_url ⇒ Object
74 75 76 77 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 74 def base_url url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') URI.encode(url) end |
#configure {|_self| ... } ⇒ Object
54 55 56 |
# File 'lib/mastercard_core_sdk/core/configuration.rb', line 54 def configure yield(self) if block_given? end |