Class: NubankSdk::Credit

Inherits:
Object
  • Object
show all
Defined in:
lib/nubank_sdk/credit.rb

Overview

Returns the credit statement

Instance Method Summary collapse

Constructor Details

#initialize(connection:, api_routes:) ⇒ Credit

Returns the credit statement

Parameters:



13
14
15
16
# File 'lib/nubank_sdk/credit.rb', line 13

def initialize(connection:, api_routes:)
  @connection = connection
  @api_routes = api_routes
end

Instance Method Details

#balancesHash<Symbol, Float>

Returns the credit balances

Returns:

  • (Hash<Symbol, Float>)

    the credit balances



22
23
24
25
26
27
28
29
# File 'lib/nubank_sdk/credit.rb', line 22

def balances
   = @api_routes.entrypoint(path: :ssl, entrypoint: :account)

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

  response_hash[:account][:balances]
end

#cardsArray<Hash>

Returns the cards summary

Returns:

  • (Array<Hash>)

    the cards summary



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nubank_sdk/credit.rb', line 48

def cards
  # cards_url vem do 'https://prod-s7-facade.nubank.com.br/api/customers/${id}/dashboard'
  # porem isso retorna muito dado... então vamos chumbar :D
  customer_id = @api_routes.entrypoint(path: :ssl, entrypoint: :customer).split('/').last
  cards_url = "https://prod-s7-mr-white.nubank.com.br/api/customers/#{customer_id}/card-summaries"

  puts cards_url
  response = @connection.get(cards_url)

  data = Client.get_body(response)
  data[:sections].map { |section| section[:cards] }.flatten
end

#feedArray<Hash>

Returns the credit feed

Returns:

  • (Array<Hash>)

    the credit feed



35
36
37
38
39
40
41
42
# File 'lib/nubank_sdk/credit.rb', line 35

def feed
  feed_url = @api_routes.entrypoint(path: :ssl, entrypoint: :feed)

  response = @connection.get(feed_url)

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

#transaction_details(transaction_id) ⇒ Hash

Return details of a specific transaction from prod-s7-showbillz.nubank.com.br/api/items/#transaction_id/details

Parameters:

  • transaction_id (String)

Returns:

  • (Hash)

    the transaction details



67
68
69
70
71
72
73
# File 'lib/nubank_sdk/credit.rb', line 67

def transaction_details(transaction_id)
  details_url = "https://prod-s7-showbillz.nubank.com.br/api/items/#{transaction_id}/details"

  response = @connection.get(details_url)

  Client.get_body(response)
end