Sha256: 4a2a13813ec141f0d7741a3c46a254cb1b3c648c9dcf2762236d7532e389fe91

Contents?: true

Size: 999 Bytes

Versions: 8

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

module NubankSdk
  #
  # Returns the credit statement
  #
  class Credit
    #
    # Returns the credit 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 credit balances
    #
    # @return [Hash<Symbol, Float>] the credit balances
    def balances
      account_url = @api_routes.entrypoint(path: :ssl, entrypoint: :account)

      response = @connection.get(account_url)
      response_hash = Client.get_body(response)

      response_hash[:account][:balances]
    end

    #
    # Returns the credit feed
    #
    # @return [Array<Hash>] the credit feed
    def feed
      feed_url = @api_routes.entrypoint(path: :ssl, entrypoint: :feed)

      response = @connection.get(feed_url)

      data = Client.get_body(response)
      data[:events]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nubank_sdk-0.7.7 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.6 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.5 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.4 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.3 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.2 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.1 lib/nubank_sdk/credit.rb
nubank_sdk-0.7.0 lib/nubank_sdk/credit.rb