class Qonto::Client
Constants
- API_VERSION
- BASE_URL
- USER_AGENT
Attributes
secret_key[R]
slug[R]
Public Class Methods
new(slug:, secret_key:)
click to toggle source
# File lib/qonto/client.rb, line 15 def initialize(slug:, secret_key:) @slug = slug @secret_key = secret_key end
Public Instance Methods
base_url()
click to toggle source
# File lib/qonto/client.rb, line 20 def base_url "#{BASE_URL}#{API_VERSION}" end
get(path, options = {})
click to toggle source
# File lib/qonto/client.rb, line 24 def get(path, options = {}) execute(:get, path, options) end
Private Instance Methods
base_options()
click to toggle source
# File lib/qonto/client.rb, line 61 def base_options { format: :json, headers: { 'Accept' => 'application/json', 'Authorization' => "#{slug}:#{secret_key}", 'User-Agent' => USER_AGENT } } end
execute(method, path, options)
click to toggle source
# File lib/qonto/client.rb, line 32 def execute(method, path, options) begin response = request(method, path, options) rescue *Error::NET_HTTP_ERRORS => err raise ConnectionError.new, err.message end case response.code when 200..299 response when 400 raise BadRequestError.new(response) when 401 raise AuthenticationError.new(response) when 404 raise NotFoundError.new(response) when 400..499 raise ResponseError.new(response) when 500 raise InternalServerError.new(response) when 500..599 raise ServerError.new(response) end end
request(method, path, options)
click to toggle source
# File lib/qonto/client.rb, line 57 def request(method, path, options) HTTParty.send(method, base_url + path, base_options.merge(options)) end