Sha256: e2a8152619057ee717a346f4670475ef60794105a7887ddb5e0782d816899005

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

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

1 entries across 1 versions & 1 rubygems

Version Path
nubank_sdk-0.6.1 lib/nubank_sdk/account.rb