Class: Frame::FrameClient
- Inherits:
-
Object
- Object
- Frame::FrameClient
- Defined in:
- lib/frame/frame_client.rb
Overview
HTTP client for making requests to the Frame Payments API.
Handles connection management, request execution, and response processing. Automatically handles authentication, error parsing, and response formatting.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#conn ⇒ Object
Returns the value of attribute conn.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(api_key: nil, api_base: nil, open_timeout: nil, read_timeout: nil, verify_ssl_certs: nil, logger: nil, log_level: nil) ⇒ FrameClient
constructor
A new instance of FrameClient.
- #request(method, path, params = {}, opts = {}) ⇒ Object
Constructor Details
#initialize(api_key: nil, api_base: nil, open_timeout: nil, read_timeout: nil, verify_ssl_certs: nil, logger: nil, log_level: nil) ⇒ FrameClient
Returns a new instance of FrameClient.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/frame/frame_client.rb', line 33 def initialize(api_key: nil, api_base: nil, open_timeout: nil, read_timeout: nil, verify_ssl_certs: nil, logger: nil, log_level: nil) @config = { api_key: api_key || Frame.api_key, api_base: api_base || Frame.api_base, open_timeout: open_timeout || Frame.open_timeout, read_timeout: read_timeout || Frame.read_timeout, verify_ssl_certs: verify_ssl_certs.nil? ? Frame.verify_ssl_certs : verify_ssl_certs, logger: logger || Frame.logger, log_level: log_level || Frame.log_level } @conn = create_connection end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
9 10 11 |
# File 'lib/frame/frame_client.rb', line 9 def config @config end |
#conn ⇒ Object
Returns the value of attribute conn.
9 10 11 |
# File 'lib/frame/frame_client.rb', line 9 def conn @conn end |
Class Method Details
.active_client ⇒ Object
13 14 15 |
# File 'lib/frame/frame_client.rb', line 13 def self.active_client Thread.current[:frame_client] || default_client end |
.default_client ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/frame/frame_client.rb', line 17 def self.default_client return @default_client if @default_client @default_client_mutex.synchronize do @default_client ||= FrameClient.new( api_key: Frame.api_key, api_base: Frame.api_base, open_timeout: Frame.open_timeout, read_timeout: Frame.read_timeout, verify_ssl_certs: Frame.verify_ssl_certs, logger: Frame.logger, log_level: Frame.log_level ) end end |
Instance Method Details
#request(method, path, params = {}, opts = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/frame/frame_client.rb', line 47 def request(method, path, params = {}, opts = {}) response = execute_request(method, path, params, opts) process_response(response) rescue Faraday::ConnectionFailed => e raise APIConnectionError.new("Connection failed: #{e.}") rescue Faraday::TimeoutError => e raise APIConnectionError.new("Request timed out: #{e.}") rescue Faraday::ClientError => e raise APIConnectionError.new("Client error: #{e.}") end |