nordigen_ob_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/nordigen_ob_client.rb +197 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a34a748612b3bf2535faffb6c6d43bad91ff0b94ae75fa1725881814fbee6674
|
4
|
+
data.tar.gz: 2f9e5560099bfd39663deeff53a8f4d17b2a6dc9af4a4f985785ac331559df53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 06f56f9153e732e8cd7c4daeaff5809beb9c5b5e570a974a025b32c705e82abceb18863ce7aae6cf293518e46d686e1865af38a1f646132512484fba1952c22f
|
7
|
+
data.tar.gz: a04466070b4a9c9332a95098f422f254a4b3e5683a2d073dda48b7d6e57519bfe8e9b5b1c9391b64a4b04672d88495616f208497b4012e3b70dad0bc26c47547
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
class NordigenOBClient
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
end
|
9
|
+
|
10
|
+
#############################################################################
|
11
|
+
#
|
12
|
+
# => Name: get_access_token
|
13
|
+
#
|
14
|
+
# => Description: Retrieve the access token that will be used to access all
|
15
|
+
# other endpoints in Nordigen's backend.
|
16
|
+
#
|
17
|
+
# => Parameters: secret_id: The Secret ID part of the credentials,
|
18
|
+
# provided by Nordigen.
|
19
|
+
#
|
20
|
+
# secret_key: The Secret Key part of the credentials,
|
21
|
+
# provided by Nordigen.
|
22
|
+
#
|
23
|
+
# => Returns: The access token
|
24
|
+
#
|
25
|
+
#############################################################################
|
26
|
+
def get_access_token secret_id, secret_key
|
27
|
+
access_token_params = {
|
28
|
+
"secret_id" => secret_id,
|
29
|
+
"secret_key" => secret_key
|
30
|
+
}.to_json
|
31
|
+
|
32
|
+
response_json = RestClient.post("https://ob.nordigen.com/api/v2/token/new/",
|
33
|
+
access_token_params,
|
34
|
+
{content_type: :json, accept: :json})
|
35
|
+
response = JSON.parse(response_json.body)
|
36
|
+
@access_token = response["access"]
|
37
|
+
@access_token
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# => Name: get_banks_by_country
|
43
|
+
#
|
44
|
+
# => Description: Returns a list of the available institutions by country,
|
45
|
+
# including
|
46
|
+
#
|
47
|
+
# => Parameters: country: The selected country, in ISO 3166 format.
|
48
|
+
# Supported countries are EEA countries.
|
49
|
+
#
|
50
|
+
#
|
51
|
+
# => Returns: The list of supported institutions in the selected country.
|
52
|
+
#
|
53
|
+
#############################################################################
|
54
|
+
def get_banks_by_country country
|
55
|
+
request_header = {
|
56
|
+
content_type: :json,
|
57
|
+
accept: :json,
|
58
|
+
authorization: "Bearer #{@access_token}"
|
59
|
+
}
|
60
|
+
|
61
|
+
response = RestClient.get(
|
62
|
+
"https://ob.nordigen.com/api/v2/institutions/?country=#{country}",
|
63
|
+
headers=request_header)
|
64
|
+
|
65
|
+
available_banks = JSON.parse(response.body,
|
66
|
+
:external_encoding => 'iso-8859-1')
|
67
|
+
available_banks
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
#############################################################################
|
72
|
+
#
|
73
|
+
# => Name: list_accounts
|
74
|
+
#
|
75
|
+
# => Description: Return a list of the available accounts connected to the
|
76
|
+
# given user account.
|
77
|
+
#
|
78
|
+
# => Parameters: requisition_id: The id of the requisition (bank login)
|
79
|
+
# for which the parameters will be parsed.
|
80
|
+
#
|
81
|
+
#
|
82
|
+
# => Returns: The list of available accounts.
|
83
|
+
#
|
84
|
+
#############################################################################
|
85
|
+
def list_accounts requisition_id
|
86
|
+
request_header = {
|
87
|
+
content_type: :json,
|
88
|
+
accept: :json,
|
89
|
+
authorization: "Bearer #{@access_token}"
|
90
|
+
}
|
91
|
+
|
92
|
+
response = RestClient.get(
|
93
|
+
"https://ob.nordigen.com/api/v2/requisitions/#{requisition_id}",
|
94
|
+
headers=request_header)
|
95
|
+
accounts = JSON.parse(response.body)
|
96
|
+
accounts
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_account_details account_id
|
100
|
+
request_header = {
|
101
|
+
content_type: :json,
|
102
|
+
accept: :json,
|
103
|
+
authorization: "Bearer #{@access_token}"
|
104
|
+
}
|
105
|
+
|
106
|
+
response = RestClient.get(
|
107
|
+
"https://ob.nordigen.com/api/v2/accounts/#{account_id}/details",
|
108
|
+
headers=request_header)
|
109
|
+
accounts = JSON.parse(response.body)
|
110
|
+
accounts
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def get_account_balances account_id
|
115
|
+
request_header = {
|
116
|
+
content_type: :json,
|
117
|
+
accept: :json,
|
118
|
+
authorization: "Bearer #{@access_token}"
|
119
|
+
}
|
120
|
+
|
121
|
+
response = RestClient.get(
|
122
|
+
"https://ob.nordigen.com/api/v2/accounts/#{account_id}/balances",
|
123
|
+
headers=request_header)
|
124
|
+
accounts = JSON.parse(response.body)
|
125
|
+
accounts
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def get_account_overview account_id
|
130
|
+
request_header = {
|
131
|
+
content_type: :json,
|
132
|
+
accept: :json,
|
133
|
+
authorization: "Bearer #{@access_token}"
|
134
|
+
}
|
135
|
+
|
136
|
+
response = RestClient.get(
|
137
|
+
"https://ob.nordigen.com/api/v2/accounts/#{account_id}",
|
138
|
+
headers=request_header)
|
139
|
+
accounts = JSON.parse(response.body)
|
140
|
+
accounts
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
def get_account_transactions account_id
|
145
|
+
request_header = {
|
146
|
+
content_type: :json,
|
147
|
+
accept: :json,
|
148
|
+
authorization: "Bearer #{@access_token}"
|
149
|
+
}
|
150
|
+
|
151
|
+
response = RestClient.get(
|
152
|
+
"https://ob.nordigen.com/api/v2/accounts/#{account_id}/transactions",
|
153
|
+
headers=request_header)
|
154
|
+
accounts = JSON.parse(response.body)
|
155
|
+
accounts
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
def create_requisition redirect_url, selected_bank_id, reference
|
161
|
+
request_body = {
|
162
|
+
"redirect" => redirect_url,
|
163
|
+
"institution_id" => selected_bank_id,
|
164
|
+
"user_language" => "EN",
|
165
|
+
"reference" => reference
|
166
|
+
}.to_json
|
167
|
+
|
168
|
+
request_header = {
|
169
|
+
content_type: :json,
|
170
|
+
accept: :json,
|
171
|
+
authorization: "Bearer #{@access_token}"
|
172
|
+
}
|
173
|
+
|
174
|
+
response = RestClient.post(
|
175
|
+
"https://ob.nordigen.com/api/v2/requisitions/",
|
176
|
+
request_body,
|
177
|
+
headers=request_header)
|
178
|
+
JSON.parse(response.body)
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
def delete_requisition requisition_id
|
183
|
+
request_header = {
|
184
|
+
content_type: :json,
|
185
|
+
accept: :json,
|
186
|
+
authorization: "Bearer #{@access_token}"
|
187
|
+
}
|
188
|
+
|
189
|
+
response = RestClient.delete(
|
190
|
+
"https://ob.nordigen.com/api/v2/requisitions/#{requisition_id}",
|
191
|
+
request_body,
|
192
|
+
headers=request_header)
|
193
|
+
JSON.parse(response.body)
|
194
|
+
response
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nordigen_ob_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Angelos Kapsimanis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A Ruby client for Nordigen's Open Banking v2.0 API. Look at https://nordigen.com/en/account_information_documenation/api-documention/overview/
|
14
|
+
for more details.
|
15
|
+
email: angelos@neffoss.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/nordigen_ob_client.rb
|
21
|
+
homepage: https://github.com/neffoss/nordigen_ob_client
|
22
|
+
licenses:
|
23
|
+
- Apache-2.0
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.2.32
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Nordigen's Open Banking v2.0 API client
|
44
|
+
test_files: []
|