fintecture 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +17 -17
  3. data/.rspec +3 -3
  4. data/.travis.yml +7 -7
  5. data/CODE_OF_CONDUCT.md +74 -74
  6. data/Gemfile +8 -8
  7. data/Gemfile.lock +59 -59
  8. data/LICENSE.txt +674 -674
  9. data/README.md +407 -407
  10. data/Rakefile +8 -8
  11. data/bin/console +15 -15
  12. data/bin/setup +8 -8
  13. data/exemples/ais.rb +53 -53
  14. data/exemples/config_ais.json +7 -7
  15. data/exemples/config_pis.json +5 -5
  16. data/exemples/pis.rb +148 -148
  17. data/exemples/ressources.rb +23 -23
  18. data/fintecture.gemspec +44 -44
  19. data/lib/fintecture/ais_client.rb +94 -94
  20. data/lib/fintecture/api/ais/account_holders.rb +61 -61
  21. data/lib/fintecture/api/ais/accounts.rb +63 -63
  22. data/lib/fintecture/api/ais/authorize.rb +72 -72
  23. data/lib/fintecture/api/ais/authorize_decoupled.rb +68 -68
  24. data/lib/fintecture/api/ais/connect.rb +65 -65
  25. data/lib/fintecture/api/ais/delete_customer.rb +53 -53
  26. data/lib/fintecture/api/ais/transactions.rb +64 -64
  27. data/lib/fintecture/api/auth/authentication.rb +78 -78
  28. data/lib/fintecture/api/pis/connect.rb +77 -77
  29. data/lib/fintecture/api/pis/initiate.rb +52 -52
  30. data/lib/fintecture/api/pis/payments.rb +48 -48
  31. data/lib/fintecture/api/pis/refund.rb +67 -67
  32. data/lib/fintecture/api/pis/request_to_pay.rb +63 -63
  33. data/lib/fintecture/api/pis/settlements.rb +50 -50
  34. data/lib/fintecture/api/ressources/applications.rb +57 -57
  35. data/lib/fintecture/api/ressources/providers.rb +61 -61
  36. data/lib/fintecture/api/ressources/test_accounts.rb +60 -60
  37. data/lib/fintecture/base_url.rb +26 -26
  38. data/lib/fintecture/endpoints/ais.rb +17 -17
  39. data/lib/fintecture/endpoints/authentication.rb +13 -13
  40. data/lib/fintecture/endpoints/pis.rb +16 -16
  41. data/lib/fintecture/endpoints/ressources.rb +13 -13
  42. data/lib/fintecture/exceptions.rb +75 -72
  43. data/lib/fintecture/faraday/authentication/connection.rb +140 -140
  44. data/lib/fintecture/pis_client.rb +100 -100
  45. data/lib/fintecture/utils/constants.rb +11 -11
  46. data/lib/fintecture/utils/crypto.rb +75 -75
  47. data/lib/fintecture/utils/date.rb +15 -15
  48. data/lib/fintecture/utils/validation.rb +32 -32
  49. data/lib/fintecture/version.rb +5 -5
  50. data/lib/fintecture.rb +65 -65
  51. metadata +8 -8
@@ -1,94 +1,94 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fintecture/api/ais/connect'
4
- require 'fintecture/api/ais/accounts'
5
- require 'fintecture/api/ais/transactions'
6
- require 'fintecture/api/ais/account_holders'
7
- require 'fintecture/api/ais/delete_customer'
8
- require 'fintecture/api/ais/authorize'
9
- require 'fintecture/api/ais/authorize_decoupled'
10
-
11
- module Fintecture
12
- class AisClient
13
- @environment = 'sandbox'
14
- @environments = %w[local sandbox production].freeze
15
-
16
- def initialize(config)
17
- @app_id = config[:app_id]
18
- @app_secret = config[:app_secret]
19
- @private_key = config[:private_key]
20
-
21
- environment = config[:environment].downcase
22
- unless environment.include?(environment)
23
- raise "#{environment} not a valid environment, options are [#{environment.join(', ')}]"
24
- end
25
-
26
- @environment = environment
27
- end
28
-
29
- # Getters
30
- attr_reader :app_id, :app_secret, :private_key, :environment, :token, :token_expires_in, :refresh_token
31
-
32
- # Methodes
33
- def connect(state, redirect_uri, scope = nil)
34
- res = Fintecture::Ais::Connect.generate self, state, redirect_uri, scope
35
-
36
- JSON.parse res.body
37
- end
38
-
39
- def generate_token(auth_code)
40
- res = Fintecture::Authentication.get_access_token self, auth_code
41
- body = JSON.parse res.body
42
- @token = body['access_token']
43
- @token_expires_in = body['expires_in']
44
- @refresh_token = body['refresh_token']
45
-
46
- body
47
- end
48
-
49
- def generate_refresh_token(refresh_token = nil)
50
- res = Fintecture::Authentication.refresh_token self, (refresh_token || @refresh_token)
51
- body = JSON.parse res.body
52
- @token = body['access_token']
53
-
54
- body
55
- end
56
-
57
- def accounts(customer_id:, account_id: nil, remove_nulls: nil, withBalances: nil)
58
- res = Fintecture::Ais::Accounts.get self, customer_id, account_id, remove_nulls, withBalances
59
-
60
- JSON.parse res.body
61
- end
62
-
63
- def transactions(customer_id:, account_id:, remove_nulls: nil, convert_dates: nil, filters: nil)
64
- res = Fintecture::Ais::Transactions.get self, customer_id, account_id, remove_nulls, convert_dates, filters
65
-
66
- JSON.parse res.body
67
- end
68
-
69
- def account_holders(customer_id:, remove_nulls: nil)
70
- res = Fintecture::Ais::AccountHolders.get self, customer_id, remove_nulls
71
-
72
- JSON.parse res.body
73
- end
74
-
75
- def delete_customer(customer_id:)
76
- res = Fintecture::Ais::DeleteCustomer.delete self, customer_id
77
-
78
- JSON.parse res.body
79
- end
80
-
81
- def authorize(provider_id:, redirect_uri:, app_id_auth: false, state: nil, x_psu_id: nil, x_psu_ip_address: nil)
82
- res = Fintecture::Ais::Authorize.get self, app_id_auth, provider_id, redirect_uri, state, x_psu_id,
83
- x_psu_ip_address
84
-
85
- JSON.parse res.body
86
- end
87
-
88
- def authorize_decoupled(provider_id:, polling_id:, app_id_auth: false)
89
- res = Fintecture::Ais::AuthorizeDecoupled.get self, app_id_auth, provider_id, polling_id
90
-
91
- JSON.parse res.body
92
- end
93
- end
94
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fintecture/api/ais/connect'
4
+ require 'fintecture/api/ais/accounts'
5
+ require 'fintecture/api/ais/transactions'
6
+ require 'fintecture/api/ais/account_holders'
7
+ require 'fintecture/api/ais/delete_customer'
8
+ require 'fintecture/api/ais/authorize'
9
+ require 'fintecture/api/ais/authorize_decoupled'
10
+
11
+ module Fintecture
12
+ class AisClient
13
+ @environment = 'sandbox'
14
+ @environments = %w[local sandbox production].freeze
15
+
16
+ def initialize(config)
17
+ @app_id = config[:app_id]
18
+ @app_secret = config[:app_secret]
19
+ @private_key = config[:private_key]
20
+
21
+ environment = config[:environment].downcase
22
+ unless environment.include?(environment)
23
+ raise "#{environment} not a valid environment, options are [#{environment.join(', ')}]"
24
+ end
25
+
26
+ @environment = environment
27
+ end
28
+
29
+ # Getters
30
+ attr_reader :app_id, :app_secret, :private_key, :environment, :token, :token_expires_in, :refresh_token
31
+
32
+ # Methodes
33
+ def connect(state, redirect_uri, scope = nil)
34
+ res = Fintecture::Ais::Connect.generate self, state, redirect_uri, scope
35
+
36
+ JSON.parse res.body
37
+ end
38
+
39
+ def generate_token(auth_code)
40
+ res = Fintecture::Authentication.get_access_token self, auth_code
41
+ body = JSON.parse res.body
42
+ @token = body['access_token']
43
+ @token_expires_in = body['expires_in']
44
+ @refresh_token = body['refresh_token']
45
+
46
+ body
47
+ end
48
+
49
+ def generate_refresh_token(refresh_token = nil)
50
+ res = Fintecture::Authentication.refresh_token self, (refresh_token || @refresh_token)
51
+ body = JSON.parse res.body
52
+ @token = body['access_token']
53
+
54
+ body
55
+ end
56
+
57
+ def accounts(customer_id:, account_id: nil, remove_nulls: nil, withBalances: nil)
58
+ res = Fintecture::Ais::Accounts.get self, customer_id, account_id, remove_nulls, withBalances
59
+
60
+ JSON.parse res.body
61
+ end
62
+
63
+ def transactions(customer_id:, account_id:, remove_nulls: nil, convert_dates: nil, filters: nil)
64
+ res = Fintecture::Ais::Transactions.get self, customer_id, account_id, remove_nulls, convert_dates, filters
65
+
66
+ JSON.parse res.body
67
+ end
68
+
69
+ def account_holders(customer_id:, remove_nulls: nil)
70
+ res = Fintecture::Ais::AccountHolders.get self, customer_id, remove_nulls
71
+
72
+ JSON.parse res.body
73
+ end
74
+
75
+ def delete_customer(customer_id:)
76
+ res = Fintecture::Ais::DeleteCustomer.delete self, customer_id
77
+
78
+ JSON.parse res.body
79
+ end
80
+
81
+ def authorize(provider_id:, redirect_uri:, app_id_auth: false, state: nil, x_psu_id: nil, x_psu_ip_address: nil)
82
+ res = Fintecture::Ais::Authorize.get self, app_id_auth, provider_id, redirect_uri, state, x_psu_id,
83
+ x_psu_ip_address
84
+
85
+ JSON.parse res.body
86
+ end
87
+
88
+ def authorize_decoupled(provider_id:, polling_id:, app_id_auth: false)
89
+ res = Fintecture::Ais::AuthorizeDecoupled.get self, app_id_auth, provider_id, polling_id
90
+
91
+ JSON.parse res.body
92
+ end
93
+ end
94
+ end
@@ -1,61 +1,61 @@
1
- # frozen_string_literal: true
2
-
3
- require 'base64'
4
- require 'json'
5
- require 'faraday'
6
- require 'fintecture/utils/validation'
7
- require 'fintecture/exceptions'
8
- require 'fintecture/utils/date'
9
- require 'fintecture/utils/constants'
10
-
11
- module Fintecture
12
- module Ais
13
- class AccountHolders
14
- class << self
15
- # ------------ PUBLIC METHOD ------------
16
- def get(client, customer_id, remove_nulls)
17
- @client = client
18
-
19
- # Do the request
20
- _request customer_id, remove_nulls
21
- end
22
-
23
- private
24
-
25
- # ------------ REQUEST ------------
26
- def _request(customer_id, remove_nulls)
27
- # Get the url request
28
- url = _endpoint customer_id
29
-
30
- # Build uri params
31
- query_string = ''
32
- if remove_nulls
33
- params = {}
34
- params['remove_nulls'] = remove_nulls if remove_nulls
35
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
36
- end
37
-
38
- # Do connect request
39
- Fintecture::Faraday::Authentication::Connection.get(
40
- url: url + query_string,
41
- client: @client,
42
- custom_content_type: 'application/json',
43
- bearer: "Bearer #{@client.token}",
44
- secure_headers: true
45
- )
46
- end
47
-
48
- # ------------ API ENDPOINT ------------
49
- def _endpoint(customer_id)
50
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::ACCOUNTHOLDERS}/#{customer_id}/accountholders"
51
- end
52
-
53
- # ------------ BASE URL ------------
54
- def _api_base_url
55
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
56
- end
57
-
58
- end
59
- end
60
- end
61
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'json'
5
+ require 'faraday'
6
+ require 'fintecture/utils/validation'
7
+ require 'fintecture/exceptions'
8
+ require 'fintecture/utils/date'
9
+ require 'fintecture/utils/constants'
10
+
11
+ module Fintecture
12
+ module Ais
13
+ class AccountHolders
14
+ class << self
15
+ # ------------ PUBLIC METHOD ------------
16
+ def get(client, customer_id, remove_nulls)
17
+ @client = client
18
+
19
+ # Do the request
20
+ _request customer_id, remove_nulls
21
+ end
22
+
23
+ private
24
+
25
+ # ------------ REQUEST ------------
26
+ def _request(customer_id, remove_nulls)
27
+ # Get the url request
28
+ url = _endpoint customer_id
29
+
30
+ # Build uri params
31
+ query_string = ''
32
+ if remove_nulls
33
+ params = {}
34
+ params['remove_nulls'] = remove_nulls if remove_nulls
35
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
36
+ end
37
+
38
+ # Do connect request
39
+ Fintecture::Faraday::Authentication::Connection.get(
40
+ url: url + query_string,
41
+ client: @client,
42
+ custom_content_type: 'application/json',
43
+ bearer: "Bearer #{@client.token}",
44
+ secure_headers: true
45
+ )
46
+ end
47
+
48
+ # ------------ API ENDPOINT ------------
49
+ def _endpoint(customer_id)
50
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::ACCOUNTHOLDERS}/#{customer_id}/accountholders"
51
+ end
52
+
53
+ # ------------ BASE URL ------------
54
+ def _api_base_url
55
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -1,63 +1,63 @@
1
- # frozen_string_literal: true
2
-
3
- require 'base64'
4
- require 'json'
5
- require 'faraday'
6
- require 'fintecture/utils/validation'
7
- require 'fintecture/exceptions'
8
- require 'fintecture/utils/date'
9
- require 'fintecture/utils/constants'
10
-
11
- module Fintecture
12
- module Ais
13
- class Accounts
14
- class << self
15
- # ------------ PUBLIC METHOD ------------
16
- def get(client, customer_id, account_id, remove_nulls, withBalances)
17
- @client = client
18
-
19
- # Do the request
20
- _request customer_id, account_id, remove_nulls, withBalances
21
- end
22
-
23
- private
24
-
25
- # ------------ REQUEST ------------
26
- def _request(customer_id, account_id, remove_nulls, withBalances)
27
- # Get the url request
28
- url = _endpoint customer_id, account_id
29
-
30
- # Build uri params
31
- query_string = ''
32
- if remove_nulls || withBalances
33
- params = {}
34
- params['remove_nulls'] = remove_nulls if remove_nulls
35
- params['withBalances'] = withBalances if withBalances
36
-
37
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
38
- end
39
-
40
- # Do connect request
41
- Fintecture::Faraday::Authentication::Connection.get(
42
- url: url + query_string,
43
- client: @client,
44
- custom_content_type: 'application/json',
45
- bearer: "Bearer #{@client.token}",
46
- secure_headers: true
47
- )
48
- end
49
-
50
- # ------------ API ENDPOINT ------------
51
- def _endpoint(customer_id, account_id)
52
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::ACCOUNTS}/#{customer_id}/accounts/#{account_id || ''}"
53
- end
54
-
55
- # ------------ BASE URL ------------
56
- def _api_base_url
57
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
58
- end
59
-
60
- end
61
- end
62
- end
63
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'json'
5
+ require 'faraday'
6
+ require 'fintecture/utils/validation'
7
+ require 'fintecture/exceptions'
8
+ require 'fintecture/utils/date'
9
+ require 'fintecture/utils/constants'
10
+
11
+ module Fintecture
12
+ module Ais
13
+ class Accounts
14
+ class << self
15
+ # ------------ PUBLIC METHOD ------------
16
+ def get(client, customer_id, account_id, remove_nulls, withBalances)
17
+ @client = client
18
+
19
+ # Do the request
20
+ _request customer_id, account_id, remove_nulls, withBalances
21
+ end
22
+
23
+ private
24
+
25
+ # ------------ REQUEST ------------
26
+ def _request(customer_id, account_id, remove_nulls, withBalances)
27
+ # Get the url request
28
+ url = _endpoint customer_id, account_id
29
+
30
+ # Build uri params
31
+ query_string = ''
32
+ if remove_nulls || withBalances
33
+ params = {}
34
+ params['remove_nulls'] = remove_nulls if remove_nulls
35
+ params['withBalances'] = withBalances if withBalances
36
+
37
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
38
+ end
39
+
40
+ # Do connect request
41
+ Fintecture::Faraday::Authentication::Connection.get(
42
+ url: url + query_string,
43
+ client: @client,
44
+ custom_content_type: 'application/json',
45
+ bearer: "Bearer #{@client.token}",
46
+ secure_headers: true
47
+ )
48
+ end
49
+
50
+ # ------------ API ENDPOINT ------------
51
+ def _endpoint(customer_id, account_id)
52
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::ACCOUNTS}/#{customer_id}/accounts/#{account_id || ''}"
53
+ end
54
+
55
+ # ------------ BASE URL ------------
56
+ def _api_base_url
57
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
58
+ end
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -1,72 +1,72 @@
1
- # frozen_string_literal: true
2
-
3
- require 'base64'
4
- require 'json'
5
- require 'faraday'
6
- require 'fintecture/utils/validation'
7
- require 'fintecture/exceptions'
8
- require 'fintecture/utils/date'
9
- require 'fintecture/utils/constants'
10
-
11
- module Fintecture
12
- module Ais
13
- class Authorize
14
- class << self
15
- # ------------ PUBLIC METHOD ------------
16
- def get(client, app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
17
- @client = client
18
-
19
- # Do the request
20
- _request app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address
21
- end
22
-
23
- private
24
-
25
- # ------------ REQUEST ------------
26
- def _request(app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
27
- # Get the url request
28
- url = _endpoint provider_id
29
-
30
- # Build uri params
31
- query_string = ''
32
-
33
- params = {}
34
- params['response_type'] = 'code' if app_id_auth
35
- params['redirect_uri'] = redirect_uri if redirect_uri
36
- params['state'] = state if state
37
- params['model'] = 'redirect'
38
-
39
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
40
-
41
- # Build additional headers
42
- additional_headers = {}
43
- additional_headers['app_id'] = @client.app_id if app_id_auth
44
- additional_headers['x-psu-id'] = x_psu_id if x_psu_id
45
- additional_headers['x-psu-ip-address'] = x_psu_ip_address if x_psu_ip_address
46
-
47
- # Do connect request
48
- Fintecture::Faraday::Authentication::Connection.get(
49
- url: url + query_string,
50
- client: @client,
51
- custom_content_type: 'application/json',
52
- bearer: "Bearer #{@client.token}",
53
- secure_headers: true,
54
- additional_headers: additional_headers,
55
- disableAuthorization: app_id_auth ? true : false
56
- )
57
- end
58
-
59
- # ------------ API ENDPOINT ------------
60
- def _endpoint(provider_id)
61
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::AUTHORIZE}/#{provider_id}/authorize"
62
- end
63
-
64
- # ------------ BASE URL ------------
65
- def _api_base_url
66
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
67
- end
68
-
69
- end
70
- end
71
- end
72
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'json'
5
+ require 'faraday'
6
+ require 'fintecture/utils/validation'
7
+ require 'fintecture/exceptions'
8
+ require 'fintecture/utils/date'
9
+ require 'fintecture/utils/constants'
10
+
11
+ module Fintecture
12
+ module Ais
13
+ class Authorize
14
+ class << self
15
+ # ------------ PUBLIC METHOD ------------
16
+ def get(client, app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
17
+ @client = client
18
+
19
+ # Do the request
20
+ _request app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address
21
+ end
22
+
23
+ private
24
+
25
+ # ------------ REQUEST ------------
26
+ def _request(app_id_auth, provider_id, redirect_uri, state, x_psu_id, x_psu_ip_address)
27
+ # Get the url request
28
+ url = _endpoint provider_id
29
+
30
+ # Build uri params
31
+ query_string = ''
32
+
33
+ params = {}
34
+ params['response_type'] = 'code' if app_id_auth
35
+ params['redirect_uri'] = redirect_uri if redirect_uri
36
+ params['state'] = state if state
37
+ params['model'] = 'redirect'
38
+
39
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
40
+
41
+ # Build additional headers
42
+ additional_headers = {}
43
+ additional_headers['app_id'] = @client.app_id if app_id_auth
44
+ additional_headers['x-psu-id'] = x_psu_id if x_psu_id
45
+ additional_headers['x-psu-ip-address'] = x_psu_ip_address if x_psu_ip_address
46
+
47
+ # Do connect request
48
+ Fintecture::Faraday::Authentication::Connection.get(
49
+ url: url + query_string,
50
+ client: @client,
51
+ custom_content_type: 'application/json',
52
+ bearer: "Bearer #{@client.token}",
53
+ secure_headers: true,
54
+ additional_headers: additional_headers,
55
+ disableAuthorization: app_id_auth ? true : false
56
+ )
57
+ end
58
+
59
+ # ------------ API ENDPOINT ------------
60
+ def _endpoint(provider_id)
61
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::AUTHORIZE}/#{provider_id}/authorize"
62
+ end
63
+
64
+ # ------------ BASE URL ------------
65
+ def _api_base_url
66
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end