module BanksterClient class Client include HTTParty def initialize @options = { base_uri: BanksterClient.configuration.api, headers: { 'Api-Key' => BanksterClient.configuration.api_key, 'Bank-Credentials' => Base64.urlsafe_encode64(BanksterClient.configuration.credentials.to_json) } } end def transactions(account, from, to) response = self.class.get('/transactions', @options.merge(query: { account: account, start: from, end: to })) raise(response.body) unless response.ok? JSON.parse(response.body) end # FIXME : Parameter lists longer # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength def transfer(sending_account, receiving_account, amount_cents, purpose, reference, identification = nil) attributes = @options.merge( body: { sending_account: sending_account.to_h, receiving_account: receiving_account.to_h, purpose: purpose, amount_cents: amount_cents, reference: reference, identification: identification } ) response = self.class.post('/transfers', attributes) raise(response.body) unless response.ok? end end end