nubank_sdk 0.7.0 → 0.7.2

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: 053f6750d8819dc5c05fa23831829106314f7002357d65083f45a234a28233f0
4
- data.tar.gz: 827596b59873ca86d556323dda076f710ee9dc19494bba206ee53cd748fa62ff
3
+ metadata.gz: acb3d7fcfc4212b5b535b127b93caf6659da30a516adf5a339078a9b2571a3e9
4
+ data.tar.gz: 9fa55b75d3076c6251a709cb065f70752e27765dbaa0a1c7eb0f11cdb653248c
5
5
  SHA512:
6
- metadata.gz: bf061fa7d6423a5c356418a5e9b2a823fa4492766e5b6bb92503bca7118cd323ce220a1042863b715a4af2297547c0539f44de35e95dd4ee1e814accbd8935df
7
- data.tar.gz: e103553e8c83693f918437f7d4ac7ae5d9121af6f88c71b759c1b0ef9878b0be84c81a9775b770b60b64bbabd9d59be52dca2a985a225fa51829594ab3ac249f
6
+ metadata.gz: f0701f569a4dac7ac8060eecefe458d842233ae4a35c1687aeb29f444a0b1919575a55f5f781c15e37f29976967bbf96c8b9a1414f61b6353d068becdf1044ae
7
+ data.tar.gz: f196c47c07437300f91d1f5d4d08b30c070bf5bbc822b5526b2b6d794d89ed91d8e797d618b03ee2eab2cc633e720f21b06acba495b6876f05805e946caa811c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nubank_sdk (0.7.0)
4
+ nubank_sdk (0.7.2)
5
5
  faraday (~> 2.7.1)
6
6
  json (~> 2.3)
7
7
 
data/Rakefile CHANGED
@@ -19,8 +19,6 @@ task :start_new_release do
19
19
  sh 'git add .'
20
20
  sh "git commit -m \"build(version): :bookmark: bump #{bump}\""
21
21
  sh 'git push'
22
-
23
- Rake::Task[:generate_git_tag].invoke
24
22
  end
25
23
 
26
24
  task :generate_git_tag do
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Graphql
4
+ class Account
5
+ BALANCE = '{viewer {savingsAccount {currentSavingsBalance {netAmount}}}}'
6
+ FEED = <<~GRAPHQL
7
+ {
8
+ viewer {
9
+ savingsAccount {
10
+ id
11
+ feed {
12
+ id
13
+ __typename
14
+ title
15
+ detail
16
+ postDate
17
+ ... on TransferInEvent {
18
+ amount
19
+ originAccount {
20
+ name
21
+ }
22
+ }
23
+ ... on TransferOutEvent {
24
+ amount
25
+ destinationAccount {
26
+ name
27
+ }
28
+ }
29
+ ... on TransferOutReversalEvent {
30
+ amount
31
+ }
32
+ ... on BillPaymentEvent {
33
+ amount
34
+ }
35
+ ... on DebitPurchaseEvent {
36
+ amount
37
+ }
38
+ ... on BarcodePaymentEvent {
39
+ amount
40
+ }
41
+ ... on DebitWithdrawalFeeEvent {
42
+ amount
43
+ }
44
+ ... on DebitWithdrawalEvent {
45
+ amount
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ GRAPHQL
52
+ end
53
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'graphql/account'
4
+
3
5
  module NubankSdk
4
6
  #
5
7
  # Returns the account statement
@@ -25,7 +27,7 @@ module NubankSdk
25
27
  response = @connection.post(
26
28
  query_url, {
27
29
  'variables': {},
28
- 'query': '{viewer {savingsAccount {currentSavingsBalance {netAmount}}}}'
30
+ 'query': Graphql::Account::BALANCE
29
31
  }
30
32
  )
31
33
 
@@ -43,7 +45,7 @@ module NubankSdk
43
45
  response = @connection.post(
44
46
  query_url, {
45
47
  'variables': {},
46
- 'query': Utils.read_graphql_query('account', 'feed')
48
+ 'query': Graphql::Account::FEED
47
49
  }
48
50
  )
49
51
 
@@ -7,7 +7,7 @@ module NubankSdk
7
7
  # Auth method to connect with the nubank api
8
8
  #
9
9
  class Auth
10
- attr_reader :refresh_token, :refresh_before, :access_token
10
+ attr_accessor :refresh_token, :refresh_before, :access_token, :encrypted_code, :p_key
11
11
 
12
12
  #
13
13
  # Auth method to connect with the nubank api
@@ -22,6 +22,7 @@ module NubankSdk
22
22
  @api_routes = api_routes || ApiRoutes.new
23
23
 
24
24
  @connection_adapter = connection_adapter
25
+ @p_key = OpenSSL::PKey::RSA.new 2048
25
26
  end
26
27
 
27
28
  #
@@ -75,7 +76,7 @@ module NubankSdk
75
76
  response = default_connection.post(@gen_certificate_path, new_payload)
76
77
 
77
78
  response_data = Client.get_body(response)
78
- certificate.process_decoded(key, response_data[:certificate])
79
+ certificate.process_decoded(@p_key, response_data[:certificate])
79
80
  end
80
81
 
81
82
  private
@@ -110,7 +111,7 @@ module NubankSdk
110
111
  {
111
112
  login: @cpf,
112
113
  password: password,
113
- public_key: key.public_key.to_pem,
114
+ public_key: @p_key.public_key.to_pem,
114
115
  device_id: @device_id,
115
116
  model: "NubankSdk Client (#{@device_id})"
116
117
  }
@@ -132,14 +133,6 @@ module NubankSdk
132
133
  }
133
134
  end
134
135
 
135
- # @!visibility private
136
- # Generates a new key for the certificate communication
137
- #
138
- # @return [OpenSSL::PKey::RSA] a new key
139
- def generate_key
140
- OpenSSL::PKey::RSA.new 2048
141
- end
142
-
143
136
  # @!visibility private
144
137
  # Add the new links to the api routes
145
138
  #
@@ -202,14 +195,6 @@ module NubankSdk
202
195
  @ssl_connection ||= Client::HTTPS.new(certificate.encoded, @connection_adapter)
203
196
  end
204
197
 
205
- # @!visibility private
206
- # return the key of the certificate communication
207
- #
208
- # @return [OpenSSL::PKey::RSA] the key of the certificate
209
- def key
210
- @key ||= generate_key
211
- end
212
-
213
198
  # @!visibility private
214
199
  # Generates a random device id
215
200
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NubankSdk
4
- VERSION = '0.7.0'
4
+ VERSION = '0.7.2'
5
5
  end
data/lib/nubank_sdk.rb CHANGED
@@ -8,7 +8,6 @@ require 'nubank_sdk/credit'
8
8
  require 'nubank_sdk/client'
9
9
  require 'nubank_sdk/user'
10
10
  require 'nubank_sdk/version'
11
- require 'nubank_sdk/utils'
12
11
 
13
12
  module NubankSdk
14
13
  class Error < StandardError; 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.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viserion77
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-02 00:00:00.000000000 Z
11
+ date: 2023-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -201,7 +201,7 @@ files:
201
201
  - bin/console
202
202
  - bin/setup
203
203
  - certificates/.gitkeep
204
- - lib/graphql/account/feed.gql
204
+ - lib/graphql/account.rb
205
205
  - lib/nubank_sdk.rb
206
206
  - lib/nubank_sdk/account.rb
207
207
  - lib/nubank_sdk/api_routes.rb
@@ -210,7 +210,6 @@ files:
210
210
  - lib/nubank_sdk/client.rb
211
211
  - lib/nubank_sdk/credit.rb
212
212
  - lib/nubank_sdk/user.rb
213
- - lib/nubank_sdk/utils.rb
214
213
  - lib/nubank_sdk/version.rb
215
214
  - nubank_sdk.gemspec
216
215
  homepage: https://github.com/Viserion77/nubank_sdk
@@ -1,44 +0,0 @@
1
- {
2
- viewer {
3
- savingsAccount {
4
- id
5
- feed {
6
- id
7
- __typename
8
- title
9
- detail
10
- postDate
11
- ... on TransferInEvent {
12
- amount
13
- originAccount {
14
- name
15
- }
16
- }
17
- ... on TransferOutEvent {
18
- amount
19
- destinationAccount {
20
- name
21
- }
22
- }
23
- ... on TransferOutReversalEvent {
24
- amount
25
- }
26
- ... on BillPaymentEvent {
27
- amount
28
- }
29
- ... on DebitPurchaseEvent {
30
- amount
31
- }
32
- ... on BarcodePaymentEvent {
33
- amount
34
- }
35
- ... on DebitWithdrawalFeeEvent {
36
- amount
37
- }
38
- ... on DebitWithdrawalEvent {
39
- amount
40
- }
41
- }
42
- }
43
- }
44
- }
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module NubankSdk
4
- #
5
- # Utils
6
- module Utils
7
- #
8
- # read graphQL query from file in ../graphql/{path}/{query}.gql
9
- #
10
- # @param [String] path - path to the query account, credit
11
- # @param [String] query - query name
12
- #
13
- # @return [String]
14
- def self.read_graphql_query(path, query)
15
- File.read(File.join('.', 'lib', 'graphql', path, "#{query}.gql"))
16
- end
17
- end
18
- end