class BunqRb::Client

Client

Public Class Methods

connection() click to toggle source
# 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 = {}) click to toggle source
# 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 = {}) click to toggle source
# 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