nubank_sdk 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a226cbf9d9b246280f13b3735c23d125592485c177e4f33b3027bd55e35de86
4
- data.tar.gz: 2768ad5e56d7198834da4ac8b23ac98e1da0b33c509c399a79ce9e6289f74496
3
+ metadata.gz: aec1c5da9cacf0f6fc08c659866de92d86bc4aeded018f50cd4647ad83d4a08b
4
+ data.tar.gz: e8d379085b5e539eac996936bd53b696a9cfbfbc9415e7603baab93739149e3f
5
5
  SHA512:
6
- metadata.gz: 0c0cd7e56e16556592cbdd537e4ae71feac2e7c64ca3610d5c1c2bcd42eb8797b502a75df3c89ebd69b8225294a74c31a13d7d25b5bcab1ea89799fdd1c183da
7
- data.tar.gz: f7ed4facab0fcc4ad87b1a480c0961390748a5a2153a85da525923cd959cbb0818015be086c9482a4b2ede4cf56c94a02d3756f942127d8734c2bd64b73f2d0e
6
+ metadata.gz: c186f8f64658205365a9a086ae7e10c4b506d5a67839bc89a534616c7387235960c4c5f13b30fe5099b528b62ee14c844b084ee98aca822efbb6c94014902c50
7
+ data.tar.gz: e3dbe818c89e3ea593cbf2a34411559d1c6af531310f4eec930a254cdf411f9a05c711812a71896da023dbc322293202290fce2bdbc65749bc2ab72e5067a4d9
@@ -14,6 +14,7 @@
14
14
  "version",
15
15
  "account",
16
16
  "github",
17
- "user"
17
+ "user",
18
+ "credit"
18
19
  ]
19
20
  }
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nubank_sdk (0.5.2)
4
+ nubank_sdk (0.6.0)
5
5
  faraday (~> 2.7.1)
6
6
  json (~> 2.3)
7
7
 
@@ -145,10 +145,10 @@ module NubankSdk
145
145
  #
146
146
  # @return [NubankSdk::ApiRoutes] the api routes with the new links
147
147
  def update_api_routes(links)
148
- feed_url_keys = ['events', 'magnitude']
149
- bills_url_keys = ['bills_summary']
150
- customer_url_keys = ['customer']
151
- account_url_keys = ['account']
148
+ feed_url_keys = [:events, :magnitude]
149
+ bills_url_keys = [:bills_summary]
150
+ customer_url_keys = [:customer]
151
+ account_url_keys = [:account]
152
152
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :revoke_token, url: links[:revoke_token][:href])
153
153
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :query, url: links[:ghostflame][:href])
154
154
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :feed, url: find_url(feed_url_keys, links))
@@ -169,7 +169,7 @@ module NubankSdk
169
169
  links_keys = list.keys
170
170
 
171
171
  keys.each do |url_key|
172
- return list[url_key]['href'] if links_keys.include?(url_key)
172
+ return list[url_key][:href] if links_keys.include?(url_key)
173
173
  end
174
174
  ''
175
175
  end
@@ -92,6 +92,23 @@ module NubankSdk
92
92
  req.body = body.to_json
93
93
  end
94
94
  end
95
+
96
+ #
97
+ # Make a get request on connection
98
+ #
99
+ # @param [String] url
100
+ #
101
+ # @return [Faraday::Response]
102
+ def get(url)
103
+ @connection.get(url) do |req|
104
+ req.headers['X-Correlation-Id'] = '772428d8-f0ee-43d6-8093-a13de3c9ce96'
105
+ req.headers['User-Agent'] = "NubankSdk Client (#{NubankSdk::VERSION})"
106
+
107
+ @headers.each do |header_key, value|
108
+ req.headers[header_key] = value
109
+ end
110
+ end
111
+ end
95
112
  end
96
113
  end
97
114
  end
@@ -0,0 +1,26 @@
1
+ module NubankSdk
2
+ class Credit
3
+ #
4
+ # Returns the credit statement
5
+ #
6
+ # @param [NubankSdk::Client::HTTPS] connection
7
+ # @param [NubankSdk::ApiRoutes] api_routes
8
+ def initialize(connection:, api_routes:)
9
+ @connection = connection
10
+ @api_routes = api_routes
11
+ end
12
+
13
+ #
14
+ # Returns the credit balances
15
+ #
16
+ # @return [Hash<Symbol, Float>] the credit balances
17
+ def balances
18
+ account_url = @api_routes.entrypoint(path: :ssl, entrypoint: :account)
19
+
20
+ response = @connection.get(account_url)
21
+ response_hash = Client.get_body(response)
22
+
23
+ response_hash[:account][:balances]
24
+ end
25
+ end
26
+ end
@@ -30,6 +30,14 @@ module NubankSdk
30
30
  @account ||= NubankSdk::Account.new(connection: connection, api_routes: api_routes)
31
31
  end
32
32
 
33
+ #
34
+ # Returns instance of credit methods
35
+ #
36
+ # @return [NubankSdk::Credit]
37
+ def credit
38
+ @credit ||= NubankSdk::Credit.new(connection: connection, api_routes: api_routes)
39
+ end
40
+
33
41
  #
34
42
  # An instance of apis routes
35
43
  #
@@ -1,3 +1,3 @@
1
1
  module NubankSdk
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/nubank_sdk.rb CHANGED
@@ -2,6 +2,7 @@ require "nubank_sdk/account"
2
2
  require "nubank_sdk/api_routes"
3
3
  require "nubank_sdk/auth"
4
4
  require "nubank_sdk/certificate"
5
+ require "nubank_sdk/credit"
5
6
  require "nubank_sdk/client"
6
7
  require "nubank_sdk/user"
7
8
  require "nubank_sdk/version"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nubank_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viserion77
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-27 00:00:00.000000000 Z
11
+ date: 2022-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -163,6 +163,7 @@ files:
163
163
  - lib/nubank_sdk/auth.rb
164
164
  - lib/nubank_sdk/certificate.rb
165
165
  - lib/nubank_sdk/client.rb
166
+ - lib/nubank_sdk/credit.rb
166
167
  - lib/nubank_sdk/user.rb
167
168
  - lib/nubank_sdk/version.rb
168
169
  - nubank_sdk.gemspec