Class: KaChing::ApiV1::Saldo

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ka_ching/api_v1/saldo.rb

Overview

Saldo Endpoint for the KaChing API V1

Instance Method Summary collapse

Constructor Details

#initialize(conn:, api_url:) ⇒ Saldo



13
14
15
16
# File 'lib/ka_ching/api_v1/saldo.rb', line 13

def initialize(conn:, api_url:)
  @conn = conn
  @api_url = api_url
end

Instance Method Details

#current(tenant_account_id:) {|Faraday::Response| ... } ⇒ Hash

Get the current saldo (in cents)

Yields:

  • (Faraday::Response)

    The response from the server



27
28
29
30
31
32
33
# File 'lib/ka_ching/api_v1/saldo.rb', line 27

def current(tenant_account_id:)
  res = get(build_url(tenant_account_id: )) do |req|
    req.headers['Content-Type'] = 'application/json'
  end
  yield res if block_given?
  JSON.parse(res.body)
end