Class: BunqRb::Client
- Inherits:
-
Object
- Object
- BunqRb::Client
- Defined in:
- lib/bunq_rb/client.rb
Overview
Client
Class Method Summary collapse
- .connection ⇒ Object
- .raw_send_method(method, url, payload = {}) ⇒ Object
- .send_method(method, url, payload = {}) ⇒ Object
Class Method Details
.connection ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/bunq_rb/client.rb', line 80 def self.connection @connection ||= Faraday.new(url: BunqRb.configuration.url) do |config| config.use Headers config.use SignRequest config.request :json config.request :multipart config.adapter Faraday.default_adapter end end |
.raw_send_method(method, url, payload = {}) ⇒ Object
98 99 100 101 |
# File 'lib/bunq_rb/client.rb', line 98 def self.raw_send_method(method, url, payload = {}) BunqRb.logger.debug "#{method.upcase} #{url}" connection.send(method, url, payload) end |
.send_method(method, url, payload = {}) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/bunq_rb/client.rb', line 90 def self.send_method(method, url, payload = {}) BunqRb.logger.debug "#{method.upcase} #{url}" faraday_response = connection.send(method, url, payload) json_response = JSON.parse(faraday_response.body) raise json_response["Error"].first["error_description"] if json_response.key?("Error") json_response["Response"] end |