class Bankster::Client
Attributes
credentials[R]
Public Class Methods
configuration()
click to toggle source
# File lib/bankster/client/client.rb, line 8 def self.configuration Configuration.instance end
configure() { |instance| ... }
click to toggle source
# File lib/bankster/client/client.rb, line 12 def self.configure yield Configuration.instance end
new(credentials)
click to toggle source
# File lib/bankster/client/client.rb, line 16 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
Public Instance Methods
transactions(account, from, to)
click to toggle source
# File lib/bankster/client/client.rb, line 27 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
transfer(sending_account, receiving_account, amount_cents, purpose, reference, identification = nil)
click to toggle source
FIXME : Parameter lists longer rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
# File lib/bankster/client/client.rb, line 35 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 Instance Methods
encoded_credentials()
click to toggle source
# File lib/bankster/client/client.rb, line 52 def encoded_credentials raise 'No credentials given' unless credentials credentials.encode end