Sha256: 27d3cd0ffc51559ff35e7d23298ac432bfcfacec49b20316959f659dc7298f0a

Contents?: true

Size: 730 Bytes

Versions: 1

Compression:

Stored size: 730 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bankster-client-0.0.2 lib/bankster/client.rb