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 +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +0 -2
- data/lib/graphql/account.rb +53 -0
- data/lib/nubank_sdk/account.rb +4 -2
- data/lib/nubank_sdk/auth.rb +4 -19
- data/lib/nubank_sdk/version.rb +1 -1
- data/lib/nubank_sdk.rb +0 -1
- metadata +3 -4
- data/lib/graphql/account/feed.gql +0 -44
- data/lib/nubank_sdk/utils.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb3d7fcfc4212b5b535b127b93caf6659da30a516adf5a339078a9b2571a3e9
|
4
|
+
data.tar.gz: 9fa55b75d3076c6251a709cb065f70752e27765dbaa0a1c7eb0f11cdb653248c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0701f569a4dac7ac8060eecefe458d842233ae4a35c1687aeb29f444a0b1919575a55f5f781c15e37f29976967bbf96c8b9a1414f61b6353d068becdf1044ae
|
7
|
+
data.tar.gz: f196c47c07437300f91d1f5d4d08b30c070bf5bbc822b5526b2b6d794d89ed91d8e797d618b03ee2eab2cc633e720f21b06acba495b6876f05805e946caa811c
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -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
|
data/lib/nubank_sdk/account.rb
CHANGED
@@ -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':
|
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':
|
48
|
+
'query': Graphql::Account::FEED
|
47
49
|
}
|
48
50
|
)
|
49
51
|
|
data/lib/nubank_sdk/auth.rb
CHANGED
@@ -7,7 +7,7 @@ module NubankSdk
|
|
7
7
|
# Auth method to connect with the nubank api
|
8
8
|
#
|
9
9
|
class Auth
|
10
|
-
|
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(
|
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:
|
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
|
#
|
data/lib/nubank_sdk/version.rb
CHANGED
data/lib/nubank_sdk.rb
CHANGED
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.
|
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-
|
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
|
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
|
-
}
|
data/lib/nubank_sdk/utils.rb
DELETED
@@ -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
|