fintecture 0.5.1 → 0.6.0

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 +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,77 +1,84 @@
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 Pis
13
- class Connect
14
- class << self
15
- # ------------ PUBLIC METHOD ------------
16
- def generate(client, payload, state, redirect_uri, origin_uri)
17
- @client = client
18
-
19
- # Build the request payload
20
- payload = _build_payload(payload)
21
-
22
- # Do the request
23
- _request payload, state, redirect_uri, origin_uri
24
- end
25
-
26
- private
27
-
28
- # ------------ REQUEST ------------
29
- def _request(payload, state, redirect_uri, origin_uri)
30
- # Get the url request
31
- url = _endpoint
32
-
33
- # Build uri params
34
- params = {}
35
- params['redirect_uri'] = redirect_uri if redirect_uri
36
- params['origin_uri'] = origin_uri if origin_uri
37
- params['state'] = state
38
-
39
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
40
-
41
- # Do connect request
42
- Fintecture::Faraday::Authentication::Connection.post(
43
- url: url + query_string,
44
- req_body: payload.to_json,
45
- client: @client,
46
- custom_content_type: 'application/json',
47
- bearer: "Bearer #{@client.token}",
48
- secure_headers: true
49
- )
50
- end
51
-
52
- # ------------ BUILD PAYLOAD ------------
53
- def _build_payload(payload)
54
- payload[:data][:attributes][:amount] = payload[:data][:attributes][:amount].to_s
55
-
56
- unless payload[:data][:attributes][:end_to_end_id]
57
- payload[:data][:attributes][:end_to_end_id] =
58
- Fintecture::Utils::Crypto.generate_uuid_only_chars
59
- end
60
-
61
- payload
62
- end
63
-
64
- # ------------ API ENDPOINT ------------
65
- def _endpoint
66
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::CONNECT}"
67
- end
68
-
69
- # ------------ BASE URL ------------
70
- def _api_base_url
71
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
72
- end
73
-
74
- end
75
- end
76
- end
77
- 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 Pis
13
+ class Connect
14
+ class << self
15
+ # ------------ PUBLIC METHOD ------------
16
+ def generate(client, payload, state, redirect_uri, origin_uri, **options)
17
+
18
+ @client = client
19
+
20
+ # Build the request payload
21
+ payload = _build_payload(payload)
22
+
23
+ # Do the request
24
+ _request payload, state, redirect_uri, origin_uri, options
25
+ end
26
+
27
+ private
28
+
29
+ # ------------ REQUEST ------------
30
+ def _request(payload, state, redirect_uri, origin_uri, options)
31
+ defaults = {
32
+ :with_virtualbeneficiary => false
33
+ }
34
+ options = defaults.merge(options)
35
+
36
+ # Get the url request
37
+ url = _endpoint
38
+
39
+ # Build uri params
40
+ params = {}
41
+ params['redirect_uri'] = redirect_uri if redirect_uri
42
+ params['origin_uri'] = origin_uri if origin_uri
43
+ params['with_virtualbeneficiary'] = 'true' if options[:with_virtualbeneficiary]
44
+ params['state'] = state
45
+
46
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
47
+
48
+ # Do connect request
49
+ Fintecture::Faraday::Authentication::Connection.post(
50
+ url: url + query_string,
51
+ req_body: payload.to_json,
52
+ client: @client,
53
+ custom_content_type: 'application/json',
54
+ bearer: "Bearer #{@client.token}",
55
+ secure_headers: true
56
+ )
57
+ end
58
+
59
+ # ------------ BUILD PAYLOAD ------------
60
+ def _build_payload(payload)
61
+ payload[:data][:attributes][:amount] = payload[:data][:attributes][:amount].to_s
62
+
63
+ unless payload[:data][:attributes][:end_to_end_id]
64
+ payload[:data][:attributes][:end_to_end_id] =
65
+ Fintecture::Utils::Crypto.generate_uuid_only_chars
66
+ end
67
+
68
+ payload
69
+ end
70
+
71
+ # ------------ API ENDPOINT ------------
72
+ def _endpoint
73
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::CONNECT}"
74
+ end
75
+
76
+ # ------------ BASE URL ------------
77
+ def _api_base_url
78
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
79
+ end
80
+
81
+ end
82
+ end
83
+ end
84
+ end
@@ -1,52 +1,52 @@
1
- # frozen_string_literal: true
2
-
3
- module Fintecture
4
- module Pis
5
- class Initiate
6
- class << self
7
- # ------------ PUBLIC METHOD ------------
8
- def generate(client, payload, provider_id, redirect_uri, state)
9
- @client = client
10
-
11
- # Do the _request request
12
- _request payload, provider_id, redirect_uri, state
13
- end
14
-
15
- private
16
-
17
- # ------------ REQUEST ------------
18
- def _request(payload, provider_id, redirect_uri, state)
19
- # Get the url request
20
- url = _endpoint provider_id
21
-
22
- # Build uri params
23
- params = {}
24
- params['state'] = state
25
- params['redirect_uri'] = redirect_uri
26
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
27
-
28
- # Do connect request
29
- Fintecture::Faraday::Authentication::Connection.post(
30
- url: url + query_string,
31
- req_body: payload.to_json,
32
- client: @client,
33
- custom_content_type: 'application/json',
34
- bearer: "Bearer #{@client.token}",
35
- secure_headers: true
36
- )
37
- end
38
-
39
- # ------------ API ENDPOINT ------------
40
- def _endpoint(provider_id)
41
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::INITIATE}/#{provider_id}/initiate"
42
- end
43
-
44
- # ------------ BASE URL ------------
45
- def _api_base_url
46
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
47
- end
48
-
49
- end
50
- end
51
- end
52
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Fintecture
4
+ module Pis
5
+ class Initiate
6
+ class << self
7
+ # ------------ PUBLIC METHOD ------------
8
+ def generate(client, payload, provider_id, redirect_uri, state)
9
+ @client = client
10
+
11
+ # Do the _request request
12
+ _request payload, provider_id, redirect_uri, state
13
+ end
14
+
15
+ private
16
+
17
+ # ------------ REQUEST ------------
18
+ def _request(payload, provider_id, redirect_uri, state)
19
+ # Get the url request
20
+ url = _endpoint provider_id
21
+
22
+ # Build uri params
23
+ params = {}
24
+ params['state'] = state
25
+ params['redirect_uri'] = redirect_uri
26
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
27
+
28
+ # Do connect request
29
+ Fintecture::Faraday::Authentication::Connection.post(
30
+ url: url + query_string,
31
+ req_body: payload.to_json,
32
+ client: @client,
33
+ custom_content_type: 'application/json',
34
+ bearer: "Bearer #{@client.token}",
35
+ secure_headers: true
36
+ )
37
+ end
38
+
39
+ # ------------ API ENDPOINT ------------
40
+ def _endpoint(provider_id)
41
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::INITIATE}/#{provider_id}/initiate"
42
+ end
43
+
44
+ # ------------ BASE URL ------------
45
+ def _api_base_url
46
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,48 +1,54 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'faraday'
5
- require 'fintecture/endpoints/pis'
6
- require 'fintecture/base_url'
7
-
8
- module Fintecture
9
- module Pis
10
- class Payments
11
- class << self
12
- # ------------ PUBLIC METHOD ------------
13
- def get(client, session_id)
14
- @client = client
15
-
16
- # Do the get_payments request
17
- _request session_id
18
- end
19
-
20
- private
21
-
22
- # ------------ REQUEST ------------
23
- def _request(session_id)
24
- url = _endpoint
25
-
26
- Fintecture::Faraday::Authentication::Connection.get(
27
- url: "#{url}/#{session_id}",
28
- client: @client,
29
- custom_content_type: 'application/json',
30
- bearer: "Bearer #{@client.token}",
31
- secure_headers: true
32
- )
33
- end
34
-
35
- # ------------ API ENDPOINT ------------
36
- def _endpoint
37
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::PAYMENTS}"
38
- end
39
-
40
- # ------------ BASE URL ------------
41
- def _api_base_url
42
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
43
- end
44
-
45
- end
46
- end
47
- end
48
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'faraday'
5
+ require 'fintecture/endpoints/pis'
6
+ require 'fintecture/base_url'
7
+
8
+ module Fintecture
9
+ module Pis
10
+ class Payments
11
+ class << self
12
+ # ------------ PUBLIC METHOD ------------
13
+ def get(client, session_id, options = {})
14
+ @client = client
15
+
16
+ # Do the get_payments request
17
+ _request session_id, options
18
+ end
19
+
20
+ private
21
+
22
+ # ------------ REQUEST ------------
23
+ def _request(session_id, options)
24
+ url = _endpoint
25
+
26
+ # Build uri params
27
+ params = {}
28
+ params['with_virtualbeneficiary'] = 'true' if options[:with_virtualbeneficiary]
29
+
30
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
31
+
32
+ Fintecture::Faraday::Authentication::Connection.get(
33
+ url: "#{url}/#{session_id}" + query_string,
34
+ client: @client,
35
+ custom_content_type: 'application/json',
36
+ bearer: "Bearer #{@client.token}",
37
+ secure_headers: true
38
+ )
39
+ end
40
+
41
+ # ------------ API ENDPOINT ------------
42
+ def _endpoint
43
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::PAYMENTS}"
44
+ end
45
+
46
+ # ------------ BASE URL ------------
47
+ def _api_base_url
48
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,67 +1,67 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'faraday'
5
- require 'fintecture/endpoints/pis'
6
- require 'fintecture/base_url'
7
- module Fintecture
8
- module Pis
9
- class Refund
10
- class << self
11
- # ------------ PUBLIC METHOD ------------
12
- def generate(client, session_id, amount, user_id)
13
- @client = client
14
-
15
- # Build the request payload
16
- payload = _build_payload session_id, amount, user_id
17
- # Do the _request request
18
- _request payload
19
- end
20
-
21
- private
22
-
23
- # ------------ REQUEST ------------
24
- def _request(payload)
25
- # Get the url request
26
- url = _endpoint
27
-
28
- # Do connect request
29
- Fintecture::Faraday::Authentication::Connection.post(
30
- url: url,
31
- req_body: payload.to_json,
32
- client: @client,
33
- custom_content_type: 'application/json',
34
- bearer: "Bearer #{@client.token}",
35
- secure_headers: true
36
- )
37
- end
38
-
39
- # ------------ BUILD PAYLOAD ------------
40
- def _build_payload(session_id, amount, user_id)
41
- # Return the payload
42
- {
43
- meta: {
44
- session_id: session_id,
45
- user_id: user_id
46
- },
47
- data: {
48
- attributes: {
49
- amount: amount.to_s
50
- }
51
- }
52
- }
53
- end
54
-
55
- # ------------ API ENDPOINT ------------
56
- def _endpoint
57
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::REFUND}"
58
- end
59
-
60
- # ------------ BASE URL ------------
61
- def _api_base_url
62
- Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
63
- end
64
- end
65
- end
66
- end
67
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'faraday'
5
+ require 'fintecture/endpoints/pis'
6
+ require 'fintecture/base_url'
7
+ module Fintecture
8
+ module Pis
9
+ class Refund
10
+ class << self
11
+ # ------------ PUBLIC METHOD ------------
12
+ def generate(client, session_id, amount, user_id)
13
+ @client = client
14
+
15
+ # Build the request payload
16
+ payload = _build_payload session_id, amount, user_id
17
+ # Do the _request request
18
+ _request payload
19
+ end
20
+
21
+ private
22
+
23
+ # ------------ REQUEST ------------
24
+ def _request(payload)
25
+ # Get the url request
26
+ url = _endpoint
27
+
28
+ # Do connect request
29
+ Fintecture::Faraday::Authentication::Connection.post(
30
+ url: url,
31
+ req_body: payload.to_json,
32
+ client: @client,
33
+ custom_content_type: 'application/json',
34
+ bearer: "Bearer #{@client.token}",
35
+ secure_headers: true
36
+ )
37
+ end
38
+
39
+ # ------------ BUILD PAYLOAD ------------
40
+ def _build_payload(session_id, amount, user_id)
41
+ # Return the payload
42
+ {
43
+ meta: {
44
+ session_id: session_id,
45
+ user_id: user_id
46
+ },
47
+ data: {
48
+ attributes: {
49
+ amount: amount.to_s
50
+ }
51
+ }
52
+ }
53
+ end
54
+
55
+ # ------------ API ENDPOINT ------------
56
+ def _endpoint
57
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::REFUND}"
58
+ end
59
+
60
+ # ------------ BASE URL ------------
61
+ def _api_base_url
62
+ Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,63 +1,63 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'faraday'
5
- require 'fintecture/endpoints/pis'
6
- require 'fintecture/base_url'
7
- module Fintecture
8
- module Pis
9
- class RequestToPay
10
- class << self
11
- # ------------ PUBLIC METHOD ------------
12
- def generate(client, payload = nil, x_language, redirect_uri)
13
- @client = client
14
-
15
- # Do the _request request
16
- _request payload, x_language, redirect_uri
17
- end
18
-
19
- private
20
-
21
- # ------------ REQUEST ------------
22
- def _request(payload, x_language, redirect_uri)
23
- # Get the url request
24
- url = _endpoint
25
-
26
- # Build uri params
27
- query_string = ''
28
- if redirect_uri
29
- params = {}
30
- params['redirect_uri'] = redirect_uri
31
- query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
32
- end
33
-
34
- # Build additional headers
35
- additional_headers = {}
36
- additional_headers['x-language'] = x_language
37
-
38
- # Do connect request
39
- Fintecture::Faraday::Authentication::Connection.post(
40
- url: url + query_string,
41
- req_body: payload.to_json,
42
- client: @client,
43
- custom_content_type: 'application/json',
44
- bearer: "Bearer #{@client.token}",
45
- secure_headers: true,
46
- additional_headers: additional_headers
47
- )
48
- end
49
-
50
- # ------------ API ENDPOINT ------------
51
- def _endpoint
52
- "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::REQUEST_TO_PAY}"
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 'json'
4
+ require 'faraday'
5
+ require 'fintecture/endpoints/pis'
6
+ require 'fintecture/base_url'
7
+ module Fintecture
8
+ module Pis
9
+ class RequestToPay
10
+ class << self
11
+ # ------------ PUBLIC METHOD ------------
12
+ def generate(client, payload = nil, x_language, redirect_uri)
13
+ @client = client
14
+
15
+ # Do the _request request
16
+ _request payload, x_language, redirect_uri
17
+ end
18
+
19
+ private
20
+
21
+ # ------------ REQUEST ------------
22
+ def _request(payload, x_language, redirect_uri)
23
+ # Get the url request
24
+ url = _endpoint
25
+
26
+ # Build uri params
27
+ query_string = ''
28
+ if redirect_uri
29
+ params = {}
30
+ params['redirect_uri'] = redirect_uri
31
+ query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
32
+ end
33
+
34
+ # Build additional headers
35
+ additional_headers = {}
36
+ additional_headers['x-language'] = x_language
37
+
38
+ # Do connect request
39
+ Fintecture::Faraday::Authentication::Connection.post(
40
+ url: url + query_string,
41
+ req_body: payload.to_json,
42
+ client: @client,
43
+ custom_content_type: 'application/json',
44
+ bearer: "Bearer #{@client.token}",
45
+ secure_headers: true,
46
+ additional_headers: additional_headers
47
+ )
48
+ end
49
+
50
+ # ------------ API ENDPOINT ------------
51
+ def _endpoint
52
+ "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::REQUEST_TO_PAY}"
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