Class: Wallee::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/wallee-ruby-sdk/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_headers = {}) {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/wallee-ruby-sdk/configuration.rb', line 95

def initialize(default_headers = {})
  @scheme = 'https'
  @host = 'app-wallee.com:443'
  @base_path = '/api'
  @timeout = 25
  @params_encoding = nil
  @cert_file = nil
  @key_file = nil
  @debugging = false
  @inject_format = false
  @force_ending_format = false
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
  @default_headers = default_headers

  yield(self) if block_given?
end

Instance Attribute Details

#authentication_keyString

Defines the authentication_key used for request authentication.

Returns:

  • (String)


39
40
41
# File 'lib/wallee-ruby-sdk/configuration.rb', line 39

def authentication_key
  @authentication_key
end

#base_pathObject

Defines url base path



29
30
31
# File 'lib/wallee-ruby-sdk/configuration.rb', line 29

def base_path
  @base_path
end

#cert_fileObject

TLS/SSL setting Client certificate file (for client certificate)



76
77
78
# File 'lib/wallee-ruby-sdk/configuration.rb', line 76

def cert_file
  @cert_file
end

#debuggingtrue, false

Set this to enable/disable debugging. When enabled (set to true), HTTP request/response details will be logged with ‘logger.debug` (see the `logger` attribute). Default to false.

Returns:

  • (true, false)


46
47
48
# File 'lib/wallee-ruby-sdk/configuration.rb', line 46

def debugging
  @debugging
end

#default_headersObject

Returns the value of attribute default_headers.



93
94
95
# File 'lib/wallee-ruby-sdk/configuration.rb', line 93

def default_headers
  @default_headers
end

#force_ending_formatObject

Returns the value of attribute force_ending_format.



91
92
93
# File 'lib/wallee-ruby-sdk/configuration.rb', line 91

def force_ending_format
  @force_ending_format
end

#hostObject

Defines url host



26
27
28
# File 'lib/wallee-ruby-sdk/configuration.rb', line 26

def host
  @host
end

#inject_formatObject

Returns the value of attribute inject_format.



89
90
91
# File 'lib/wallee-ruby-sdk/configuration.rb', line 89

def inject_format
  @inject_format
end

#key_fileObject

TLS/SSL setting Client private key file (for client certificate)



80
81
82
# File 'lib/wallee-ruby-sdk/configuration.rb', line 80

def key_file
  @key_file
end

#logger#debug

Defines the logger used for debugging. Default to ‘Rails.logger` (when in Rails) or logging to STDOUT.

Returns:

  • (#debug)


52
53
54
# File 'lib/wallee-ruby-sdk/configuration.rb', line 52

def logger
  @logger
end

#params_encodingObject

Set this to customize parameters encoding of array parameter with multi collectionFormat. Default to nil.

github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96

See Also:

  • params_encoding option of Ethon. Related source code:


87
88
89
# File 'lib/wallee-ruby-sdk/configuration.rb', line 87

def params_encoding
  @params_encoding
end

#schemeObject

Defines url scheme



23
24
25
# File 'lib/wallee-ruby-sdk/configuration.rb', line 23

def scheme
  @scheme
end

#ssl_ca_certString

TLS/SSL setting Set this to customize the certificate file to verify the peer.

github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145

Returns:

  • (String)

    the path to the certificate file

See Also:

  • `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:


72
73
74
# File 'lib/wallee-ruby-sdk/configuration.rb', line 72

def ssl_ca_cert
  @ssl_ca_cert
end

#temp_folder_pathString

Defines the temporary folder to store downloaded files (for API endpoints that have file response). Default to use ‘Tempfile`.

Returns:

  • (String)


59
60
61
# File 'lib/wallee-ruby-sdk/configuration.rb', line 59

def temp_folder_path
  @temp_folder_path
end

#timeoutObject

The time limit for HTTP request in seconds. Default to 25.



63
64
65
# File 'lib/wallee-ruby-sdk/configuration.rb', line 63

def timeout
  @timeout
end

#user_idString

Defines the user_id used for request authentication.

Returns:

  • (String)


34
35
36
# File 'lib/wallee-ruby-sdk/configuration.rb', line 34

def user_id
  @user_id
end

Class Method Details

.defaultObject

The default Configuration object.



113
114
115
# File 'lib/wallee-ruby-sdk/configuration.rb', line 113

def self.default
  @@default ||= Configuration.new
end

Instance Method Details

#base_urlObject



137
138
139
140
# File 'lib/wallee-ruby-sdk/configuration.rb', line 137

def base_url
  url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
  Addressable::URI.encode(url)
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



117
118
119
# File 'lib/wallee-ruby-sdk/configuration.rb', line 117

def configure
  yield(self) if block_given?
end