fintecture 0.5.1 → 0.6.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -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 +405 -408
  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 +84 -77
  29. data/lib/fintecture/api/pis/initiate.rb +52 -52
  30. data/lib/fintecture/api/pis/payments.rb +54 -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 +48 -48
  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 +12 -6
@@ -1,75 +1,75 @@
1
- # frozen_string_literal: true
2
-
3
- require 'securerandom'
4
- require 'openssl'
5
- require 'base64'
6
- require 'json'
7
- require 'fintecture/exceptions'
8
- require 'fintecture/utils/constants'
9
- require 'uri'
10
-
11
- module Fintecture
12
- module Utils
13
- class Crypto
14
- class << self
15
- def generate_uuid
16
- SecureRandom.uuid
17
- end
18
-
19
- def generate_uuid_only_chars
20
- generate_uuid.gsub!('-', '')
21
- end
22
-
23
- def sign_payload(payload)
24
- payload = payload.to_json.to_s if payload.is_a? Hash
25
- digest = OpenSSL::Digest.new('SHA256')
26
- private_key = OpenSSL::PKey::RSA.new(@client.private_key)
27
-
28
- begin
29
- signature = private_key.sign(digest, payload)
30
- Base64.strict_encode64(signature)
31
- rescue StandardError
32
- raise Fintecture::CryptoException, 'error during signature'
33
- end
34
- end
35
-
36
- def decrypt_private(digest)
37
- digest = URI.unescape digest
38
- encrypted_string = Base64.decode64(digest)
39
- private_key = OpenSSL::PKey::RSA.new(@client.private_key)
40
-
41
- begin
42
- private_key.private_decrypt(encrypted_string, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
43
- rescue OpenSSL::PKey::RSAError => e
44
- raise Fintecture::CryptoException, "error while decrypt, #{e.message}"
45
- rescue StandardError
46
- raise Fintecture::CryptoException, 'error during decryption'
47
- end
48
- end
49
-
50
- def hash_base64(plain_text)
51
- digest = Digest::SHA256.digest plain_text
52
- Base64.strict_encode64(digest)
53
- end
54
-
55
- def create_signature_header(headers, client)
56
- @client = client
57
- signing = []
58
- header = []
59
-
60
- Fintecture::Utils::Constants::SIGNEDHEADERPARAMETERLIST.each do |param|
61
- next unless headers[param]
62
-
63
- param_low = param.downcase
64
- signing << "#{param_low}: #{headers[param]}"
65
- header << param_low
66
- end
67
-
68
- # Double quote in join needed. If not we will get two slashes \\n
69
- signature = sign_payload signing.join("\n")
70
- "keyId=\"#{@client.app_id}\",algorithm=\"rsa-sha256\",headers=\"#{header.join(' ')}\",signature=\"#{signature}\""
71
- end
72
- end
73
- end
74
- end
75
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+ require 'openssl'
5
+ require 'base64'
6
+ require 'json'
7
+ require 'fintecture/exceptions'
8
+ require 'fintecture/utils/constants'
9
+ require 'uri'
10
+
11
+ module Fintecture
12
+ module Utils
13
+ class Crypto
14
+ class << self
15
+ def generate_uuid
16
+ SecureRandom.uuid
17
+ end
18
+
19
+ def generate_uuid_only_chars
20
+ generate_uuid.gsub!('-', '')
21
+ end
22
+
23
+ def sign_payload(payload)
24
+ payload = payload.to_json.to_s if payload.is_a? Hash
25
+ digest = OpenSSL::Digest.new('SHA256')
26
+ private_key = OpenSSL::PKey::RSA.new(@client.private_key)
27
+
28
+ begin
29
+ signature = private_key.sign(digest, payload)
30
+ Base64.strict_encode64(signature)
31
+ rescue StandardError
32
+ raise Fintecture::CryptoException, 'error during signature'
33
+ end
34
+ end
35
+
36
+ def decrypt_private(digest)
37
+ digest = URI.unescape digest
38
+ encrypted_string = Base64.decode64(digest)
39
+ private_key = OpenSSL::PKey::RSA.new(@client.private_key)
40
+
41
+ begin
42
+ private_key.private_decrypt(encrypted_string, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
43
+ rescue OpenSSL::PKey::RSAError => e
44
+ raise Fintecture::CryptoException, "error while decrypt, #{e.message}"
45
+ rescue StandardError
46
+ raise Fintecture::CryptoException, 'error during decryption'
47
+ end
48
+ end
49
+
50
+ def hash_base64(plain_text)
51
+ digest = Digest::SHA256.digest plain_text
52
+ Base64.strict_encode64(digest)
53
+ end
54
+
55
+ def create_signature_header(headers, client)
56
+ @client = client
57
+ signing = []
58
+ header = []
59
+
60
+ Fintecture::Utils::Constants::SIGNEDHEADERPARAMETERLIST.each do |param|
61
+ next unless headers[param]
62
+
63
+ param_low = param.downcase
64
+ signing << "#{param_low}: #{headers[param]}"
65
+ header << param_low
66
+ end
67
+
68
+ # Double quote in join needed. If not we will get two slashes \\n
69
+ signature = sign_payload signing.join("\n")
70
+ "keyId=\"#{@client.app_id}\",algorithm=\"rsa-sha256\",headers=\"#{header.join(' ')}\",signature=\"#{signature}\""
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -1,15 +1,15 @@
1
- # frozen_string_literal: true
2
-
3
- require 'time'
4
-
5
- module Fintecture
6
- module Utils
7
- class Date
8
- class << self
9
- def header_time
10
- Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S GMT')
11
- end
12
- end
13
- end
14
- end
15
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'time'
4
+
5
+ module Fintecture
6
+ module Utils
7
+ class Date
8
+ class << self
9
+ def header_time
10
+ Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S GMT')
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,32 +1,32 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fintecture/exceptions'
4
-
5
- module Fintecture
6
- module Utils
7
- class Validation
8
- class << self
9
- def raise_if_klass_mismatch(target, klass, param_name = nil)
10
- return if target.is_a? klass
11
-
12
- raise Fintecture::ValidationException,
13
- "invalid #{param_name || 'parameter'} format, the parameter should be a #{klass} instead a #{target.class.name}"
14
- end
15
-
16
- def raise_if_invalid_date_format(date)
17
- return unless date
18
-
19
- valid_format = date.match(/\d{4}-\d{2}-\d{2}/)
20
- valid_date = begin
21
- ::Date.strptime(date, '%Y-%m-%d')
22
- rescue StandardError
23
- false
24
- end
25
- return if valid_format && valid_date
26
-
27
- raise Fintecture::ValidationException, "invalidss #{date} date, the format should be YYYY-MM-DD"
28
- end
29
- end
30
- end
31
- end
32
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fintecture/exceptions'
4
+
5
+ module Fintecture
6
+ module Utils
7
+ class Validation
8
+ class << self
9
+ def raise_if_klass_mismatch(target, klass, param_name = nil)
10
+ return if target.is_a? klass
11
+
12
+ raise Fintecture::ValidationException,
13
+ "invalid #{param_name || 'parameter'} format, the parameter should be a #{klass} instead a #{target.class.name}"
14
+ end
15
+
16
+ def raise_if_invalid_date_format(date)
17
+ return unless date
18
+
19
+ valid_format = date.match(/\d{4}-\d{2}-\d{2}/)
20
+ valid_date = begin
21
+ ::Date.strptime(date, '%Y-%m-%d')
22
+ rescue StandardError
23
+ false
24
+ end
25
+ return if valid_format && valid_date
26
+
27
+ raise Fintecture::ValidationException, "invalidss #{date} date, the format should be YYYY-MM-DD"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module Fintecture
4
- VERSION = '0.5.1'
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Fintecture
4
+ VERSION = '0.6.0'
5
+ end
data/lib/fintecture.rb CHANGED
@@ -1,65 +1,65 @@
1
- # frozen_string_literal: true
2
-
3
- require 'logger'
4
- require 'uri'
5
- require 'faraday'
6
-
7
- # ToRemove
8
- require 'openssl'
9
- require 'cgi'
10
-
11
- # Version
12
- require 'fintecture/version'
13
-
14
- # Modules
15
- require 'fintecture/api/auth/authentication'
16
-
17
- # Clients
18
- require 'fintecture/pis_client'
19
- require 'fintecture/ais_client'
20
-
21
- # Utilities
22
- require 'fintecture/utils/crypto'
23
-
24
- # Endpoints
25
- require 'fintecture/base_url'
26
- require 'fintecture/endpoints/authentication'
27
- require 'fintecture/endpoints/ais'
28
- require 'fintecture/endpoints/pis'
29
- require 'fintecture/endpoints/ressources'
30
-
31
- # Connections
32
- require 'fintecture/faraday/authentication/connection'
33
-
34
- module Fintecture
35
- @log_level = nil
36
- @logger = nil
37
-
38
- class << self
39
- attr_accessor :logger
40
- attr_reader :log_level
41
-
42
- # Logging
43
- LEVEL_DEBUG = Logger::DEBUG
44
- LEVEL_ERROR = Logger::ERROR
45
- LEVEL_INFO = Logger::INFO
46
-
47
- def log_level=(val)
48
- case val
49
- when 'debug'
50
- val = LEVEL_DEBUG
51
- when 'info'
52
- val = LEVEL_INFO
53
- end
54
-
55
- if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
56
- raise ArgumentError, 'log_level should only be set to `nil`, `debug` or `info`'
57
- end
58
-
59
- @log_level = val
60
- end
61
- end
62
- end
63
-
64
- Fintecture.log_level = ENV['FINTECTURE_LOG'] unless ENV['FINTECTURE_LOG'].nil?
65
- # TODO: Mettre a jour la gem sur le site de package
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+ require 'uri'
5
+ require 'faraday'
6
+
7
+ # ToRemove
8
+ require 'openssl'
9
+ require 'cgi'
10
+
11
+ # Version
12
+ require 'fintecture/version'
13
+
14
+ # Modules
15
+ require 'fintecture/api/auth/authentication'
16
+
17
+ # Clients
18
+ require 'fintecture/pis_client'
19
+ require 'fintecture/ais_client'
20
+
21
+ # Utilities
22
+ require 'fintecture/utils/crypto'
23
+
24
+ # Endpoints
25
+ require 'fintecture/base_url'
26
+ require 'fintecture/endpoints/authentication'
27
+ require 'fintecture/endpoints/ais'
28
+ require 'fintecture/endpoints/pis'
29
+ require 'fintecture/endpoints/ressources'
30
+
31
+ # Connections
32
+ require 'fintecture/faraday/authentication/connection'
33
+
34
+ module Fintecture
35
+ @log_level = nil
36
+ @logger = nil
37
+
38
+ class << self
39
+ attr_accessor :logger
40
+ attr_reader :log_level
41
+
42
+ # Logging
43
+ LEVEL_DEBUG = Logger::DEBUG
44
+ LEVEL_ERROR = Logger::ERROR
45
+ LEVEL_INFO = Logger::INFO
46
+
47
+ def log_level=(val)
48
+ case val
49
+ when 'debug'
50
+ val = LEVEL_DEBUG
51
+ when 'info'
52
+ val = LEVEL_INFO
53
+ end
54
+
55
+ if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
56
+ raise ArgumentError, 'log_level should only be set to `nil`, `debug` or `info`'
57
+ end
58
+
59
+ @log_level = val
60
+ end
61
+ end
62
+ end
63
+
64
+ Fintecture.log_level = ENV['FINTECTURE_LOG'] unless ENV['FINTECTURE_LOG'].nil?
65
+ # TODO: Mettre a jour la gem sur le site de package
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintecture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fintecture
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2023-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,14 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Longer summary
69
+ description: Our APIs allow easy and secure access to bank account data and payment
70
+ initiation. The account data accessible are account holder's personal information,
71
+ account balances, transaction history and much more. The available payment methods
72
+ depend on the banks implementation but typically are domestic transfers, SEPA credit
73
+ transfer, instant SEPA credit transfer, fast payment scheme, and SWIFT international
74
+ payments.
70
75
  email:
71
- - alvaro.fernandez@nazaries.com
76
+ - support@fintecture.com
72
77
  executables: []
73
78
  extensions: []
74
79
  extra_rdoc_files: []
@@ -143,8 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
148
  - !ruby/object:Gem::Version
144
149
  version: '0'
145
150
  requirements: []
146
- rubygems_version: 3.1.4
151
+ rubygems_version: 3.1.6
147
152
  signing_key:
148
153
  specification_version: 4
149
- summary: Short summary
154
+ summary: SDK to allow easy and secure access to bank account data and payment initiation
155
+ with Fintecture.
150
156
  test_files: []