bridge_bankin 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfe54b48509650b463422657a08f719b65ddbdd67f02c51acfb02cde720cf795
4
- data.tar.gz: 789e29bc5b5f95a3a9dac2954c17c95a5a5420cff9fffd45e46d4dde85bfa0ad
3
+ metadata.gz: 4a9b2d23a566212f859c98a3d51351c3b66ed9ce1cc726e6b6529cbbaa7d00cc
4
+ data.tar.gz: cabf9ebc60c09b0aad07bd3138581f8f0dfbeeeb82009486b9f47ff7f1cde324
5
5
  SHA512:
6
- metadata.gz: 8808c5e9381f0b3c79cab3c93663561e1f4e8688c172b752a39e02885694b910f669a026822f134d2e9c741400e31438af592e2481b794fe044f9c312ca3d9b4
7
- data.tar.gz: 129b232bd2b76a61616deec2f430d1d3b59c3523f4cf802d36bf0ac142548124f40a648fb53f7f2b69e549cd629f6bfec196a478e5a6aa362432fcf94e310c3f
6
+ metadata.gz: cc8f0d7735714f22fb50db94d29a6056659dc44bf3de4df4fc9dde283061f81be9c3bd23d8c2cc5ce4640beb13c69f172e0056d3ff16e8f3dd93ccffcbb45fd6
7
+ data.tar.gz: d688ca09401e5e1fdbb80245f2774b84568b198b5eeb0cff2dc011daa831077406fbe9578361f95bef6571c59f484dde1d2dc67f738cc75ad6b98a53412aaaa4
@@ -1,4 +1,4 @@
1
- name: Ruby
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.2
19
+ ruby-version: 3.0.0
20
20
  - name: Run the default task
21
21
  run: |
22
- gem install bundler -v 2.2.1
22
+ gem install bundler
23
23
  bundle install
24
- bundle exec rake
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: 3.0.0
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
@@ -1,13 +1,11 @@
1
+ .env
2
+ .rspec_status
3
+ /_yardoc/
1
4
  /.bundle/
2
5
  /.yardoc
3
- /_yardoc/
4
6
  /coverage/
5
7
  /doc/
6
8
  /pkg/
7
9
  /spec/reports/
8
10
  /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- .env
11
+ /.idea
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.7
6
+ TargetRubyVersion: 3.0.0
7
7
  NewCops: enable
8
8
 
9
9
  Style/StringLiterals:
@@ -17,9 +17,6 @@ Style/StringLiteralsInInterpolation:
17
17
  Layout/LineLength:
18
18
  Max: 120
19
19
 
20
- Style/Documentation:
21
- Enabled: false
22
-
23
20
  Metrics/BlockLength:
24
21
  Enabled: false
25
22
 
@@ -43,3 +40,9 @@ RSpec/SubjectStub:
43
40
 
44
41
  RSpec/MultipleDescribes:
45
42
  Enabled: false
43
+
44
+ RSpec/StubbedMock:
45
+ Enabled: false
46
+
47
+ RSpec/MultipleExpectations:
48
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_bankin (0.1.0)
4
+ bridge_bankin (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -12,7 +12,7 @@ GEM
12
12
  minitest (>= 5.1)
13
13
  tzinfo (~> 2.0)
14
14
  zeitwerk (~> 2.3)
15
- addressable (2.7.0)
15
+ addressable (2.8.0)
16
16
  public_suffix (>= 2.0.2, < 5.0)
17
17
  ast (2.4.1)
18
18
  awesome_print (1.8.0)
@@ -36,7 +36,7 @@ GEM
36
36
  rainbow (3.0.0)
37
37
  rake (13.0.3)
38
38
  regexp_parser (2.0.3)
39
- rexml (3.2.4)
39
+ rexml (3.2.5)
40
40
  rspec (3.10.0)
41
41
  rspec-core (~> 3.10.0)
42
42
  rspec-expectations (~> 3.10.0)
@@ -80,6 +80,7 @@ GEM
80
80
  zeitwerk (2.4.2)
81
81
 
82
82
  PLATFORMS
83
+ ruby
83
84
  x86_64-darwin-19
84
85
 
85
86
  DEPENDENCIES
@@ -96,4 +97,4 @@ DEPENDENCIES
96
97
  webmock
97
98
 
98
99
  BUNDLED WITH
99
- 2.2.1
100
+ 2.2.3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Olivier Buffon
3
+ Copyright (c) 2020 Neatops
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
@@ -1,12 +1,34 @@
1
- # BridgeBankin
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bridge_bankin`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
1
+ <p align="center">
2
+ <img width="500" src="https://user-images.githubusercontent.com/112219/103307983-5fe04500-49df-11eb-9618-1f9704b2f460.png" alt="Bankin Bridge Logo">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="https://badge.fury.io/rb/bridge_bankin">
7
+ <img src="https://badge.fury.io/rb/bridge_bankin.svg" alt="Gem Version">
8
+ </a>
9
+ <a href="https://github.com/neatops/bridge_bankin/actions?query=workflow%3ACI">
10
+ <img src="https://github.com/neatops/bridge_bankin/workflows/CI/badge.svg" alt="CI Status">
11
+ </a>
12
+ <a href="https://github.com/neatops/bridge_bankin/actions?query=workflow%3ARuboCop">
13
+ <img src="https://github.com/neatops/bridge_bankin/workflows/RuboCop/badge.svg" alt="Rubocop Status">
14
+ </a>
15
+ <a href="https://rubydoc.info/github/neatops/bridge_bankin/main">
16
+ <img src="https://img.shields.io/badge/yard-docs-blue.svg" alt="RubyDoc Link">
17
+ </a>
18
+ </p>
19
+
20
+ <br />
21
+
22
+ This gem is an **unofficial Ruby client** that consumes the [Bridge by Bankin’ API](https://bridgeapi.io/).
23
+
24
+ Thanks to a safe and automated access to bank data, Bridge powered by Bankin’ provides
25
+ competitive and smart solutions to build conversion-driver financial services.
26
+
27
+ You'll find more information about Bridge API in the [official documentations](https://docs.bridgeapi.io/).
6
28
 
7
29
  ## Installation
8
30
 
9
- Add this line to your application's Gemfile:
31
+ Add this line to your applications Gemfile:
10
32
 
11
33
  ```ruby
12
34
  gem 'bridge_bankin'
@@ -22,22 +44,185 @@ Or install it yourself as:
22
44
 
23
45
  ## Usage
24
46
 
25
- TODO: Write usage instructions here
47
+ ### Requirements
26
48
 
27
- ## Development
49
+ 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).
50
+ Then you’ll have to create a new `application` and generate the required API credentials: a `client_id` and `client_secret`.
51
+ You can find more information about this process by visiting the [Bridge API Dashboard documentation](https://docs.bridgeapi.io/docs/dashboard).
52
+
53
+ ### Getting started
54
+
55
+ One you have your valid API credential you can now create an initializer in your app like this:
56
+
57
+ ```ruby
58
+ BridgeBankin.configure do |config|
59
+ config.api_client_id = ENV["BRIDGE_API_CLIENT_ID"]
60
+ config.api_client_secret = ENV["BRIDGE_API_CLIENT_SECRET"]
61
+ end
62
+ ```
63
+
64
+ Feel free to replace those environment variables by whatever values that work for you.
65
+
66
+ Some resources are public (banks and categories) meaning that only provided the `client_id` and `client_secret` are required.
67
+ Here is an example on how you can use this gem to fetch the banks:
68
+
69
+ ```ruby
70
+ BridgeBankin::Bank.list
71
+ => [#<BridgeBankin::BridgeObject:0x00007fbb0727c620
72
+ @country_code="DE",
73
+ @parent_banks=
74
+ [#<BridgeBankin::BridgeObject:0x00007fbb0727c148
75
+ @banks=
76
+ [#<BridgeBankin::Bank:0x00007fbad702f6b8
77
+ @authentication_type="INTERNAL_CREDS",
78
+ @automatic_refresh=true,
79
+ @capabilities=["ais"],
80
+ @country_code="DE",
81
+ @deeplink_android=nil,
82
+ @deeplink_ios=nil,
83
+ @form=[#<BridgeBankin::BridgeObject:0x00007fbad702cf30 @isNum="0", @label="Email", @maxLength=nil, @type="USER">, #<BridgeBankin::BridgeObject:0x00007fbad702c648 @isNum="0", @label="Password", @maxLength=nil, @type="PWD">],
84
+ @id=457,
85
+ @logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
86
+ @name="N26 (Number 26) DE",
87
+ @payment_enabled=false,
88
+ @primary_color=nil,
89
+ @secondary_color=nil,
90
+ @transfer_enabled=false>],
91
+ @display_order=0,
92
+ @is_highlighted=false,
93
+ @logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
94
+ @name="N26 (Number 26) DE">,
95
+ ...]
96
+ ...]
97
+ ...]
98
+ ```
99
+
100
+ But the majority of the resources need a logged in user. Here is how to create one using the gem:
101
+
102
+ ```ruby
103
+ BridgeBankin::User.create(email: "john.doe@email.com", password: "password123!")
104
+ => #<BridgeBankin::User:0x00007fbb07c5e990 @email="john.doe@email.com", @uuid="f974389d-1442-48bb-bb5e-ac62d1a96984">
105
+ ```
106
+
107
+ Then you can generate an `access_token` for this user by using the `Authorization` class:
108
+
109
+ ```ruby
110
+ BridgeBankin::Authorization.generate_token(email: "john.doe@email.com", password: "password123!")
111
+ => #<BridgeBankin::Authorization:0x00007fbb07967f48 @access_token="58b0195d943f9a3e8433cda7dea48a70339eafc6-5fe7c375-873b-4b0d-bcff-4541c1e19488", @expires_at=2020-12-29 21:35:28.97 UTC>
112
+ ```
113
+
114
+ Since the majority of endpoints are private, you’ll need to pass a valid `access_token` each time you request them.
115
+ Here is how it works with the user we previously created:
28
116
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
117
+ ```ruby
118
+ BridgeBankin::Transaction.list(access_token: auth.access_token)
119
+ => [#<BridgeBankin::Transaction:0x00007fbb0002d948
120
+ @account=#<BridgeBankin::Account:0x00007fbb0002c250 @id=22271302>,
121
+ @amount=-676.0,
122
+ @category=#<BridgeBankin::Category:0x00007fbb0002c520 @id=79>,
123
+ @currency_code="EUR",
124
+ @date=#<Date: 2021-01-02 ((2459217j,0s,0n),+0s,2299161j)>,
125
+ @description="Achat De Titres",
126
+ @id=38000214608599,
127
+ @is_deleted=false,
128
+ @is_future=true,
129
+ @raw_description="ACHAT DE TITRES - 020121",
130
+ @show_client_side=true,
131
+ @updated_at=2020-12-29 19:40:50.942 UTC>,
132
+ #<BridgeBankin::Transaction:0x00007fbb00023da8
133
+ @account=#<BridgeBankin::Account:0x00007fbb000229f8 @id=22271298>,
134
+ @amount=170.0,
135
+ @category=#<BridgeBankin::Category:0x00007fbb00022c50 @id=289>,
136
+ @currency_code="EUR",
137
+ @date=#<Date: 2021-01-02 ((2459217j,0s,0n),+0s,2299161j)>,
138
+ @description="Economies",
139
+ @id=38000214608462,
140
+ @is_deleted=false,
141
+ @is_future=true,
142
+ @raw_description="Economies - 020121",
143
+ @show_client_side=true,
144
+ @updated_at=2020-12-29 19:40:49.564 UTC>,
145
+ ...
146
+ ]
147
+ ```
148
+
149
+ 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).
150
+
151
+ ### Parameters
152
+
153
+ ##### Mandatory parameters
154
+
155
+ In some case you'll need to specify some parameters to complete your request.
156
+ For instance, in order to retrieve a specific `user`, it requires you to pass the user's `UUID`:
157
+
158
+ ```ruby
159
+ BridgeBankin::User.find(uuid: "f974389d-1442-48bb-bb5e-ac62d1a96984")
160
+ => #<BridgeBankin::User:0x00007fbb07febf90 @email="john.doe@email.com", @uuid="f974389d-1442-48bb-bb5e-ac62d1a96984">
161
+ ```
162
+
163
+ Note that in some case, the API uses basic sequential `IDs` instead of `UUIDs`. In that case just replace `uuid` key by `id`:
164
+
165
+ ```ruby
166
+ BridgeBankin::Bank.find(id: 457)
167
+ => #<BridgeBankin::Bank:0x00007fbb07ec64d0
168
+ @authentication_type="INTERNAL_CREDS",
169
+ @automatic_refresh=true,
170
+ @capabilities=["ais"],
171
+ @country_code="DE",
172
+ @deeplink_android=nil,
173
+ @deeplink_ios=nil,
174
+ @form=[#<BridgeBankin::BridgeObject:0x00007fbb07ec5968 @isNum="0", @label="Email", @maxLength=nil, @type="USER">, #<BridgeBankin::BridgeObject:0x00007fbb07ec54b8 @isNum="0", @label="Password", @maxLength=nil, @type="PWD">],
175
+ @id=457,
176
+ @logo_url="https://web.bankin.com/img/banks-logo/neo/04N26@2x.png",
177
+ @name="N26 (Number 26) DE",
178
+ @payment_enabled=false,
179
+ @primary_color=nil,
180
+ @secondary_color=nil,
181
+ @transfer_enabled=false>
182
+ ```
183
+
184
+ ##### Optional parameters
30
185
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
186
+ The gem resources also allows you to pass any optional parameters supported by the API (see [Official Documentation](https://docs.bridgeapi.io/docs/overview)).
187
+ To do so, just pass them as `named parameters` in corresponding resource class method:
188
+
189
+ ```ruby
190
+ BridgeBankin::Bank.list(limit: 1)
191
+ => [#<BridgeBankin::BridgeObject:0x00007fbb07b4c228
192
+ @country_code="FR",
193
+ @parent_banks=
194
+ [#<BridgeBankin::BridgeObject:0x00007fbb07b4c070
195
+ @banks=
196
+ [#<BridgeBankin::Bank:0x00007fbb07b27d38
197
+ @authentication_type="INTERNAL_CREDS",
198
+ @automatic_refresh=true,
199
+ @capabilities=["ais"],
200
+ @country_code="FR",
201
+ @deeplink_android=nil,
202
+ @deeplink_ios=nil,
203
+ @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">],
204
+ @id=486,
205
+ @logo_url="https://web.bankin.com/img/banks-logo/france/themis.png",
206
+ @name="Themis Banque",
207
+ @payment_enabled=false,
208
+ @primary_color=nil,
209
+ @secondary_color=nil,
210
+ @transfer_enabled=false>],
211
+ @display_order=0,
212
+ @is_highlighted=false,
213
+ @logo_url="https://web.bankin.com/img/banks-logo/france/themis.png",
214
+ @name="Themis Banque">]>]
215
+ ```
216
+
217
+ ## Development
218
+
219
+ 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
220
 
33
221
  ## Contributing
34
222
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bridge_bankin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/bridge_bankin/blob/master/CODE_OF_CONDUCT.md).
223
+ 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.
224
+ 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
225
 
37
226
  ## License
38
227
 
39
228
  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).
@@ -8,14 +8,14 @@ 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."
15
15
 
16
16
  spec.homepage = "https://github.com/neatops/bridge_bankin"
17
17
  spec.license = "MIT"
18
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
19
19
 
20
20
  spec.metadata["homepage_uri"] = spec.homepage
21
21
  spec.metadata["source_code_uri"] = spec.homepage
data/lib/bridge_bankin.rb CHANGED
@@ -15,5 +15,8 @@ require "bridge_bankin/object_types"
15
15
  # Resources
16
16
  require "bridge_bankin/resources"
17
17
 
18
+ #
19
+ # BridgeBankin main module
20
+ #
18
21
  module BridgeBankin
19
22
  end
@@ -1,23 +1,44 @@
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
- data = api_client.get("/v2/accounts", params)
13
- convert_to_bridge_object(data)
23
+ data = api_client.get("/v2/accounts", **params)
24
+ # binding.pry
25
+ convert_to_bridge_object(**data)
14
26
  end
15
27
  end
16
28
 
29
+ #
30
+ # Retrieve a single account for logged in user
31
+ #
32
+ # @param [Integer] id the id of the requested resource
33
+ # @param [String] access_token the access token provided during the user authentication
34
+ # @param [Hash] params any params that might be required (or optional) to communicate with the API
35
+ #
36
+ # @return [Account] the user accounts
37
+ #
17
38
  def find(id:, access_token:, **params)
18
39
  protected_resource(access_token) do
19
- data = api_client.get("/v2/accounts/#{id}", params)
20
- convert_to_bridge_object(data)
40
+ data = api_client.get("/v2/accounts/#{id}", **params)
41
+ convert_to_bridge_object(**data)
21
42
  end
22
43
  end
23
44
  end