require 'httparty' require 'bankster/bank_credentials' module Bankster class Client include HTTParty attr_reader :credentials base_uri "localhost:9292" def initialize(credentials, api_key) @credentials = credentials @api_key = api_key @options = { 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) if response.ok? else raise(response.body) end end end end