fintecture 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -3
- data/Gemfile +4 -2
- data/Gemfile.lock +1 -1
- data/README.md +328 -162
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/exemples/ais.rb +53 -0
- data/exemples/config_ais.json +8 -0
- data/exemples/config_pis.json +6 -0
- data/exemples/pis.rb +148 -0
- data/exemples/ressources.rb +23 -0
- data/fintecture.gemspec +16 -15
- data/lib/fintecture/ais_client.rb +94 -0
- data/lib/fintecture/api/ais/account_holders.rb +61 -0
- data/lib/fintecture/api/ais/accounts.rb +63 -0
- data/lib/fintecture/api/ais/authorize.rb +72 -0
- data/lib/fintecture/api/ais/authorize_decoupled.rb +68 -0
- data/lib/fintecture/api/ais/connect.rb +65 -0
- data/lib/fintecture/api/ais/delete_customer.rb +53 -0
- data/lib/fintecture/api/ais/transactions.rb +64 -0
- data/lib/fintecture/{authentication.rb → api/auth/authentication.rb} +25 -23
- data/lib/fintecture/api/pis/connect.rb +77 -0
- data/lib/fintecture/api/pis/initiate.rb +52 -0
- data/lib/fintecture/api/pis/payments.rb +48 -0
- data/lib/fintecture/api/pis/refund.rb +67 -0
- data/lib/fintecture/api/pis/request_to_pay.rb +63 -0
- data/lib/fintecture/api/pis/settlements.rb +48 -0
- data/lib/fintecture/api/ressources/applications.rb +57 -0
- data/lib/fintecture/api/ressources/providers.rb +61 -0
- data/lib/fintecture/api/ressources/test_accounts.rb +60 -0
- data/lib/fintecture/base_url.rb +26 -0
- data/lib/fintecture/endpoints/ais.rb +17 -0
- data/lib/fintecture/{api/endpoints → endpoints}/authentication.rb +3 -3
- data/lib/fintecture/endpoints/pis.rb +16 -0
- data/lib/fintecture/endpoints/ressources.rb +13 -0
- data/lib/fintecture/exceptions.rb +52 -13
- data/lib/fintecture/faraday/authentication/connection.rb +60 -40
- data/lib/fintecture/pis_client.rb +100 -0
- data/lib/fintecture/utils/constants.rb +5 -8
- data/lib/fintecture/utils/crypto.rb +15 -18
- data/lib/fintecture/utils/date.rb +4 -4
- data/lib/fintecture/utils/validation.rb +12 -6
- data/lib/fintecture/version.rb +3 -1
- data/lib/fintecture.rb +21 -38
- metadata +31 -8
- data/lib/fintecture/api/base_url.rb +0 -29
- data/lib/fintecture/api/endpoints/pis.rb +0 -14
- data/lib/fintecture/connect.rb +0 -38
- data/lib/fintecture/pis.rb +0 -262
@@ -0,0 +1,53 @@
|
|
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 DeleteCustomer
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def delete(client, customer_id)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request customer_id
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(customer_id)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint customer_id
|
29
|
+
|
30
|
+
# Do connect request
|
31
|
+
Fintecture::Faraday::Authentication::Connection.delete(
|
32
|
+
url: url,
|
33
|
+
client: @client,
|
34
|
+
custom_content_type: 'application/json',
|
35
|
+
bearer: "Bearer #{@client.token}",
|
36
|
+
secure_headers: true
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
# ------------ API ENDPOINT ------------
|
41
|
+
def _endpoint(customer_id)
|
42
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::CUSTOMER}/#{customer_id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
# ------------ BASE URL ------------
|
46
|
+
def _api_base_url
|
47
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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 Transactions
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client, customer_id, account_id, remove_nulls, convert_dates, filters)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request customer_id, account_id, remove_nulls, convert_dates, filters
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(customer_id, account_id, remove_nulls, convert_dates, filters)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint customer_id, account_id
|
29
|
+
|
30
|
+
# Build uri params
|
31
|
+
query_string = ''
|
32
|
+
if remove_nulls || convert_dates || filters
|
33
|
+
params = {}
|
34
|
+
params['remove_nulls'] = remove_nulls if remove_nulls
|
35
|
+
params['convert_dates'] = convert_dates if convert_dates
|
36
|
+
filters.each { |key, value| params[key] = value } if filters
|
37
|
+
|
38
|
+
query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Do connect request
|
42
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
43
|
+
url: url + query_string,
|
44
|
+
client: @client,
|
45
|
+
custom_content_type: 'application/json',
|
46
|
+
bearer: "Bearer #{@client.token}",
|
47
|
+
secure_headers: true
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# ------------ API ENDPOINT ------------
|
52
|
+
def _endpoint(customer_id, account_id)
|
53
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ais::TRANSACTIONS}/#{customer_id}/accounts/#{account_id}/transactions"
|
54
|
+
end
|
55
|
+
|
56
|
+
# ------------ BASE URL ------------
|
57
|
+
def _api_base_url
|
58
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,37 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'faraday'
|
3
5
|
|
4
6
|
module Fintecture
|
5
7
|
class Authentication
|
6
8
|
class << self
|
7
|
-
|
8
9
|
def authorize(redirect_uri, state = nil)
|
9
10
|
query_string = "?#{{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}.map{|key, value| "#{key}=#{value}"}.join('&')}"
|
11
|
+
response_type: 'code',
|
12
|
+
app_id: Fintecture.app_id,
|
13
|
+
redirect_uri: redirect_uri,
|
14
|
+
state: state
|
15
|
+
}.map { |key, value| "#{key}=#{value}" }.join('&')}"
|
15
16
|
|
16
17
|
::Faraday.get "#{token_authorize_endpoint}#{query_string}"
|
17
18
|
end
|
18
19
|
|
19
|
-
def get_access_token(auth_code =
|
20
|
+
def get_access_token(client, auth_code = nil)
|
21
|
+
@client = client
|
20
22
|
body = access_token_data auth_code
|
21
|
-
|
22
|
-
Fintecture::Faraday::Authentication::Connection.post url: access_token_url, req_body: body
|
23
|
+
|
24
|
+
Fintecture::Faraday::Authentication::Connection.post url: access_token_url, req_body: body, client: client
|
23
25
|
end
|
24
26
|
|
25
|
-
def refresh_token(refresh_token)
|
27
|
+
def refresh_token(client, refresh_token)
|
28
|
+
@client = client
|
26
29
|
body = refresh_token_data refresh_token
|
27
30
|
|
28
|
-
Fintecture::Faraday::Authentication::Connection.post url: refresh_token_url, req_body: body
|
31
|
+
Fintecture::Faraday::Authentication::Connection.post url: refresh_token_url, req_body: body, client: client
|
29
32
|
end
|
30
33
|
|
31
34
|
private
|
32
35
|
|
33
36
|
def base_url
|
34
|
-
Fintecture::Api::BaseUrl::FINTECTURE_OAUTH_URL[
|
37
|
+
Fintecture::Api::BaseUrl::FINTECTURE_OAUTH_URL[@client.environment.to_sym]
|
35
38
|
end
|
36
39
|
|
37
40
|
def token_authorize_endpoint
|
@@ -47,17 +50,17 @@ module Fintecture
|
|
47
50
|
end
|
48
51
|
|
49
52
|
def access_token_data(auth_code)
|
50
|
-
data =
|
51
|
-
|
52
|
-
|
53
|
-
|
53
|
+
data = {
|
54
|
+
scope: 'PIS',
|
55
|
+
app_id: @client.app_id,
|
56
|
+
grant_type: 'client_credentials'
|
54
57
|
}
|
55
58
|
|
56
59
|
if auth_code
|
57
60
|
data = {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
+
scope: 'AIS',
|
62
|
+
code: auth_code,
|
63
|
+
grant_type: 'authorization_code'
|
61
64
|
}
|
62
65
|
end
|
63
66
|
|
@@ -66,11 +69,10 @@ module Fintecture
|
|
66
69
|
|
67
70
|
def refresh_token_data(refresh_token)
|
68
71
|
{
|
69
|
-
|
70
|
-
|
72
|
+
grant_type: 'refresh_token',
|
73
|
+
refresh_token: refresh_token
|
71
74
|
}
|
72
75
|
end
|
73
|
-
|
74
76
|
end
|
75
77
|
end
|
76
|
-
end
|
78
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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
|
@@ -0,0 +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
|
@@ -0,0 +1,48 @@
|
|
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
|
@@ -0,0 +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)
|
13
|
+
@client = client
|
14
|
+
|
15
|
+
# Build the request payload
|
16
|
+
payload = _build_payload session_id, amount
|
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)
|
41
|
+
# Return the payload
|
42
|
+
{
|
43
|
+
meta: {
|
44
|
+
session_id: session_id
|
45
|
+
},
|
46
|
+
data: {
|
47
|
+
attributes: {
|
48
|
+
amount: amount.to_s
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# ------------ API ENDPOINT ------------
|
55
|
+
def _endpoint
|
56
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::REFUND}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# ------------ BASE URL ------------
|
60
|
+
def _api_base_url
|
61
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +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
|
@@ -0,0 +1,48 @@
|
|
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 Settlements
|
11
|
+
class << self
|
12
|
+
# ------------ PUBLIC METHOD ------------
|
13
|
+
def get(client, settlement_id)
|
14
|
+
@client = client
|
15
|
+
|
16
|
+
# Do the get_payments request
|
17
|
+
_request settlement_id
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# ------------ REQUEST ------------
|
23
|
+
def _request(settlement_id)
|
24
|
+
url = _endpoint
|
25
|
+
|
26
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
27
|
+
url: "#{url}/#{settlement_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::SETTLEMENTS}"
|
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
|
@@ -0,0 +1,57 @@
|
|
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 Ressources
|
13
|
+
class Applications
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint
|
29
|
+
|
30
|
+
# Build additional headers
|
31
|
+
additional_headers = {}
|
32
|
+
additional_headers['app_id'] = @client.app_id
|
33
|
+
|
34
|
+
# Do connect request
|
35
|
+
Fintecture::Faraday::Authentication::Connection.get(
|
36
|
+
url: url,
|
37
|
+
client: @client,
|
38
|
+
custom_content_type: 'application/json',
|
39
|
+
secure_headers: true,
|
40
|
+
additional_headers: additional_headers
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# ------------ API ENDPOINT ------------
|
45
|
+
def _endpoint
|
46
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ressources::APPLICATION}"
|
47
|
+
end
|
48
|
+
|
49
|
+
# ------------ BASE URL ------------
|
50
|
+
def _api_base_url
|
51
|
+
Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +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 Ressources
|
13
|
+
class Providers
|
14
|
+
class << self
|
15
|
+
# ------------ PUBLIC METHOD ------------
|
16
|
+
def get(client, provider_id, paramsProviders)
|
17
|
+
@client = client
|
18
|
+
|
19
|
+
# Do the request
|
20
|
+
_request provider_id, paramsProviders
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# ------------ REQUEST ------------
|
26
|
+
def _request(provider_id, paramsProviders)
|
27
|
+
# Get the url request
|
28
|
+
url = _endpoint provider_id
|
29
|
+
|
30
|
+
# Build additional headers
|
31
|
+
additional_headers = {}
|
32
|
+
additional_headers['app_id'] = @client.app_id
|
33
|
+
|
34
|
+
# Build uri params
|
35
|
+
query_string = ''
|
36
|
+
query_string = "?#{paramsProviders.map { |key, value| "#{key}=#{value}" }.join('&')}" if paramsProviders
|
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
|
+
secure_headers: true,
|
44
|
+
additional_headers: additional_headers
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# ------------ API ENDPOINT ------------
|
49
|
+
def _endpoint(provider_id)
|
50
|
+
"#{_api_base_url}/#{Fintecture::Api::Endpoints::Ressources::PROVIDERS}/#{provider_id || ''}"
|
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
|