Class: Wompi::Client
- Inherits:
-
Object
- Object
- Wompi::Client
- Defined in:
- lib/wompi/client.rb
Instance Method Summary collapse
- #call(method, path, params = {}, auth_type: :private) ⇒ Object
- #connection ⇒ Object
-
#initialize(config = Wompi.configuration) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(config = Wompi.configuration) ⇒ Client
Returns a new instance of Client.
6 7 8 |
# File 'lib/wompi/client.rb', line 6 def initialize(config = Wompi.configuration) @config = config end |
Instance Method Details
#call(method, path, params = {}, auth_type: :private) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/wompi/client.rb', line 18 def call(method, path, params = {}, auth_type: :private) key = auth_type == :private ? @config.private_key : @config.public_key response = connection.send(method, path, params) do |req| req.headers['Authorization'] = "Bearer #{key}" end handle_response(response) end |
#connection ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/wompi/client.rb', line 10 def connection Faraday.new(url: @config.base_url) do |f| f.request :json f.response :json f.adapter Faraday.default_adapter end end |