Sha256: 48a0d093c01d26cf5ad24febfba20c693716d09678c6ba0aacb4efbf5419da25
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true module Bankster class Client include HTTParty attr_reader :credentials def self.configuration Configuration.instance end def self.configure yield Configuration.instance end def initialize(credentials) @credentials = credentials @options = { base_uri: self.class.configuration.api_url, headers: { 'Api-Key': self.class.configuration.api_key, 'Bank-Credentials': encoded_credentials } } 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) if !response.code.eql?(200) && !response.code.eql?(201) end private def encoded_credentials raise 'No credentials given' unless credentials credentials.encode end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bankster-client-0.0.6 | lib/bankster/client/client.rb |