fintecture 0.2.1 → 0.4.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.
- checksums.yaml +4 -4
- data/.gitignore +17 -19
- data/.rspec +3 -3
- data/.travis.yml +7 -7
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +8 -6
- data/Gemfile.lock +59 -59
- data/LICENSE.txt +674 -674
- data/README.md +407 -238
- data/Rakefile +8 -6
- data/bin/console +15 -14
- data/bin/setup +8 -8
- 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 +44 -43
- 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} +78 -76
- 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 +50 -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 +13 -13
- data/lib/fintecture/endpoints/pis.rb +16 -0
- data/lib/fintecture/endpoints/ressources.rb +13 -0
- data/lib/fintecture/exceptions.rb +72 -33
- data/lib/fintecture/faraday/authentication/connection.rb +140 -120
- data/lib/fintecture/pis_client.rb +100 -0
- data/lib/fintecture/utils/constants.rb +11 -14
- data/lib/fintecture/utils/crypto.rb +75 -78
- data/lib/fintecture/utils/date.rb +15 -15
- data/lib/fintecture/utils/validation.rb +32 -26
- data/lib/fintecture/version.rb +5 -3
- data/lib/fintecture.rb +65 -82
- metadata +35 -12
- 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
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'fintecture'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/exemples/ais.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/fintecture'
|
4
|
+
|
5
|
+
config = JSON.parse(File.read('./exemples/config_ais.json'))
|
6
|
+
|
7
|
+
ais_client = Fintecture::AisClient.new({
|
8
|
+
environment: config['environment'],
|
9
|
+
app_id: config['app_id'],
|
10
|
+
app_secret: config['app_secret'],
|
11
|
+
private_key: config['private_key']
|
12
|
+
})
|
13
|
+
|
14
|
+
# ######################## AIS ########################
|
15
|
+
|
16
|
+
# ------------ Connect ------------
|
17
|
+
connect_response = ais_client.connect 'ok', 'https://www.google.fr'
|
18
|
+
connect_id = connect_response['meta']['connect_id']
|
19
|
+
url = connect_response['meta']['url']
|
20
|
+
|
21
|
+
puts "Connect url => #{url}"
|
22
|
+
|
23
|
+
# Put the return of connect url here
|
24
|
+
customer_id = 'c84e6a2c66862f6ce169a11262b28f4c'
|
25
|
+
code = '173535d0acc16271e7942cc6e1772a5b'
|
26
|
+
|
27
|
+
# ------------ Get access token ------------
|
28
|
+
ais_client.generate_token code
|
29
|
+
ais_client.generate_refresh_token
|
30
|
+
# ------------ Authorize ------------
|
31
|
+
puts ais_client.authorize app_id_auth: true, provider_id: 'agfbfr', redirect_uri: 'https://www.google.fr', state: 'ok',
|
32
|
+
x_psu_id: nil, x_psu_ip_address: nil
|
33
|
+
# ------------ Authorize decoupled ------------
|
34
|
+
puts ais_client.authorize_decoupled app_id_auth: false, provider_id: 'agfbfr', polling_id: '1234'
|
35
|
+
# ------------ Get accounts ------------
|
36
|
+
accounts_response = ais_client.accounts customer_id: customer_id, account_id: nil, remove_nulls: nil, withBalances: nil
|
37
|
+
account = accounts_response['data'].first
|
38
|
+
account_id = account['id']
|
39
|
+
# ------------ Get transactions ------------
|
40
|
+
transactions_filters = {
|
41
|
+
"filter[date_to]": '2020-01-01',
|
42
|
+
'filter[date_from]': 'max'
|
43
|
+
}
|
44
|
+
transactions_response = ais_client.transactions customer_id: customer_id, account_id: account_id, remove_nulls: true,
|
45
|
+
convert_dates: true, filters: transactions_filters
|
46
|
+
transaction = transactions_response['data'].first
|
47
|
+
puts transaction
|
48
|
+
# ------------ Get account holders ------------
|
49
|
+
# Caution the hasAccountholders field in db must have a value = 1.
|
50
|
+
puts ais_client.account_holders customer_id: customer_id, remove_nulls: nil
|
51
|
+
# ------------ Delete customer ------------
|
52
|
+
# Customer not found if customer you don't use the api before
|
53
|
+
puts ais_client.delete_customer customer_id: customer_id
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{
|
2
|
+
"environment": "local",
|
3
|
+
"app_id": "043e25e7-92b7-4871-a941-3fb4b0fac07c",
|
4
|
+
"app_secret": "7c6ec508-600c-43ff-9f89-514ac65c9f67",
|
5
|
+
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCgteF+uhVdSltL\nKYtOwt+PWVu3U1zfPcKFy/Hf2htCyvxXZ4ibR5rXsCDFqpHiyUtAN5YYcaWlqwg2\n2EapV6Z+MGZHff+PVOxDQco08nrfHGESn8akHU1/REKak9WX/tuhmNvqjOirQ8WO\n30AR/Bsz5j09/epOFF925V0MIpFxF7hndQ+YKyzc1VNWiqC5e/MmO6i3ZiwLUABv\n+yMyIOmObbuCc2itMRnQPcpWDi6rLGSnOEJisXdzeYQk8cMiMwtxlATOikA/fQBF\norBHmhuS5IykG6EVRL6wacg3Q5sl0mm1r5oYAf3QPOp/eg08lJPO9KiUDgp8/X7s\nHiZ1CvpVAgMBAAECggEAEcrBCa4hQmBChio1xYT2iiC68itU+1QTjot7Hiy/2t+t\nGyIXshU1084oeqm9F+3wGk5tHAys6Y/rS2MbQ5E0GgFSuXR+EAi3VWTZtY3ow32Z\nU54DuFSUKVRNyV43henNt/C73BY4hgltPDmEFtmhy1egjRXo1DcWMIwJBphnIK1y\nJzD1IDJeCSng3Wa6tp9rhI0Lc5Iu7A9kKW6ACqlaGDziySuF+KI4qHa8DBd3WKIC\nWp0LOyVWzKIAHd9pLul7udBiZMOk7teYpho/OOQGMR7WZ1dhMXsisE+k/o0NGP/w\noHPXB6EbgXCXXDKghS182SwZ81KE5FfmABQ984CYWwKBgQDS7uDCfcNzy5/TJKfO\nFDO7ax3v6q/0XGrE1KfkEj6MBfwKIkA/LQEu4JJAYzAxMjvl3whqWwUI2ULiuKEh\nDMyL7OMUs2CQt1wkpxjSyQhtAmxyiVC7DJQSsGuVdR7Q9KconmaIXtE+IzYwr0k8\n4jmRsRfRlipxoQvj+reFFTYygwKBgQDDDAsJcQJKxQjmvJmffVqhehGRDHJilFVf\ntUVB8QgKB/6z7o7k+Xe6Jm8ZAxjc63mbka1n7WcH+yl/CzIp7n6OgNvn7sZWefqF\nyPP8nBM4/o2JME45CyF3rSKnL/HRQ76TjW8EcLIKZ6NAN0EkedQDK2VLcqk/hqcy\nnDfBTB+oRwKBgG2jrv5JQpvg3q1wYyzSAWXMst3u/hClLPYslywMc6hyv+RAk2aD\nLRdBsaN4KyeXNd0xRf2KXB6SV5rjXxV/wp6EvjAXYP034dRHara9ufx3gwkx6N2h\nFyJzwygHncH9ORn6487EgjyrLtK1efsEl+nrxDazuFIh5L1Wp6esM+SjAoGBAKP2\n2sxcEPYz/xChGW+m3GqEiIHr+bh/Q+nKI+eULRLpt6cg80TvpkN5jclz/hGxbjBm\nXWTRgNyHulGPYuM3F3LKRpMJ+fe2YPDYhqsjtVEjRG5AinGPttm5VTlAp8ModOvr\naJlN942ho+4WxQ9Zzu2/LE8pm7fIhYOZKZG4YaB/AoGAZvY7c/GPbpfdHuSAe5qH\nw3+39bJ0qv8s51V40hjOTMalux3YF5LRG+rDFDhUem9qkdfMIrVAm374w5AVfz6H\nQ60iR+ebz0kkpqHhsyHk2IAwamPPtbNAZhqCRoVvVJWHui7zD3v2jdb2nGbk3oXc\n8BeFbmwg3pKBHmMBAZTzTgg=\n-----END PRIVATE KEY-----"
|
6
|
+
}
|
data/exemples/pis.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/fintecture'
|
4
|
+
|
5
|
+
config = JSON.parse(File.read('./exemples/config_pis.json'))
|
6
|
+
|
7
|
+
pis_client = Fintecture::PisClient.new({
|
8
|
+
environment: config['environment'],
|
9
|
+
app_id: config['app_id'],
|
10
|
+
app_secret: config['app_secret'],
|
11
|
+
private_key: config['private_key']
|
12
|
+
})
|
13
|
+
|
14
|
+
payload_connect = {
|
15
|
+
meta: {
|
16
|
+
psu_name: 'John Doe', # Mandatory
|
17
|
+
psu_email: 'John.Doe@gmail.com', # Mandatory
|
18
|
+
psu_phone: '666777888', # Mandatory
|
19
|
+
psu_phone_prefix: '', # Optionnal
|
20
|
+
psu_ip: '127.0.0.1', # Optionnal (Plante la signature)
|
21
|
+
psu_form: '', # Mandatory - if no fixed beneficiary
|
22
|
+
psu_incorporation: '', # Mandatory - if no fixed beneficiary
|
23
|
+
psu_address: {
|
24
|
+
street: 'Main St.', # Mandatory
|
25
|
+
# number: '123', # Optional
|
26
|
+
complement: '2nd floor', # Optional
|
27
|
+
city: 'Paris', # Mandatory
|
28
|
+
zip: '75000', # Mandatory
|
29
|
+
country: 'fr' # Mandatory
|
30
|
+
}
|
31
|
+
},
|
32
|
+
data: {
|
33
|
+
type: 'PIS',
|
34
|
+
attributes: {
|
35
|
+
amount: '123', # Mandatory
|
36
|
+
currency: 'EUR', # Mandatory
|
37
|
+
communication: 'Thanks Mom!' # Mandatory
|
38
|
+
# execution_date: '2021-09-31', # Optional
|
39
|
+
# beneficiary: { # Optional
|
40
|
+
# name: "Dummy SA", # Conditional
|
41
|
+
# iban: "FR1420041010050500013M02606", # Conditional
|
42
|
+
# swift_bic: "FTSBSESSXXX", # Conditional
|
43
|
+
# street: "road of somewhere", # Conditional
|
44
|
+
# number: "2", # Optional
|
45
|
+
# complement:"", # Optional
|
46
|
+
# city: "Paris", # Conditional
|
47
|
+
# zip: "93160", # Conditional
|
48
|
+
# country: "FR", # Conditional
|
49
|
+
# form: "", # Mandatory if no fixed beneficiary
|
50
|
+
# incorporation: "" # Mandatory if no fixed beneficiary
|
51
|
+
# },
|
52
|
+
# debited_account_id: 'FR1420041010050500013M02606', # Optional
|
53
|
+
# debited_account_type: 'iban', # Mandatory if debited_account_id exist
|
54
|
+
# end_to_end_id: '5f78e902907e4209aa8df63659b05d24',
|
55
|
+
# scheme: 'AUTO' # Optional
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
payload_request_to_pay = {
|
61
|
+
meta: {
|
62
|
+
psu_name: 'John Doe', # Mandatory
|
63
|
+
psu_email: 'John.Doe@gmail.com', # Mandatory
|
64
|
+
psu_phone: '666777888', # Mandatory
|
65
|
+
psu_phone_prefix: '+33', # Optionnal
|
66
|
+
psu_address: {
|
67
|
+
street: 'Main St.', # Mandatory
|
68
|
+
number: '123', # Optional
|
69
|
+
city: 'Paris', # Mandatory
|
70
|
+
zip: '75000', # Mandatory
|
71
|
+
country: 'fr' # Mandatory
|
72
|
+
},
|
73
|
+
expirary: 86_400, # Optional
|
74
|
+
cc: 'John.Doe@gmail.com', # Optional
|
75
|
+
bcc: 'John.Doe@gmail.com' # Optional
|
76
|
+
},
|
77
|
+
data: {
|
78
|
+
type: 'REQUEST_TO_PAY',
|
79
|
+
attributes: {
|
80
|
+
amount: 123, # Mandatory
|
81
|
+
currency: 'EUR', # Mandatory
|
82
|
+
communication: 'Thanks Mom!' # Mandatory
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
payload_initiate = {
|
88
|
+
"meta": {
|
89
|
+
"psu_name": 'Bob McCheese',
|
90
|
+
"psu_email": 'John.Doe@gmail.com',
|
91
|
+
"psu_phone": '09743593535',
|
92
|
+
"psu_address": {
|
93
|
+
"street": 'route de la france',
|
94
|
+
"number": '33',
|
95
|
+
"complement": '2nd floor',
|
96
|
+
"zip": '12001',
|
97
|
+
"city": 'Paris',
|
98
|
+
"country": 'FR'
|
99
|
+
}
|
100
|
+
},
|
101
|
+
"data": {
|
102
|
+
"type": 'PIS',
|
103
|
+
"attributes": {
|
104
|
+
"amount": '149.30',
|
105
|
+
"currency": 'EUR',
|
106
|
+
"communication": 'Order 6543321'
|
107
|
+
# "beneficiary": {
|
108
|
+
# "name": "Bob Smith",
|
109
|
+
# "street": "road of somewhere",
|
110
|
+
# "number": "2",
|
111
|
+
# "city": "Paris",
|
112
|
+
# "zip": "93160",
|
113
|
+
# "country": "FR",
|
114
|
+
# "iban": "FR1420041010050500013M02606",
|
115
|
+
# "swift_bic": "BANKFRXXXXX"
|
116
|
+
# }
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
paramsProviders = {
|
122
|
+
'filter[country]': 'FR',
|
123
|
+
'filter[pis]': 'SEPA',
|
124
|
+
'filter[ais]': 'Accounts',
|
125
|
+
'filter[psu_type]': 'retail',
|
126
|
+
'filter[auth_model]': 'redirect',
|
127
|
+
'sort[name]': 'ASC',
|
128
|
+
'sort[full_name]': 'ASC',
|
129
|
+
'sort[country]': 'ASC',
|
130
|
+
'sort[provider_id]': 'ASC'
|
131
|
+
}
|
132
|
+
|
133
|
+
# ######################## PIS ########################
|
134
|
+
# ------------ Get access token ------------
|
135
|
+
pis_client.generate_token
|
136
|
+
# # ------------ Connect ------------
|
137
|
+
# puts pis_client.connect payload_connect, 'ok', 'https://www.google.fr'
|
138
|
+
# # ------------ Request to pay ------------
|
139
|
+
# puts pis_client.request_to_pay payload_request_to_pay, 'fr', 'https://www.google.fr'
|
140
|
+
# # ------------ Get payments ------------
|
141
|
+
# puts pis_client.payments '7f47d3675f5d4964bc416b43af63b06e'
|
142
|
+
# # ------------ Initiate ------------
|
143
|
+
# puts pis_client.initiate payload_initiate, 'cmcifrpp', 'https://www.google.fr', 'ok'
|
144
|
+
# # ------------ Refund ------------
|
145
|
+
# puts pis_client.refund '7f47d3675f5d4964bc416b43af63b06e', 1
|
146
|
+
# # ------------ settlements ------------
|
147
|
+
puts pis_client.settlements
|
148
|
+
puts pis_client.settlements 'e76778c4-d987-4b6a-901a-07686b9c7c9c', true
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require './lib/fintecture'
|
4
|
+
|
5
|
+
# ------------ Test class -------------
|
6
|
+
config = JSON.parse(File.read('./exemples/config_pis.json'))
|
7
|
+
|
8
|
+
pis_client = Fintecture::PisClient.new({
|
9
|
+
environment: config['environment'],
|
10
|
+
app_id: config['app_id'],
|
11
|
+
app_secret: config['app_secret'],
|
12
|
+
private_key: config['private_key']
|
13
|
+
})
|
14
|
+
|
15
|
+
# ######################## RESSOURCES ########################
|
16
|
+
# ------------ Get providers ------------
|
17
|
+
puts pis_client.providers provider_id: 'agfbfr'
|
18
|
+
puts pis_client.providers paramsProviders: paramsProviders
|
19
|
+
# ------------ Get applications ------------
|
20
|
+
puts pis_client.applications
|
21
|
+
# ------------ Get test accounts ------------
|
22
|
+
puts pis_client.test_accounts
|
23
|
+
puts pis_client.test_accounts 'bbvaes'
|
data/fintecture.gemspec
CHANGED
@@ -1,43 +1,44 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
|
12
|
-
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
spec.metadata[
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
spec.
|
37
|
-
spec.
|
38
|
-
|
39
|
-
|
40
|
-
spec.add_development_dependency
|
41
|
-
spec.add_development_dependency
|
42
|
-
spec.
|
43
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'fintecture/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'fintecture'
|
9
|
+
spec.version = Fintecture::VERSION
|
10
|
+
spec.authors = ['Fintecture']
|
11
|
+
spec.email = ['alvaro.fernandez@nazaries.com']
|
12
|
+
|
13
|
+
spec.summary = 'Short summary'
|
14
|
+
spec.description = 'Longer summary'
|
15
|
+
spec.homepage = 'http://fintecture.com'
|
16
|
+
spec.license = 'GPL-3.0'
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
# spec.metadata["allowed_push_host"] = 'http://mygemserver.com'
|
22
|
+
|
23
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
24
|
+
spec.metadata['source_code_uri'] = 'https://github.com/Fintecture/fintecture-sdk-ruby'
|
25
|
+
# spec.metadata["changelog_uri"] = spec.homepage
|
26
|
+
else
|
27
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
28
|
+
'public gem pushes.'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Specify which files should be added to the gem when it is released.
|
32
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
33
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
34
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
35
|
+
end
|
36
|
+
spec.bindir = 'exe'
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = ['lib']
|
39
|
+
|
40
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
41
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
+
spec.add_dependency 'faraday'
|
44
|
+
end
|
@@ -0,0 +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
|
@@ -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 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
|
@@ -0,0 +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
|