Sha256: 4f8c4080bc18bd9ec051ce4eae650fdd7d48e82ae888a321cdfa4aa815ff4b8d

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

module NubankSdk
  class Account
    #
    # Returns the account statement
    #
    # @param [NubankSdk::Client::HTTPS] connection
    # @param [NubankSdk::ApiRoutes] api_routes
    def initialize(connection:, api_routes:)
      @connection = connection
      @api_routes = api_routes
    end

    #
    # Returns the account balance
    #
    # @return [Float]
    def balance
      query_url = @api_routes.entrypoint(path: :ssl, entrypoint: :query)

      response = @connection.post(
        query_url, {
          'variables': {},
          'query': '{viewer {savingsAccount {currentSavingsBalance {netAmount}}}}'
        }
      )

      data = NubankSdk::Client.get_body(response)
      data[:data][:viewer][:savingsAccount][:currentSavingsBalance][:netAmount]
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nubank_sdk-0.6.0 lib/nubank_sdk/account.rb
nubank_sdk-0.5.2 lib/nubank_sdk/account.rb
nubank_sdk-0.5.1 lib/nubank_sdk/account.rb