bridge_bankin 0.1.0 → 0.1.1
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/.github/workflows/{main.yml → ci-analysis.yml} +4 -4
- data/.github/workflows/rubocop-analysis.yml +44 -0
- data/.gitignore +3 -6
- data/.rubocop.yml +0 -3
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +183 -13
- data/bridge_bankin.gemspec +1 -1
- data/lib/bridge_bankin.rb +3 -0
- data/lib/bridge_bankin/account.rb +20 -0
- data/lib/bridge_bankin/api/client.rb +49 -3
- data/lib/bridge_bankin/api/error.rb +12 -0
- data/lib/bridge_bankin/api/resource.rb +5 -2
- data/lib/bridge_bankin/authorization.rb +17 -0
- data/lib/bridge_bankin/bank.rb +18 -0
- data/lib/bridge_bankin/bridge_object.rb +15 -0
- data/lib/bridge_bankin/category.rb +18 -0
- data/lib/bridge_bankin/configuration.rb +9 -0
- data/lib/bridge_bankin/connect.rb +52 -0
- data/lib/bridge_bankin/insight.rb +11 -0
- data/lib/bridge_bankin/item.rb +49 -2
- data/lib/bridge_bankin/object_types.rb +8 -0
- data/lib/bridge_bankin/stock.rb +43 -9
- data/lib/bridge_bankin/transaction.rb +52 -0
- data/lib/bridge_bankin/transfer.rb +53 -0
- data/lib/bridge_bankin/user.rb +76 -4
- data/lib/bridge_bankin/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ddf1d83e8ae1b1ced919dcc5858be9b8b331f25af05ff26824a462b36f6b240
|
4
|
+
data.tar.gz: 22c5bc8aa682d00956bc0f1bfe8c4c710f18626dfbc770ce01cee890603061d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b508b5d4c8d3572bd1db5f85282d9b6da7ca7c1a66b84a7acb5eecff2d94ec5d02791ac7421358085acd615aa65e8d65237a6d9ce603673121c0f3090c9705c8
|
7
|
+
data.tar.gz: fc7df99b3ea68557a473c27d5fd4f6404a3a2cab97cd4ff05cf613f759e8f843d94e9f0fc46213fd7030af231e3380bf11a9e4d06eb7e78dd8c282868c84540f
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name:
|
1
|
+
name: CI
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
@@ -16,9 +16,9 @@ jobs:
|
|
16
16
|
- name: Set up Ruby
|
17
17
|
uses: ruby/setup-ruby@v1
|
18
18
|
with:
|
19
|
-
ruby-version: 2.7
|
19
|
+
ruby-version: 2.7
|
20
20
|
- name: Run the default task
|
21
21
|
run: |
|
22
|
-
gem install bundler
|
22
|
+
gem install bundler
|
23
23
|
bundle install
|
24
|
-
bundle exec
|
24
|
+
bundle exec rspec
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# .github/workflows/rubocop-analysis.yml
|
2
|
+
name: "RuboCop"
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- "*"
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
rubocop:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
fail-fast: false
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- name: Checkout repository
|
20
|
+
uses: actions/checkout@v2
|
21
|
+
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: 2.7
|
26
|
+
|
27
|
+
# This step is not necessary if you add the gem to your Gemfile
|
28
|
+
- name: Install Code Scanning integration
|
29
|
+
run: bundle add code-scanning-rubocop --skip-install
|
30
|
+
|
31
|
+
- name: Install dependencies
|
32
|
+
run: bundle install
|
33
|
+
|
34
|
+
- name: RuboCop run
|
35
|
+
run: |
|
36
|
+
bash -c "
|
37
|
+
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
38
|
+
[[ $? -ne 2 ]]
|
39
|
+
"
|
40
|
+
|
41
|
+
- name: Upload Sarif output
|
42
|
+
uses: github/codeql-action/upload-sarif@v1
|
43
|
+
with:
|
44
|
+
sarif_file: rubocop.sarif
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<img width="500" src="https://user-images.githubusercontent.com/112219/103307983-5fe04500-49df-11eb-9618-1f9704b2f460.png">
|
3
|
+
</p>
|
2
4
|
|
3
|
-
|
5
|
+
<br />
|
4
6
|
|
5
|
-
|
7
|
+
This gem is an **unofficial Ruby client** that consumes the [Bridge by Bankin’ API](https://bridgeapi.io/).
|
8
|
+
|
9
|
+
Thanks to a safe and automated access to bank data, Bridge powered by Bankin’ provides
|
10
|
+
competitive and smart solutions to build conversion-driver financial services.
|
11
|
+
|
12
|
+
You'll find more information about Bridge API in the [official documentations](https://docs.bridgeapi.io/).
|
6
13
|
|
7
14
|
## Installation
|
8
15
|
|
9
|
-
Add this line to your application
|
16
|
+
Add this line to your application’s Gemfile:
|
10
17
|
|
11
18
|
```ruby
|
12
19
|
gem 'bridge_bankin'
|
@@ -22,22 +29,185 @@ Or install it yourself as:
|
|
22
29
|
|
23
30
|
## Usage
|
24
31
|
|
25
|
-
|
32
|
+
### Requirements
|
26
33
|
|
27
|
-
|
34
|
+
To begin using the API with this gem, you need to create an account to the dashboard on the [Bridge website](https://dashboard.bridgeapi.io/signup).
|
35
|
+
Then you’ll have to create a new `application` and generate the required API credentials: a `client_id` and `client_secret`.
|
36
|
+
You can find more information about this process by visiting the [Bridge API Dashboard documentation](https://docs.bridgeapi.io/docs/dashboard).
|
37
|
+
|
38
|
+
### Getting started
|
39
|
+
|
40
|
+
One you have your valid API credential you can now create an initializer in your app like this:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
BridgeBankin.configure do |config|
|
44
|
+
config.api_client_id = ENV["BRIDGE_API_CLIENT_ID"]
|
45
|
+
config.api_client_secret = ENV["BRIDGE_API_CLIENT_SECRET"]
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
Feel free to replace those environment variables by whatever values that work for you.
|
50
|
+
|
51
|
+
Some resources are public (banks and categories) meaning that only provided the `client_id` and `client_secret` are required.
|
52
|
+
Here is an example on how you can use this gem to fetch the banks:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
BridgeBankin::Bank.list
|
56
|
+
=> [#<BridgeBankin::BridgeObject:0x00007fbb0727c620
|
57
|
+
@country_code="DE",
|
58
|
+
@parent_banks=
|
59
|
+
[#<BridgeBankin::BridgeObject:0x00007fbb0727c148
|
60
|
+
@banks=
|
61
|
+
[#<BridgeBankin::Bank:0x00007fbad702f6b8
|
62
|
+
@authentication_type="INTERNAL_CREDS",
|
63
|
+
@automatic_refresh=true,
|
64
|
+
@capabilities=["ais"],
|
65
|
+
@country_code="DE",
|
66
|
+
@deeplink_android=nil,
|
67
|
+
@deeplink_ios=nil,
|
68
|
+
@form=[#<BridgeBankin::BridgeObject:0x00007fbad702cf30 @isNum="0", @label="Email", @maxLength=nil, @type="USER">, #<BridgeBankin::BridgeObject:0x00007fbad702c648 @isNum="0", @label="Password", @maxLength=nil, @type="PWD">],
|
69
|
+
@id=457,
|
70
|
+
@logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
|
71
|
+
@name="N26 (Number 26) DE",
|
72
|
+
@payment_enabled=false,
|
73
|
+
@primary_color=nil,
|
74
|
+
@secondary_color=nil,
|
75
|
+
@transfer_enabled=false>],
|
76
|
+
@display_order=0,
|
77
|
+
@is_highlighted=false,
|
78
|
+
@logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
|
79
|
+
@name="N26 (Number 26) DE">,
|
80
|
+
...]
|
81
|
+
...]
|
82
|
+
...]
|
83
|
+
```
|
84
|
+
|
85
|
+
But the majority of the resources need a logged in user. Here is how to create one using the gem:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
BridgeBankin::User.create(email: "john.doe@email.com", password: "password123!")
|
89
|
+
=> #<BridgeBankin::User:0x00007fbb07c5e990 @email="john.doe@email.com", @uuid="f974389d-1442-48bb-bb5e-ac62d1a96984">
|
90
|
+
```
|
91
|
+
|
92
|
+
Then you can generate an `access_token` for this user by using the `Authorization` class:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
BridgeBankin::Authorization.generate_token(email: "john.doe@email.com", password: "password123!")
|
96
|
+
=> #<BridgeBankin::Authorization:0x00007fbb07967f48 @access_token="58b0195d943f9a3e8433cda7dea48a70339eafc6-5fe7c375-873b-4b0d-bcff-4541c1e19488", @expires_at=2020-12-29 21:35:28.97 UTC>
|
97
|
+
```
|
98
|
+
|
99
|
+
Since the majority of endpoints are private, you’ll need to pass a valid `access_token` each time you request them.
|
100
|
+
Here is how it works with the user we previously created:
|
28
101
|
|
29
|
-
|
102
|
+
```ruby
|
103
|
+
BridgeBankin::Transaction.list(access_token: auth.access_token)
|
104
|
+
=> [#<BridgeBankin::Transaction:0x00007fbb0002d948
|
105
|
+
@account=#<BridgeBankin::Account:0x00007fbb0002c250 @id=22271302>,
|
106
|
+
@amount=-676.0,
|
107
|
+
@category=#<BridgeBankin::Category:0x00007fbb0002c520 @id=79>,
|
108
|
+
@currency_code="EUR",
|
109
|
+
@date=#<Date: 2021-01-02 ((2459217j,0s,0n),+0s,2299161j)>,
|
110
|
+
@description="Achat De Titres",
|
111
|
+
@id=38000214608599,
|
112
|
+
@is_deleted=false,
|
113
|
+
@is_future=true,
|
114
|
+
@raw_description="ACHAT DE TITRES - 020121",
|
115
|
+
@show_client_side=true,
|
116
|
+
@updated_at=2020-12-29 19:40:50.942 UTC>,
|
117
|
+
#<BridgeBankin::Transaction:0x00007fbb00023da8
|
118
|
+
@account=#<BridgeBankin::Account:0x00007fbb000229f8 @id=22271298>,
|
119
|
+
@amount=170.0,
|
120
|
+
@category=#<BridgeBankin::Category:0x00007fbb00022c50 @id=289>,
|
121
|
+
@currency_code="EUR",
|
122
|
+
@date=#<Date: 2021-01-02 ((2459217j,0s,0n),+0s,2299161j)>,
|
123
|
+
@description="Economies",
|
124
|
+
@id=38000214608462,
|
125
|
+
@is_deleted=false,
|
126
|
+
@is_future=true,
|
127
|
+
@raw_description="Economies - 020121",
|
128
|
+
@show_client_side=true,
|
129
|
+
@updated_at=2020-12-29 19:40:49.564 UTC>,
|
130
|
+
...
|
131
|
+
]
|
132
|
+
```
|
133
|
+
|
134
|
+
If you need more information on how the API works or which parameters you can use for a specific query, we really encourage you to consult the great [official guides](https://docs.bridgeapi.io/docs).
|
135
|
+
|
136
|
+
### Parameters
|
137
|
+
|
138
|
+
##### Mandatory parameters
|
139
|
+
|
140
|
+
In some case you'll need to specify some parameters to complete your request.
|
141
|
+
For instance, in order to retrieve a specific `user`, it requires you to pass the user's `UUID`:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
BridgeBankin::User.find(uuid: "f974389d-1442-48bb-bb5e-ac62d1a96984")
|
145
|
+
=> #<BridgeBankin::User:0x00007fbb07febf90 @email="john.doe@email.com", @uuid="f974389d-1442-48bb-bb5e-ac62d1a96984">
|
146
|
+
```
|
147
|
+
|
148
|
+
Note that in some case, the API uses basic sequential `IDs` instead of `UUIDs`. In that case just replace `uuid` key by `id`:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
BridgeBankin::Bank.find(id: 457)
|
152
|
+
=> #<BridgeBankin::Bank:0x00007fbb07ec64d0
|
153
|
+
@authentication_type="INTERNAL_CREDS",
|
154
|
+
@automatic_refresh=true,
|
155
|
+
@capabilities=["ais"],
|
156
|
+
@country_code="DE",
|
157
|
+
@deeplink_android=nil,
|
158
|
+
@deeplink_ios=nil,
|
159
|
+
@form=[#<BridgeBankin::BridgeObject:0x00007fbb07ec5968 @isNum="0", @label="Email", @maxLength=nil, @type="USER">, #<BridgeBankin::BridgeObject:0x00007fbb07ec54b8 @isNum="0", @label="Password", @maxLength=nil, @type="PWD">],
|
160
|
+
@id=457,
|
161
|
+
@logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
|
162
|
+
@name="N26 (Number 26) DE",
|
163
|
+
@payment_enabled=false,
|
164
|
+
@primary_color=nil,
|
165
|
+
@secondary_color=nil,
|
166
|
+
@transfer_enabled=false>
|
167
|
+
```
|
168
|
+
|
169
|
+
##### Optional parameters
|
30
170
|
|
31
|
-
|
171
|
+
The gem resources also allows you to pass any optional parameters supported by the API (see [Official Documentation](https://docs.bridgeapi.io/docs/overview)).
|
172
|
+
To do so, just pass them as `named parameters` in corresponding resource class method:
|
173
|
+
|
174
|
+
```ruby
|
175
|
+
BridgeBankin::Bank.list(limit: 1)
|
176
|
+
=> [#<BridgeBankin::BridgeObject:0x00007fbb07b4c228
|
177
|
+
@country_code="FR",
|
178
|
+
@parent_banks=
|
179
|
+
[#<BridgeBankin::BridgeObject:0x00007fbb07b4c070
|
180
|
+
@banks=
|
181
|
+
[#<BridgeBankin::Bank:0x00007fbb07b27d38
|
182
|
+
@authentication_type="INTERNAL_CREDS",
|
183
|
+
@automatic_refresh=true,
|
184
|
+
@capabilities=["ais"],
|
185
|
+
@country_code="FR",
|
186
|
+
@deeplink_android=nil,
|
187
|
+
@deeplink_ios=nil,
|
188
|
+
@form=[#<BridgeBankin::BridgeObject:0x00007fbb07b271a8 @isNum="1", @label="Identifiant", @maxLength=nil, @type="USER">, #<BridgeBankin::BridgeObject:0x00007fbb07b26cd0 @isNum="0", @label="Mot de passe", @maxLength=nil, @type="PWD">],
|
189
|
+
@id=486,
|
190
|
+
@logo_url="https://web.bankin.com/img/banks-logo/france/themis.png",
|
191
|
+
@name="Themis Banque",
|
192
|
+
@payment_enabled=false,
|
193
|
+
@primary_color=nil,
|
194
|
+
@secondary_color=nil,
|
195
|
+
@transfer_enabled=false>],
|
196
|
+
@display_order=0,
|
197
|
+
@is_highlighted=false,
|
198
|
+
@logo_url="https://web.bankin.com/img/banks-logo/france/themis.png",
|
199
|
+
@name="Themis Banque">]>]
|
200
|
+
```
|
201
|
+
|
202
|
+
## Development
|
203
|
+
|
204
|
+
If you need more detailed informations regarding the gem source code you can find more in the official [RubyDoc](https://rubydoc.info/github/neatops/bridge_bankin/main).
|
32
205
|
|
33
206
|
## Contributing
|
34
207
|
|
35
|
-
|
208
|
+
We're convinced this gem could be improved a lot or simply not cover every needs you have. That's why contributions of any kind is very encouraged.
|
209
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/neatops/bridge_bankin. This project is intended to be a safe, welcoming space for collaboration.
|
36
210
|
|
37
211
|
## License
|
38
212
|
|
39
213
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
-
|
41
|
-
## Code of Conduct
|
42
|
-
|
43
|
-
Everyone interacting in the BridgeBankin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bridge_bankin/blob/master/CODE_OF_CONDUCT.md).
|
data/bridge_bankin.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Olivier Buffon"]
|
9
9
|
spec.email = ["olivier@buffon.dev"]
|
10
10
|
|
11
|
-
spec.summary = "Unofficial client to consume Bridge by Bankin’ API"
|
11
|
+
spec.summary = "Unofficial Ruby client to consume Bridge by Bankin’ API"
|
12
12
|
|
13
13
|
spec.description = "Thanks to a safe and automated access to bank data, Bridge powered by Bankin’ provides " \
|
14
14
|
"competitive and smart solutions to build conversion-driver financial services."
|
data/lib/bridge_bankin.rb
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module BridgeBankin
|
4
|
+
#
|
5
|
+
# Account resource
|
6
|
+
#
|
4
7
|
class Account < BridgeObject
|
5
8
|
RESOURCE_TYPE = "account"
|
6
9
|
|
7
10
|
class << self
|
8
11
|
include API::Resource
|
9
12
|
|
13
|
+
#
|
14
|
+
# List all logged in user accounts
|
15
|
+
#
|
16
|
+
# @param [String] access_token the access token provided during the user authentication
|
17
|
+
# @param [Hash] params any params that might be required (or optional) to communicate with the API
|
18
|
+
#
|
19
|
+
# @return [Array<Account>] the user accounts
|
20
|
+
#
|
10
21
|
def list(access_token:, **params)
|
11
22
|
protected_resource(access_token) do
|
12
23
|
data = api_client.get("/v2/accounts", params)
|
@@ -14,6 +25,15 @@ module BridgeBankin
|
|
14
25
|
end
|
15
26
|
end
|
16
27
|
|
28
|
+
#
|
29
|
+
# Retrieve a single account for logged in user
|
30
|
+
#
|
31
|
+
# @param [Integer] id the id of the requested resource
|
32
|
+
# @param [String] access_token the access token provided during the user authentication
|
33
|
+
# @param [Hash] params any params that might be required (or optional) to communicate with the API
|
34
|
+
#
|
35
|
+
# @return [Account] the user accounts
|
36
|
+
#
|
17
37
|
def find(id:, access_token:, **params)
|
18
38
|
protected_resource(access_token) do
|
19
39
|
data = api_client.get("/v2/accounts/#{id}", params)
|
@@ -8,6 +8,9 @@ require "bridge_bankin/api/error"
|
|
8
8
|
|
9
9
|
module BridgeBankin
|
10
10
|
module API
|
11
|
+
#
|
12
|
+
# Allows to request the Bridge API using Ruby native net/http library
|
13
|
+
#
|
11
14
|
class Client
|
12
15
|
HTTP_VERBS_MAP = {
|
13
16
|
get: Net::HTTP::Get,
|
@@ -18,18 +21,56 @@ module BridgeBankin
|
|
18
21
|
|
19
22
|
attr_accessor :access_token
|
20
23
|
|
24
|
+
#
|
25
|
+
# Handles a GET request
|
26
|
+
#
|
27
|
+
# @param [String] path the API endpoint PATH to query
|
28
|
+
# @param [Hash] params any params that might be required (or optional) to communicate with the API
|
29
|
+
#
|
30
|
+
# @return [Hash] the parsed API response
|
31
|
+
#
|
32
|
+
# @raise [API::Error] expectation if API responding with any error
|
33
|
+
#
|
21
34
|
def get(path, **params)
|
22
35
|
request :get, path, params
|
23
36
|
end
|
24
37
|
|
38
|
+
#
|
39
|
+
# Handles a POST request
|
40
|
+
#
|
41
|
+
# @param (see #get)
|
42
|
+
#
|
43
|
+
# @return (see #get)
|
44
|
+
#
|
45
|
+
# @raise (see #get)
|
46
|
+
#
|
47
|
+
|
25
48
|
def post(path, **params)
|
26
49
|
request :post, path, params
|
27
50
|
end
|
28
51
|
|
52
|
+
#
|
53
|
+
# Handles a PUT request
|
54
|
+
#
|
55
|
+
# @param (see #get)
|
56
|
+
#
|
57
|
+
# @return (see #get)
|
58
|
+
#
|
59
|
+
# @raise (see #get)
|
60
|
+
#
|
29
61
|
def put(path, **params)
|
30
62
|
request :put, path, params
|
31
63
|
end
|
32
64
|
|
65
|
+
#
|
66
|
+
# Handles a DELETE request
|
67
|
+
#
|
68
|
+
# @param (see #get)
|
69
|
+
#
|
70
|
+
# @return (see #get)
|
71
|
+
#
|
72
|
+
# @raise (see #get)
|
73
|
+
#
|
33
74
|
def delete(path, **params)
|
34
75
|
request :delete, path, params
|
35
76
|
end
|
@@ -48,9 +89,14 @@ module BridgeBankin
|
|
48
89
|
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
49
90
|
api_response = http.request(yield)
|
50
91
|
|
51
|
-
|
52
|
-
|
53
|
-
|
92
|
+
case api_response.code
|
93
|
+
when "200", "201"
|
94
|
+
parse_response_body(api_response.body)
|
95
|
+
when "204"
|
96
|
+
{}
|
97
|
+
else
|
98
|
+
handle_error(api_response)
|
99
|
+
end
|
54
100
|
end
|
55
101
|
end
|
56
102
|
|