require 'httparty' require 'bankster/bank_credentials' module Bankster class Client include HTTParty attr_reader :credentials def initialize(credentials, api_key) @credentials = credentials @api_key = api_key @options = { base_uri: BANKSTER_BASE_URI || 'https://api.bankster.io', headers: { 'Api-Key' => api_key, 'Bank-Credentials' => Base64.encode64(credentials.to_json) } } end def transactions(account, from, to) response = self.class.get("/transactions", @options.merge(query: {account: account, start: from, end: to})) if response.ok? JSON.parse(response.body) else raise(response.body) end end end end