Class: BunqRb::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bunq_rb/client.rb

Overview

Client

Class Method Summary collapse

Class Method Details

.connectionObject



69
70
71
72
73
74
75
76
77
# File 'lib/bunq_rb/client.rb', line 69

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



87
88
89
90
# File 'lib/bunq_rb/client.rb', line 87

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



79
80
81
82
83
84
85
# File 'lib/bunq_rb/client.rb', line 79

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