Class: NubankSdk::Credit
- Inherits:
-
Object
- Object
- NubankSdk::Credit
- Defined in:
- lib/nubank_sdk/credit.rb
Overview
Returns the credit statement
Instance Method Summary collapse
-
#balances ⇒ Hash<Symbol, Float>
Returns the credit balances.
-
#cards ⇒ Array<Hash>
Returns the cards summary.
-
#feed ⇒ Array<Hash>
Returns the credit feed.
-
#initialize(connection:, api_routes:) ⇒ Credit
constructor
Returns the credit statement.
-
#transaction_details(transaction_id) ⇒ Hash
Return details of a specific transaction from prod-s7-showbillz.nubank.com.br/api/items/#transaction_id/details.
Constructor Details
#initialize(connection:, api_routes:) ⇒ Credit
Returns the credit statement
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
#balances ⇒ Hash<Symbol, Float>
Returns the credit balances
22 23 24 25 26 27 28 29 |
# File 'lib/nubank_sdk/credit.rb', line 22 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 |
#cards ⇒ Array<Hash>
Returns 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 |
#feed ⇒ Array<Hash>
Returns 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
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 |