nubank_sdk 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88e935ce5affb735e7676f0dd93a213658308ce205f837028172bac24d0ceb0e
4
- data.tar.gz: dc9bd5c2cc72d965a2cfa0bb20e81eb3e43e6f4077806cfcab04532c1db00181
3
+ metadata.gz: aec1c5da9cacf0f6fc08c659866de92d86bc4aeded018f50cd4647ad83d4a08b
4
+ data.tar.gz: e8d379085b5e539eac996936bd53b696a9cfbfbc9415e7603baab93739149e3f
5
5
  SHA512:
6
- metadata.gz: 7a3217000244778e41aa31f56df110888cedae14efcdcd39b88a7e6fc430bb53bac67eee8a9570a0a67de8035a9d7e2f892bc9413c65e3198772ebe92b4039b9
7
- data.tar.gz: bf2509cbf0b73934c5e490fb146e499c286b658ab4050417ac47f9b17b7dc851829c31bbf9a58c265c00a9ff27714d0d3ba8ddf063186b17562e11c618d6da09
6
+ metadata.gz: c186f8f64658205365a9a086ae7e10c4b506d5a67839bc89a534616c7387235960c4c5f13b30fe5099b528b62ee14c844b084ee98aca822efbb6c94014902c50
7
+ data.tar.gz: e3dbe818c89e3ea593cbf2a34411559d1c6af531310f4eec930a254cdf411f9a05c711812a71896da023dbc322293202290fce2bdbc65749bc2ab72e5067a4d9
@@ -13,6 +13,8 @@
13
13
  "client",
14
14
  "version",
15
15
  "account",
16
- "github"
16
+ "github",
17
+ "user",
18
+ "credit"
17
19
  ]
18
20
  }
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nubank_sdk (0.5.1)
5
- faraday (~> 0.15.0)
4
+ nubank_sdk (0.6.0)
5
+ faraday (~> 2.7.1)
6
6
  json (~> 2.3)
7
7
 
8
8
  GEM
@@ -18,14 +18,15 @@ GEM
18
18
  diff-lcs (1.5.0)
19
19
  factory_bot (4.8.2)
20
20
  activesupport (>= 3.0.0)
21
- faraday (0.15.4)
22
- multipart-post (>= 1.2, < 3)
21
+ faraday (2.7.1)
22
+ faraday-net_http (>= 2.0, < 3.1)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-net_http (3.0.2)
23
25
  i18n (1.12.0)
24
26
  concurrent-ruby (~> 1.0)
25
27
  jaro_winkler (1.5.4)
26
- json (2.6.1)
28
+ json (2.6.2)
27
29
  minitest (5.15.0)
28
- multipart-post (2.2.3)
29
30
  parallel (1.19.2)
30
31
  parser (3.1.2.1)
31
32
  ast (~> 2.4.1)
@@ -56,6 +57,7 @@ GEM
56
57
  rubocop-rspec (1.27.0)
57
58
  rubocop (>= 0.56.0)
58
59
  ruby-progressbar (1.11.0)
60
+ ruby2_keywords (0.0.5)
59
61
  thread_safe (0.3.6)
60
62
  tzinfo (1.2.10)
61
63
  thread_safe (~> 0.1)
data/Rakefile CHANGED
@@ -7,12 +7,12 @@ Bundler::GemHelper.install_tasks
7
7
  task :default => :spec
8
8
 
9
9
  task :start_new_release do
10
- # TODO: add guard clean
11
10
  bump = ENV['BUMP'] || 'patch'
12
11
 
13
12
  sh 'gem install gem-release'
14
13
  sh "gem bump --version #{bump}"
15
14
 
15
+ sh 'bundle'
16
16
  Rake::Task[:build].invoke
17
17
 
18
18
  sh 'git add .'
@@ -1,3 +1,5 @@
1
+ require 'securerandom'
2
+
1
3
  module NubankSdk
2
4
  class Auth
3
5
  attr_reader :refresh_token, :refresh_before, :access_token
@@ -143,10 +145,10 @@ module NubankSdk
143
145
  #
144
146
  # @return [NubankSdk::ApiRoutes] the api routes with the new links
145
147
  def update_api_routes(links)
146
- feed_url_keys = ['events', 'magnitude']
147
- bills_url_keys = ['bills_summary']
148
- customer_url_keys = ['customer']
149
- 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]
150
152
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :revoke_token, url: links[:revoke_token][:href])
151
153
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :query, url: links[:ghostflame][:href])
152
154
  @api_routes.add_entrypoint(path: :ssl, entrypoint: :feed, url: find_url(feed_url_keys, links))
@@ -167,7 +169,7 @@ module NubankSdk
167
169
  links_keys = list.keys
168
170
 
169
171
  keys.each do |url_key|
170
- return list[url_key]['href'] if links_keys.include?(url_key)
172
+ return list[url_key][:href] if links_keys.include?(url_key)
171
173
  end
172
174
  ''
173
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.1"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/nubank_sdk.rb CHANGED
@@ -2,7 +2,9 @@ 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"
7
+ require "nubank_sdk/user"
6
8
  require "nubank_sdk/version"
7
9
 
8
10
  module NubankSdk
data/nubank_sdk.gemspec CHANGED
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "factory_bot", "~> 4.8.2"
30
30
  spec.add_development_dependency "yard", "~> 0.9.12"
31
31
 
32
- spec.add_dependency "faraday", "~> 0.15.0"
32
+ spec.add_dependency "faraday", "~> 2.7.1"
33
33
  spec.add_dependency "json", "~> 2.3"
34
34
  end
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.1
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
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.15.0
117
+ version: 2.7.1
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.15.0
124
+ version: 2.7.1
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: json
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -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