nordigen-ruby 1.0.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +7 -4
- data/Gemfile.lock +8 -29
- data/LICENSE.txt +1 -1
- data/README.md +16 -7
- data/Rakefile +7 -1
- data/lib/nordigen-ruby.rb +18 -11
- data/lib/nordigen_ruby/api/account.rb +8 -5
- data/lib/nordigen_ruby/version.rb +1 -1
- data/nordigen.gemspec +1 -2
- metadata +5 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55e72e3ae468d31197df1d31c3ed1ab62d54c2e3f138bf2c8f946559a605d4db
|
|
4
|
+
data.tar.gz: 55f1a55b4c854d9cc96d701999b832c59388cf707d26f611cf43f7dc17205fd1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0432d6819c810c20cf5424c9d771e44192c8e27506cb01e8d40fb83395c645efa6c975e61f78493cfc9a348a22e687a7cb373668ff2408ba15e4411630c8d990
|
|
7
|
+
data.tar.gz: 417f3953480f7bcc91d6f88d6c0ad2256ee915bdab43a88d395005e36fc516f5383393e1db92603f707f15a7ea53271f2e3ffbb03af669c2224922e69317b77c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.0.0] - 2022-05-05
|
|
4
|
+
|
|
5
|
+
- Use JSON response instead of OpenStruct
|
|
6
|
+
- Add `date_to`, `date_from` arguments to filter transactions
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [1.0.1] - 2022-01-13
|
|
10
|
+
|
|
11
|
+
- Republish library with latest working gem
|
|
12
|
+
|
|
3
13
|
## [1.0.0] - 2022-01-13
|
|
4
14
|
|
|
5
15
|
- Initial release
|
data/Gemfile
CHANGED
|
@@ -5,7 +5,10 @@ source "https://rubygems.org"
|
|
|
5
5
|
# Specify your gem's dependencies in nordigen.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem "
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
gem "
|
|
8
|
+
gem "faraday", "~> 2.5.2"
|
|
9
|
+
|
|
10
|
+
group :development do
|
|
11
|
+
gem "rake", "~> 13.0"
|
|
12
|
+
gem "test-unit", "~> 3.5.3"
|
|
13
|
+
gem "dotenv", "~> 2.8.1"
|
|
14
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,37 +1,17 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
nordigen-ruby (
|
|
5
|
-
|
|
6
|
-
faraday (~> 1.8.0)
|
|
7
|
-
faraday_middleware (~> 1.2.0)
|
|
4
|
+
nordigen-ruby (2.0.0)
|
|
5
|
+
faraday (~> 2.5.2)
|
|
8
6
|
|
|
9
7
|
GEM
|
|
10
8
|
remote: https://rubygems.org/
|
|
11
9
|
specs:
|
|
12
|
-
dotenv (2.
|
|
13
|
-
faraday (
|
|
14
|
-
faraday-
|
|
15
|
-
faraday-em_synchrony (~> 1.0)
|
|
16
|
-
faraday-excon (~> 1.1)
|
|
17
|
-
faraday-httpclient (~> 1.0.1)
|
|
18
|
-
faraday-net_http (~> 1.0)
|
|
19
|
-
faraday-net_http_persistent (~> 1.1)
|
|
20
|
-
faraday-patron (~> 1.0)
|
|
21
|
-
faraday-rack (~> 1.0)
|
|
22
|
-
multipart-post (>= 1.2, < 3)
|
|
10
|
+
dotenv (2.8.1)
|
|
11
|
+
faraday (2.5.2)
|
|
12
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
23
13
|
ruby2_keywords (>= 0.0.4)
|
|
24
|
-
faraday-
|
|
25
|
-
faraday-em_synchrony (1.0.0)
|
|
26
|
-
faraday-excon (1.1.0)
|
|
27
|
-
faraday-httpclient (1.0.1)
|
|
28
|
-
faraday-net_http (1.0.1)
|
|
29
|
-
faraday-net_http_persistent (1.2.0)
|
|
30
|
-
faraday-patron (1.0.0)
|
|
31
|
-
faraday-rack (1.0.0)
|
|
32
|
-
faraday_middleware (1.2.0)
|
|
33
|
-
faraday (~> 1.0)
|
|
34
|
-
multipart-post (2.1.1)
|
|
14
|
+
faraday-net_http (3.0.0)
|
|
35
15
|
power_assert (2.0.1)
|
|
36
16
|
rake (13.0.6)
|
|
37
17
|
ruby2_keywords (0.0.5)
|
|
@@ -42,9 +22,8 @@ PLATFORMS
|
|
|
42
22
|
x86_64-linux
|
|
43
23
|
|
|
44
24
|
DEPENDENCIES
|
|
45
|
-
dotenv (~> 2.
|
|
46
|
-
faraday (~>
|
|
47
|
-
faraday_middleware (~> 1.2.0)
|
|
25
|
+
dotenv (~> 2.8.1)
|
|
26
|
+
faraday (~> 2.5.2)
|
|
48
27
|
nordigen-ruby!
|
|
49
28
|
rake (~> 13.0)
|
|
50
29
|
test-unit (~> 3.5.3)
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2022 Nordigen Solutions
|
|
3
|
+
Copyright (c) 2022 SIA "Nordigen Solutions"
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
|
@@ -45,8 +45,8 @@ client.set_token("YOUR_TOKEN")
|
|
|
45
45
|
|
|
46
46
|
# Get access and refresh token
|
|
47
47
|
# Note: access_token is automatically injected to other requests after you successfully obtain it
|
|
48
|
-
access_token = token_data
|
|
49
|
-
refresh_token = token_data
|
|
48
|
+
access_token = token_data["access"]
|
|
49
|
+
refresh_token = token_data["refresh"]
|
|
50
50
|
|
|
51
51
|
# Exchange refresh token. Refresh token is valid for 30 days
|
|
52
52
|
refresh_token = client.exchange_token(refresh_token)
|
|
@@ -69,9 +69,9 @@ init = client.init_session(
|
|
|
69
69
|
reference_id: SecureRandom.uuid
|
|
70
70
|
)
|
|
71
71
|
|
|
72
|
-
link = init
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
link = init["link"] # bank authorization link
|
|
73
|
+
requisition_id = init["id"] # requisition id that is needed to get an account_id
|
|
74
|
+
puts link
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
After successful authorization with a bank you can fetch your data (details, balances, transactions)
|
|
@@ -82,9 +82,9 @@ After successful authorization with a bank you can fetch your data (details, bal
|
|
|
82
82
|
```ruby
|
|
83
83
|
|
|
84
84
|
# Get account id after you have completed authorization with a bank.
|
|
85
|
-
|
|
85
|
+
requisition_data = client.requisition.get_requisition_by_id(requisition_id)
|
|
86
86
|
# Get account id from list
|
|
87
|
-
account_id = accounts
|
|
87
|
+
account_id = accounts["accounts"][0]
|
|
88
88
|
|
|
89
89
|
# Instantiate account object
|
|
90
90
|
account = client.account_api(account_id)
|
|
@@ -97,6 +97,15 @@ details = account.get_details()
|
|
|
97
97
|
balances = account.get_balances()
|
|
98
98
|
# Fetch transactions
|
|
99
99
|
transactions = account.get_transactions()
|
|
100
|
+
# Filter transactions by specific date range
|
|
101
|
+
transactions = account.get_transactions(date_from: "2021-12-01", date_to: "2022-01-30")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
Run all tests in a directory
|
|
107
|
+
```bash
|
|
108
|
+
bundle exec rake test
|
|
100
109
|
```
|
|
101
110
|
|
|
102
111
|
## Support
|
data/Rakefile
CHANGED
data/lib/nordigen-ruby.rb
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
require "faraday"
|
|
2
|
-
require "faraday_middleware"
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
require_relative "nordigen_ruby/api/institutions"
|
|
4
|
+
require_relative "nordigen_ruby/api/agreements"
|
|
5
|
+
require_relative "nordigen_ruby/api/requisitions"
|
|
6
|
+
require_relative "nordigen_ruby/api/account"
|
|
8
7
|
|
|
9
8
|
module Nordigen
|
|
10
9
|
class NordigenClient
|
|
@@ -27,13 +26,20 @@ module Nordigen
|
|
|
27
26
|
@requisition = RequisitionsApi.new(client=self)
|
|
28
27
|
end
|
|
29
28
|
|
|
30
|
-
def request
|
|
29
|
+
def request(params = nil)
|
|
31
30
|
# HTTP client request
|
|
31
|
+
parameters = {}
|
|
32
|
+
params&.each do |key, value|
|
|
33
|
+
if value
|
|
34
|
+
parameters[key] = value
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
32
38
|
@request ||= Faraday.new do |conn|
|
|
33
39
|
conn.url_prefix = BASE_URL
|
|
34
40
|
conn.headers = @@headers
|
|
35
41
|
conn.request :json
|
|
36
|
-
conn.response :json
|
|
42
|
+
conn.response :json
|
|
37
43
|
end
|
|
38
44
|
end
|
|
39
45
|
|
|
@@ -58,7 +64,7 @@ module Nordigen
|
|
|
58
64
|
raise Exception.new response.body
|
|
59
65
|
end
|
|
60
66
|
|
|
61
|
-
@@headers["Authorization"] = "Bearer #{response.body
|
|
67
|
+
@@headers["Authorization"] = "Bearer #{response.body['access']}"
|
|
62
68
|
request.headers = @@headers
|
|
63
69
|
return response.body
|
|
64
70
|
end
|
|
@@ -67,7 +73,7 @@ module Nordigen
|
|
|
67
73
|
# Exchange refresh token for access token
|
|
68
74
|
payload = {"refresh": refresh_token}
|
|
69
75
|
response = self.request.post("token/refresh/", payload).body
|
|
70
|
-
@@headers["Authorization"] = "Bearer #{response
|
|
76
|
+
@@headers["Authorization"] = "Bearer #{response['access']}"
|
|
71
77
|
request.headers = @@headers
|
|
72
78
|
return response
|
|
73
79
|
end
|
|
@@ -93,8 +99,9 @@ module Nordigen
|
|
|
93
99
|
new_requsition = @requisition.create_requisition(
|
|
94
100
|
redirect_url: redirect_url,
|
|
95
101
|
reference: reference_id,
|
|
96
|
-
institution_id: institution_id
|
|
97
|
-
|
|
102
|
+
institution_id: institution_id,
|
|
103
|
+
agreement: new_agreement["id"]
|
|
104
|
+
)
|
|
98
105
|
|
|
99
106
|
return new_requsition
|
|
100
107
|
end
|
|
@@ -9,15 +9,14 @@ module Nordigen
|
|
|
9
9
|
@account_id = account_id
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def get(path = nil)
|
|
12
|
+
def get(path = nil, params = nil)
|
|
13
13
|
# Create Get request
|
|
14
14
|
url = "#{ENDPOINT}#{@account_id}/"
|
|
15
|
-
|
|
16
15
|
if path
|
|
17
16
|
url = "#{url}#{path}/"
|
|
18
17
|
end
|
|
19
18
|
|
|
20
|
-
return client.request.get(url).body
|
|
19
|
+
return client.request(params).get(url).body
|
|
21
20
|
end
|
|
22
21
|
|
|
23
22
|
def get_metadata
|
|
@@ -36,9 +35,13 @@ module Nordigen
|
|
|
36
35
|
return get("balances")
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
def get_transactions
|
|
38
|
+
def get_transactions(date_from: nil, date_to: nil)
|
|
40
39
|
# Access account transactions
|
|
41
|
-
|
|
40
|
+
date_range = {
|
|
41
|
+
"date_from" => date_from,
|
|
42
|
+
"date_to" => date_to
|
|
43
|
+
}
|
|
44
|
+
return get("transactions", date_range)
|
|
42
45
|
end
|
|
43
46
|
|
|
44
47
|
end
|
data/nordigen.gemspec
CHANGED
|
@@ -33,8 +33,7 @@ Gem::Specification.new do |spec|
|
|
|
33
33
|
spec.executables = `git ls-files -- bin/*`.split("\n")
|
|
34
34
|
.map { |f| ::File.basename(f) }
|
|
35
35
|
|
|
36
|
-
spec.add_dependency "faraday", "~>
|
|
37
|
-
spec.add_dependency "faraday_middleware", "~> 1.2.0"
|
|
36
|
+
spec.add_dependency "faraday", "~> 2.5.2"
|
|
38
37
|
|
|
39
38
|
spec.require_paths = ["lib"]
|
|
40
39
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nordigen-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nordigen Solutions
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-09-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -16,28 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 2.5.2
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: faraday_middleware
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.2.0
|
|
34
|
-
type: :runtime
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.2.0
|
|
26
|
+
version: 2.5.2
|
|
41
27
|
description: Nordigen official API client for Ruby
|
|
42
28
|
email:
|
|
43
29
|
- support@nordigen.com
|
|
@@ -87,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
73
|
- !ruby/object:Gem::Version
|
|
88
74
|
version: '0'
|
|
89
75
|
requirements: []
|
|
90
|
-
rubygems_version: 3.2
|
|
76
|
+
rubygems_version: 3.1.2
|
|
91
77
|
signing_key:
|
|
92
78
|
specification_version: 4
|
|
93
79
|
summary: Nordigen client for Ruby
|