ibanity 1.0 → 1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rspec +1 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +20 -0
- data/README.md +2 -0
- data/ibanity.gemspec +1 -2
- data/lib/ibanity.rb +33 -2
- data/lib/ibanity/api/base_resource.rb +1 -1
- data/lib/ibanity/api/consent/consent.rb +41 -0
- data/lib/ibanity/api/consent/processing_operation.rb +37 -0
- data/lib/ibanity/api/isabel_connect/access_token.rb +2 -2
- data/lib/ibanity/api/isabel_connect/intraday_transaction.rb +10 -0
- data/lib/ibanity/api/isabel_connect/refresh_token.rb +4 -4
- data/lib/ibanity/api/o_auth_resource.rb +9 -2
- data/lib/ibanity/api/ponto_connect/account.rb +15 -0
- data/lib/ibanity/api/ponto_connect/financial_institution.rb +15 -0
- data/lib/ibanity/api/ponto_connect/payment.rb +20 -0
- data/lib/ibanity/api/ponto_connect/sandbox/financial_institution_account.rb +21 -0
- data/lib/ibanity/api/ponto_connect/sandbox/financial_institution_transaction.rb +31 -0
- data/lib/ibanity/api/ponto_connect/synchronization.rb +15 -0
- data/lib/ibanity/api/ponto_connect/token.rb +53 -0
- data/lib/ibanity/api/ponto_connect/transaction.rb +15 -0
- data/lib/ibanity/api/ponto_connect/usage.rb +10 -0
- data/lib/ibanity/api/ponto_connect/user_info.rb +10 -0
- data/lib/ibanity/api/sandbox/financial_institution_holding.rb +45 -0
- data/lib/ibanity/api/xs2a/account_information_access_request_authorization.rb +21 -0
- data/lib/ibanity/api/xs2a/bulk_payment_initiation_request.rb +33 -0
- data/lib/ibanity/api/xs2a/holding.rb +21 -0
- data/lib/ibanity/api/xs2a/payment_initiation_request_authorization.rb +21 -0
- data/lib/ibanity/api/xs2a/periodic_payment_initiation_request.rb +33 -0
- data/lib/ibanity/client.rb +10 -7
- data/lib/ibanity/error.rb +9 -5
- data/lib/ibanity/http_signature.rb +1 -1
- data/lib/ibanity/util.rb +11 -4
- data/lib/ibanity/version.rb +1 -1
- data/spec/lib/ibanity/util_spec.rb +89 -0
- data/spec/spec_helper.rb +100 -0
- metadata +32 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 81118d7e11ae925cc6430b6c8bd2ffd2afa948ee5c867c433f39c382522221b8
|
4
|
+
data.tar.gz: 97ddaeb532907a37de4fcede16e0365eca040ca0400b3f3062b6f951e276c1b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11bd6d234f2aa23f685fc8628fc95b66aef1d668e888f83a12adfbc92882ed0e3a1f75943af66dfdc9014b867ea503afd423f7bb70cef47194f1a1c928e6fc78
|
7
|
+
data.tar.gz: 783515919ad0436aa0e851999b86a288b8e73b1a240465f21e39606a422bb903eb61356b2641188c9558d88ad8517c2493f0013e882df22939b073f0e68bbcf5
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
script: bundle exec rspec
|
3
|
+
deploy:
|
4
|
+
provider: rubygems
|
5
|
+
api_key:
|
6
|
+
secure: pfXgGXH/AZEG3HMiaJPmJ7fck6Z3Hj0y7TU5TwvLAtKuBy6hlLT67ne/VfeBZQKa9d7eerr9PFP1hvLjZppScZMMOTtjBTvwpchkcUDwCxHx5GzS/jRnBF+uYHIza2p4Wq8yIPug7UrZ0qyq5VOG45R/nC/fPm2Ht2T7heqF5VgRaDGrN7Fq3zXn7duiYhTy02nDXorZ/kEAjnwdwDtXWyVFq8wr4inTExYrDP9/M57qx5TrkgWmcQ7JrvO2KfLDMJqAxI8lNoaPl5dAi7q1XWqqSVay7h9OAnP4UfvnvAc106lG6nHfTQig1krTfxRAvtHlPQjSlFkL+0qfBPBz1C/ex221O3NsNBYmI/mJ45lcNhqJbnkV2VEAEgUoe4ZFfKUUczLfnVxIPjoQmHMwLwfEO4g8/Hz/I3L7bvebgfzGGMDpmN6ERZRJmhutE6K5cL80ghoLs6ExJLoqHi1qvdBSkM2IyE4Yo+lob/hKU1IBL1w13T2h3EHapBh3kKn+jBzu/y5nXTEteBHbMP8j2zxFiihVBJEKPXhg/iU8WHLI6HZgWJkOc9ZH3hS7CN3VELK7fVZp9jaPAKaKihdvxQ0z3gCPFL+E6rYKsBPYqXE6qDsSQswhqTN15W0eVQqK8fDXkZmW0lSGvi2IJvL0CjIaahfB2GaapTtqOwar7sc=
|
7
|
+
on:
|
8
|
+
tags: true
|
9
|
+
gem: ibanity
|
10
|
+
skip_cleanup: true
|
11
|
+
notifications:
|
12
|
+
email: false
|
13
|
+
slack:
|
14
|
+
- rooms:
|
15
|
+
- secure: J06CK+muuVTW1SS1GmhSw7ZVo0vEMFpNWU5B9Cz94h5BZI3rPSxZFSCQG8OTQ/lBIrzPTlQj5JGzYgHpS5QRHGa4s1A1tYrZUfjUUgaZ7SIfoY8AgHH6cKF+jtwYy2z+kOJekBtfNLqfzAx+48QrxdbmBnXTG+r7UXczw0TAB7BMKh8107q7kqgjKiAnpGlXzC6rLWUwdRF/1qvDtYFCjoZ0OpYMnUUK+0/bgwVHxjYRl64DrPD3jC2XoaCTRCMyLbfqb9ZUXKVf27ByAQ/Ikj+qODdSH10vwPARXlbbVhpPfjAax42zC1OwSABdE00iJW1+TuoI69znjWg1d8Ti97raihV98OXMyqHXPKxX/gZp+0MSuYIE9GQWY791ulmQ+GwwkgB6v2LmXGCE8K+eUCc3zkGJWVUzBP+Wu49mDzDAQHBPl/G3u26RqmVQzWhk9ckHQ30cyIPFjz/eaMrda+wgQ6AKzfNq+XVL6hAO+Se28PRPhDu33ZzIKqgpk0dH77LcKPI/Uf1dCT+0oa+pvVx1T0Z93SNp0azh71rx9AOWBMZm7TcOYvMOw9QpVBZkoWy4NQo9PMT0Jo73qAnOTHadr8b5zeDoAu7jnlhCxIpmnrmIh4Dz6n6XF+c+d+C/MAQVQ0rKj7KzTYEsYat0NQ62lgBtHy5/Qmu736MaIVA=
|
16
|
+
if: (tag =~ ^v) AND (branch = master)
|
17
|
+
- rooms:
|
18
|
+
- secure: J06CK+muuVTW1SS1GmhSw7ZVo0vEMFpNWU5B9Cz94h5BZI3rPSxZFSCQG8OTQ/lBIrzPTlQj5JGzYgHpS5QRHGa4s1A1tYrZUfjUUgaZ7SIfoY8AgHH6cKF+jtwYy2z+kOJekBtfNLqfzAx+48QrxdbmBnXTG+r7UXczw0TAB7BMKh8107q7kqgjKiAnpGlXzC6rLWUwdRF/1qvDtYFCjoZ0OpYMnUUK+0/bgwVHxjYRl64DrPD3jC2XoaCTRCMyLbfqb9ZUXKVf27ByAQ/Ikj+qODdSH10vwPARXlbbVhpPfjAax42zC1OwSABdE00iJW1+TuoI69znjWg1d8Ti97raihV98OXMyqHXPKxX/gZp+0MSuYIE9GQWY791ulmQ+GwwkgB6v2LmXGCE8K+eUCc3zkGJWVUzBP+Wu49mDzDAQHBPl/G3u26RqmVQzWhk9ckHQ30cyIPFjz/eaMrda+wgQ6AKzfNq+XVL6hAO+Se28PRPhDu33ZzIKqgpk0dH77LcKPI/Uf1dCT+0oa+pvVx1T0Z93SNp0azh71rx9AOWBMZm7TcOYvMOw9QpVBZkoWy4NQo9PMT0Jo73qAnOTHadr8b5zeDoAu7jnlhCxIpmnrmIh4Dz6n6XF+c+d+C/MAQVQ0rKj7KzTYEsYat0NQ62lgBtHy5/Qmu736MaIVA=
|
19
|
+
on_success: change
|
20
|
+
on_failure: always
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.3
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
|
7
|
+
* [Ponto Connect] Add support for the /userinfo and /organizations/{id}/usage endpoints.
|
8
|
+
|
9
|
+
## 1.2
|
10
|
+
|
11
|
+
### Enhancements
|
12
|
+
|
13
|
+
* Add support for periodic and bulk payments
|
14
|
+
* Add snake-case transformation for deeply nested data structures
|
15
|
+
|
16
|
+
## 1.1.1
|
17
|
+
|
18
|
+
### Enhancements
|
19
|
+
|
20
|
+
* Improve debugging by logging the `ibanity_request_id` header from the response in case of error
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/ibanity/ibanity-ruby.svg?branch=master)](https://travis-ci.org/ibanity/ibanity-ruby)
|
2
|
+
|
1
3
|
# Ibanity Ruby Library
|
2
4
|
|
3
5
|
The Ibanity Ruby Library provides convenient wrappers around the Ibanity API. The object attributes are dynamically defined based on the API response, supporting minor API changes seamlessly.
|
data/ibanity.gemspec
CHANGED
@@ -19,6 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rest-client", ">= 1.8.0"
|
22
|
-
spec.add_development_dependency "rspec", "3.
|
23
|
-
spec.add_development_dependency "webmock", "1.24.2"
|
22
|
+
spec.add_development_dependency "rspec", "3.9.0"
|
24
23
|
end
|
data/lib/ibanity.rb
CHANGED
@@ -13,23 +13,42 @@ require_relative "ibanity/http_signature"
|
|
13
13
|
require_relative "ibanity/api/base_resource"
|
14
14
|
require_relative "ibanity/api/xs2a/account"
|
15
15
|
require_relative "ibanity/api/xs2a/transaction"
|
16
|
+
require_relative "ibanity/api/xs2a/holding"
|
16
17
|
require_relative "ibanity/api/xs2a/financial_institution"
|
17
18
|
require_relative "ibanity/api/xs2a/account_information_access_request"
|
19
|
+
require_relative "ibanity/api/xs2a/account_information_access_request_authorization"
|
20
|
+
require_relative "ibanity/api/xs2a/payment_initiation_request_authorization"
|
18
21
|
require_relative "ibanity/api/xs2a/customer_access_token"
|
19
22
|
require_relative "ibanity/api/xs2a/customer"
|
20
23
|
require_relative "ibanity/api/xs2a/payment_initiation_request"
|
24
|
+
require_relative "ibanity/api/xs2a/bulk_payment_initiation_request"
|
25
|
+
require_relative "ibanity/api/xs2a/periodic_payment_initiation_request"
|
21
26
|
require_relative "ibanity/api/xs2a/synchronization"
|
22
27
|
require_relative "ibanity/api/o_auth_resource"
|
23
28
|
require_relative "ibanity/api/isabel_connect/account"
|
24
29
|
require_relative "ibanity/api/isabel_connect/balance"
|
25
30
|
require_relative "ibanity/api/isabel_connect/transaction"
|
31
|
+
require_relative "ibanity/api/isabel_connect/intraday_transaction"
|
26
32
|
require_relative "ibanity/api/isabel_connect/account_report"
|
27
33
|
require_relative "ibanity/api/isabel_connect/access_token"
|
28
34
|
require_relative "ibanity/api/isabel_connect/refresh_token"
|
29
35
|
require_relative "ibanity/api/isabel_connect/bulk_payment_initiation_request"
|
30
36
|
require_relative "ibanity/api/sandbox/financial_institution_account"
|
31
37
|
require_relative "ibanity/api/sandbox/financial_institution_transaction"
|
38
|
+
require_relative "ibanity/api/sandbox/financial_institution_holding"
|
32
39
|
require_relative "ibanity/api/sandbox/financial_institution_user"
|
40
|
+
require_relative "ibanity/api/ponto_connect/token"
|
41
|
+
require_relative "ibanity/api/ponto_connect/financial_institution"
|
42
|
+
require_relative "ibanity/api/ponto_connect/account"
|
43
|
+
require_relative "ibanity/api/ponto_connect/transaction"
|
44
|
+
require_relative "ibanity/api/ponto_connect/synchronization"
|
45
|
+
require_relative "ibanity/api/consent/consent"
|
46
|
+
require_relative "ibanity/api/consent/processing_operation"
|
47
|
+
require_relative "ibanity/api/ponto_connect/payment"
|
48
|
+
require_relative "ibanity/api/ponto_connect/user_info"
|
49
|
+
require_relative "ibanity/api/ponto_connect/usage"
|
50
|
+
require_relative "ibanity/api/ponto_connect/sandbox/financial_institution_account"
|
51
|
+
require_relative "ibanity/api/ponto_connect/sandbox/financial_institution_transaction"
|
33
52
|
|
34
53
|
module Ibanity
|
35
54
|
class << self
|
@@ -42,6 +61,8 @@ module Ibanity
|
|
42
61
|
@client = nil
|
43
62
|
@xs2a_api_schema = nil
|
44
63
|
@isabel_connect_api_schema = nil
|
64
|
+
@consent_api_schema = nil
|
65
|
+
@ponto_connect_api_schema = nil
|
45
66
|
@sandbox_api_schema = nil
|
46
67
|
@configuration = nil
|
47
68
|
yield configuration
|
@@ -56,8 +77,10 @@ module Ibanity
|
|
56
77
|
:signature_certificate_id,
|
57
78
|
:signature_key,
|
58
79
|
:signature_key_passphrase,
|
59
|
-
:
|
60
|
-
:
|
80
|
+
:isabel_connect_client_id,
|
81
|
+
:isabel_connect_client_secret,
|
82
|
+
:ponto_connect_client_id,
|
83
|
+
:ponto_connect_client_secret,
|
61
84
|
:api_scheme,
|
62
85
|
:api_host,
|
63
86
|
:api_port,
|
@@ -77,6 +100,14 @@ module Ibanity
|
|
77
100
|
@isabel_connect_api_schema ||= client.get(uri: "#{client.base_uri}/isabel-connect")["links"]
|
78
101
|
end
|
79
102
|
|
103
|
+
def ponto_connect_api_schema
|
104
|
+
@ponto_connect_api_schema ||= client.get(uri: "#{client.base_uri}/ponto-connect")["links"]
|
105
|
+
end
|
106
|
+
|
107
|
+
def consent_api_schema
|
108
|
+
@consent_api_schema ||= client.get(uri: "#{client.base_uri}/consent")["links"]
|
109
|
+
end
|
110
|
+
|
80
111
|
def respond_to_missing?(method_name, include_private = false)
|
81
112
|
client.respond_to?(method_name, include_private)
|
82
113
|
end
|
@@ -92,7 +92,7 @@ module Ibanity
|
|
92
92
|
attributes = raw["attributes"] || {}
|
93
93
|
meta = raw["meta"] || {}
|
94
94
|
params = base.merge(attributes).merge(meta)
|
95
|
-
Ibanity::Util.
|
95
|
+
Ibanity::Util.underscorize(params)
|
96
96
|
end
|
97
97
|
|
98
98
|
def setup_relationships(relationships, customer_access_token = nil)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Consent
|
3
|
+
class Consent < Ibanity::BaseResource
|
4
|
+
def self.create(idempotency_key: nil, **attributes)
|
5
|
+
path = Ibanity.consent_api_schema["consents"].gsub("{consentId}", "")
|
6
|
+
uri = Ibanity.client.build_uri(path)
|
7
|
+
create_by_uri(uri: uri, resource_type: "consent", attributes: attributes, idempotency_key: idempotency_key)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.list(**query_params)
|
11
|
+
path = Ibanity.consent_api_schema["consents"].gsub("{consentId}", "")
|
12
|
+
uri = Ibanity.client.build_uri(path)
|
13
|
+
list_by_uri(uri: uri, query_params: query_params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.find(id:)
|
17
|
+
path = Ibanity.consent_api_schema["consents"].gsub("{consentId}", id)
|
18
|
+
uri = Ibanity.client.build_uri(path)
|
19
|
+
find_by_uri(uri: uri)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.validate(id:, idempotency_key: nil)
|
23
|
+
path = Ibanity.consent_api_schema["consent"]["validations"].gsub("{consentId}", id)
|
24
|
+
uri = Ibanity.client.build_uri(path)
|
25
|
+
create_by_uri(uri: uri, resource_type: "consent", attributes: [], idempotency_key: idempotency_key)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.revoke(id:, idempotency_key: nil)
|
29
|
+
path = Ibanity.consent_api_schema["consent"]["revocations"].gsub("{consentId}", id)
|
30
|
+
uri = Ibanity.client.build_uri(path)
|
31
|
+
create_by_uri(uri: uri, resource_type: "consent", attributes: [], idempotency_key: idempotency_key)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete(id:)
|
35
|
+
path = Ibanity.consent_api_schema["consents"].gsub("{consentId}", id)
|
36
|
+
uri = Ibanity.client.build_uri(path)
|
37
|
+
destroy_by_uri(uri: uri)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Consent
|
3
|
+
class ProcessingOperation < Ibanity::BaseResource
|
4
|
+
def self.create(consent_id:, idempotency_key: nil, **attributes)
|
5
|
+
path = Ibanity.consent_api_schema["consent"]["processingOperations"]
|
6
|
+
.gsub("{consentId}", consent_id)
|
7
|
+
.gsub("{processingOperationId}", "")
|
8
|
+
uri = Ibanity.client.build_uri(path)
|
9
|
+
create_by_uri(uri: uri, resource_type: "processingOperation", attributes: attributes, idempotency_key: idempotency_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.list(consent_id:, **query_params)
|
13
|
+
path = Ibanity.consent_api_schema["consent"]["processingOperations"]
|
14
|
+
.gsub("{consentId}", consent_id)
|
15
|
+
.gsub("{processingOperationId}", "")
|
16
|
+
uri = Ibanity.client.build_uri(path)
|
17
|
+
list_by_uri(uri: uri, query_params: query_params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find(id:, consent_id:)
|
21
|
+
path = Ibanity.sandbox_api_schema["consent"]["processingOperations"]
|
22
|
+
.gsub("{consentId}", consent_id)
|
23
|
+
.gsub("{processingOperationId}", id)
|
24
|
+
uri = Ibanity.client.build_uri(path)
|
25
|
+
find_by_uri(uri: uri)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.revoke(id:, consent_id:, idempotency_key: nil)
|
29
|
+
path = Ibanity.consent_api_schema["consent"]["processingOperation"]["revocations"]
|
30
|
+
.gsub("{consentId}", consent_id)
|
31
|
+
.gsub("{processingOperationId}", id)
|
32
|
+
uri = Ibanity.client.build_uri(path)
|
33
|
+
create_by_uri(uri: uri, resource_type: "processingOperation", attributes: [], idempotency_key: idempotency_key)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -6,8 +6,8 @@ module Ibanity
|
|
6
6
|
arguments = [
|
7
7
|
["grant_type", "refresh_token"],
|
8
8
|
["refresh_token", refresh_token],
|
9
|
-
["client_id", Ibanity.client.
|
10
|
-
["client_secret", Ibanity.client.
|
9
|
+
["client_id", Ibanity.client.isabel_connect_client_id],
|
10
|
+
["client_secret", Ibanity.client.isabel_connect_client_secret]
|
11
11
|
]
|
12
12
|
payload = URI.encode_www_form(arguments)
|
13
13
|
create_by_uri(uri: uri, payload: payload, idempotency_key: idempotency_key)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module IsabelConnect
|
3
|
+
class IntradayTransaction < Ibanity::BaseResource
|
4
|
+
def self.list(account_id:, access_token:, headers: nil, **query_params)
|
5
|
+
uri = Ibanity.isabel_connect_api_schema["account"]["intradayTransactions"].sub("{accountId}", account_id)
|
6
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token, headers: headers)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -6,8 +6,8 @@ module Ibanity
|
|
6
6
|
arguments = [
|
7
7
|
["grant_type", "authorization_code"],
|
8
8
|
["code", authorization_code],
|
9
|
-
["client_id", Ibanity.client.
|
10
|
-
["client_secret", Ibanity.client.
|
9
|
+
["client_id", Ibanity.client.isabel_connect_client_id],
|
10
|
+
["client_secret", Ibanity.client.isabel_connect_client_secret],
|
11
11
|
["redirect_uri", redirect_uri]
|
12
12
|
]
|
13
13
|
payload = URI.encode_www_form(arguments)
|
@@ -18,8 +18,8 @@ module Ibanity
|
|
18
18
|
uri = Ibanity.isabel_connect_api_schema["oAuth2"]["refreshTokens"]["revoke"]
|
19
19
|
arguments = [
|
20
20
|
["token", token],
|
21
|
-
["client_id", Ibanity.client.
|
22
|
-
["client_secret", Ibanity.client.
|
21
|
+
["client_id", Ibanity.client.isabel_connect_client_id],
|
22
|
+
["client_secret", Ibanity.client.isabel_connect_client_secret]
|
23
23
|
]
|
24
24
|
payload = URI.encode_www_form(arguments)
|
25
25
|
create_by_uri(uri: uri, payload: payload)
|
@@ -1,7 +1,14 @@
|
|
1
1
|
module Ibanity
|
2
2
|
class OAuthResource < OpenStruct
|
3
|
-
def self.create_by_uri(uri:, payload:, idempotency_key: nil)
|
4
|
-
raw_item = Ibanity.client.post(uri: uri, payload: payload, json: false, idempotency_key: idempotency_key)
|
3
|
+
def self.create_by_uri(uri:, payload:, idempotency_key: nil, headers: nil)
|
4
|
+
raw_item = Ibanity.client.post(uri: uri, payload: payload, json: false, idempotency_key: idempotency_key, headers: headers)
|
5
|
+
raw_item = {} if raw_item == ""
|
6
|
+
new(raw_item)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find_by_uri(uri:, customer_access_token: nil, headers: nil)
|
10
|
+
raw_item = Ibanity.client.get(uri: uri, customer_access_token: customer_access_token, headers: headers)
|
11
|
+
raw_item = {} if raw_item == ""
|
5
12
|
new(raw_item)
|
6
13
|
end
|
7
14
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Account < Ibanity::BaseResource
|
4
|
+
def self.list(access_token:, **query_params)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["accounts"].sub("{accountId}", "")
|
6
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(access_token:, id:)
|
10
|
+
uri = Ibanity.ponto_connect_api_schema["accounts"].sub("{accountId}", id)
|
11
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class FinancialInstitution < Ibanity::BaseResource
|
4
|
+
def self.list(access_token: nil, **query_params)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["financialInstitutions"].sub("{financialInstitutionId}", "")
|
6
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(access_token: nil, id:)
|
10
|
+
uri = Ibanity.ponto_connect_api_schema["financialInstitutions"].sub("{financialInstitutionId}", id)
|
11
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Payment < Ibanity::BaseResource
|
4
|
+
def self.find(access_token:, account_id:, id:)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["payments"].sub("{accountId}", account_id).sub("{paymentId}", id)
|
6
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create(account_id:, access_token: nil, **attributes)
|
10
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["payments"].gsub("{accountId}", account_id).gsub("{paymentId}", "")
|
11
|
+
create_by_uri(uri: uri, resource_type: "payment", attributes: attributes, customer_access_token: access_token)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.delete(id:, account_id:, access_token:)
|
15
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["payments"].gsub("{accountId}", account_id).gsub("{paymentId}", id)
|
16
|
+
destroy_by_uri(uri: uri, customer_access_token: access_token)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
module Sandbox
|
4
|
+
class FinancialInstitutionAccount < Ibanity::BaseResource
|
5
|
+
def self.list(access_token:, financial_institution_id:, **query_params)
|
6
|
+
uri = Ibanity.ponto_connect_api_schema["sandbox"]["financialInstitution"]["financialInstitutionAccounts"]
|
7
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
8
|
+
.gsub("{financialInstitutionAccountId}", "")
|
9
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find(access_token:, id:, financial_institution_id:)
|
13
|
+
uri = Ibanity.ponto_connect_api_schema["sandbox"]["financialInstitution"]["financialInstitutionAccounts"]
|
14
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
15
|
+
.gsub("{financialInstitutionAccountId}", id)
|
16
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
module Sandbox
|
4
|
+
class FinancialInstitutionTransaction < Ibanity::BaseResource
|
5
|
+
def self.list(access_token:, financial_institution_account_id:, financial_institution_id:, **query_params)
|
6
|
+
uri = Ibanity.ponto_connect_api_schema["sandbox"]["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionTransactions"]
|
7
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
8
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
9
|
+
.gsub("{financialInstitutionTransactionId}", "")
|
10
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.find(access_token:, id:, financial_institution_id:, financial_institution_account_id:)
|
14
|
+
uri = Ibanity.ponto_connect_api_schema["sandbox"]["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionTransactions"]
|
15
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
16
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
17
|
+
.gsub("{financialInstitutionTransactionId}", id)
|
18
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.create(access_token:, financial_institution_id:, financial_institution_account_id:, **attributes)
|
22
|
+
uri = Ibanity.ponto_connect_api_schema["sandbox"]["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionTransactions"]
|
23
|
+
.sub("{financialInstitutionId}", financial_institution_id)
|
24
|
+
.sub("{financialInstitutionAccountId}", financial_institution_account_id)
|
25
|
+
.sub("{financialInstitutionTransactionId}", "")
|
26
|
+
create_by_uri(uri: uri, resource_type: "financialInstitutionTransaction", attributes: attributes, customer_access_token: access_token)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Synchronization < Ibanity::BaseResource
|
4
|
+
def self.create(access_token:, **attributes)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["synchronizations"].sub("{synchronizationId}", "")
|
6
|
+
create_by_uri(uri: uri, resource_type: "synchronization", attributes: attributes, customer_access_token: access_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(id:, access_token:)
|
10
|
+
uri = Ibanity.ponto_connect_api_schema["synchronizations"].sub("{synchronizationId}", id)
|
11
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Token < Ibanity::OAuthResource
|
4
|
+
def self.create(refresh_token: nil, authorization_code: nil, redirect_uri: nil, idempotency_key: nil, code_verifier: nil)
|
5
|
+
arguments =
|
6
|
+
if refresh_token
|
7
|
+
[
|
8
|
+
["grant_type", "refresh_token"],
|
9
|
+
["client_id", Ibanity.client.ponto_connect_client_id],
|
10
|
+
["refresh_token", refresh_token]
|
11
|
+
]
|
12
|
+
elsif authorization_code
|
13
|
+
[
|
14
|
+
["grant_type", "authorization_code"],
|
15
|
+
["client_id", Ibanity.client.ponto_connect_client_id],
|
16
|
+
["code", authorization_code],
|
17
|
+
["code_verifier", code_verifier],
|
18
|
+
["redirect_uri", redirect_uri]
|
19
|
+
]
|
20
|
+
else
|
21
|
+
[
|
22
|
+
["grant_type", "client_credentials"]
|
23
|
+
]
|
24
|
+
end
|
25
|
+
|
26
|
+
create_by_uri(
|
27
|
+
uri: Ibanity.ponto_connect_api_schema["oauth2"]["token"],
|
28
|
+
payload: URI.encode_www_form(arguments),
|
29
|
+
idempotency_key: idempotency_key,
|
30
|
+
headers: self.headers
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete(refresh_token:)
|
35
|
+
uri = Ibanity.ponto_connect_api_schema["oauth2"]["revoke"]
|
36
|
+
arguments = [
|
37
|
+
["token", refresh_token]
|
38
|
+
]
|
39
|
+
payload = URI.encode_www_form(arguments)
|
40
|
+
create_by_uri(uri: uri, payload: payload, headers: self.headers)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def self.headers
|
46
|
+
{
|
47
|
+
"Authorization": "Basic " + Base64.strict_encode64("#{Ibanity.client.ponto_connect_client_id}:#{Ibanity.client.ponto_connect_client_secret}"),
|
48
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Transaction < Ibanity::BaseResource
|
4
|
+
def self.list(access_token:, account_id:, **query_params)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["transactions"].sub("{accountId}", account_id).sub("{transactionId}", "")
|
6
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: access_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(access_token:, account_id:, id:)
|
10
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["transactions"].sub("{accountId}", account_id).sub("{transactionId}", id)
|
11
|
+
find_by_uri(uri: uri, customer_access_token: access_token)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class Usage < Ibanity::BaseResource
|
4
|
+
def self.find(client_access_token:, organization_id:, month:)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["organizations"]["usage"].sub("{organizationId}", organization_id).sub("{month}", month)
|
6
|
+
find_by_uri(uri: uri, customer_access_token: client_access_token)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Sandbox
|
3
|
+
class FinancialInstitutionHolding < Ibanity::BaseResource
|
4
|
+
def self.create(financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:, idempotency_key: nil, **attributes)
|
5
|
+
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionHoldings"]
|
6
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.gsub("{financialInstitutionUserId}", financial_institution_user_id)
|
8
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
9
|
+
.gsub("{financialInstitutionHoldingId}", "")
|
10
|
+
uri = Ibanity.client.build_uri(path)
|
11
|
+
create_by_uri(uri: uri, resource_type: "financialInstitutionHolding", attributes: attributes, idempotency_key: idempotency_key)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.list(financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:, **query_params)
|
15
|
+
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionHoldings"]
|
16
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
17
|
+
.gsub("{financialInstitutionUserId}", financial_institution_user_id)
|
18
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
19
|
+
.gsub("{financialInstitutionHoldingId}", "")
|
20
|
+
uri = Ibanity.client.build_uri(path)
|
21
|
+
list_by_uri(uri: uri, query_params: query_params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find(id:, financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:)
|
25
|
+
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionHoldings"]
|
26
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
27
|
+
.gsub("{financialInstitutionUserId}", financial_institution_user_id)
|
28
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
29
|
+
.gsub("{financialInstitutionHoldingId}", id)
|
30
|
+
uri = Ibanity.client.build_uri(path)
|
31
|
+
find_by_uri(uri: uri)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete(id:, financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:)
|
35
|
+
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionHoldings"]
|
36
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
37
|
+
.gsub("{financialInstitutionUserId}", financial_institution_user_id)
|
38
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
39
|
+
.gsub("{financialInstitutionHoldingId}", id)
|
40
|
+
uri = Ibanity.client.build_uri(path)
|
41
|
+
destroy_by_uri(uri: uri)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Xs2a
|
3
|
+
class AccountInformationAccessRequestAuthorization < Ibanity::BaseResource
|
4
|
+
def self.create(financial_institution_id:, account_information_access_request_id:, customer_access_token:, idempotency_key: nil, meta: nil, **attributes)
|
5
|
+
path = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["accountInformationAccessRequest"]["authorizations"]
|
6
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.gsub("{accountInformationAccessRequestId}", account_information_access_request_id)
|
8
|
+
.gsub("{authorizationId}", "")
|
9
|
+
uri = Ibanity.client.build_uri(path)
|
10
|
+
create_by_uri(
|
11
|
+
uri: uri,
|
12
|
+
resource_type: "authorization",
|
13
|
+
attributes: attributes,
|
14
|
+
customer_access_token: customer_access_token,
|
15
|
+
idempotency_key: idempotency_key,
|
16
|
+
meta: meta
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Xs2a
|
3
|
+
class BulkPaymentInitiationRequest < Ibanity::BaseResource
|
4
|
+
def self.create_for_financial_institution(financial_institution_id:, customer_access_token:, idempotency_key: nil, **attributes)
|
5
|
+
path = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["bulkPaymentInitiationRequests"]
|
6
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.sub("{paymentInitiationRequestId}", "")
|
8
|
+
uri = Ibanity.client.build_uri(path)
|
9
|
+
create_by_uri(
|
10
|
+
uri: uri,
|
11
|
+
resource_type: "bulkPaymentInitiationRequest",
|
12
|
+
attributes: attributes,
|
13
|
+
customer_access_token: customer_access_token,
|
14
|
+
idempotency_key: idempotency_key
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find(id:, financial_institution_id:, customer_access_token:)
|
19
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["bulkPaymentInitiationRequests"]
|
20
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
21
|
+
.sub("{paymentInitiationRequestId}", id)
|
22
|
+
find_by_uri(uri: uri, customer_access_token: customer_access_token)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.delete(id:, financial_institution_id:, customer_access_token:)
|
26
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["bulkPaymentInitiationRequests"]
|
27
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
28
|
+
.sub("{paymentInitiationRequestId}", id)
|
29
|
+
destroy_by_uri(uri: uri, customer_access_token: customer_access_token)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Xs2a
|
3
|
+
class Holding < Ibanity::BaseResource
|
4
|
+
def self.list(financial_institution_id:, account_id:, customer_access_token:, headers: nil, **query_params)
|
5
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["holdings"]
|
6
|
+
.sub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.sub("{accountId}", account_id)
|
8
|
+
.sub("{holdingId}", "")
|
9
|
+
list_by_uri(uri: uri, query_params: query_params, customer_access_token: customer_access_token, headers: headers)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.find(id:, financial_institution_id:, account_id:, customer_access_token:)
|
13
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["holdings"]
|
14
|
+
.sub("{financialInstitutionId}", financial_institution_id)
|
15
|
+
.sub("{accountId}", account_id)
|
16
|
+
.sub("{holdingId}", id)
|
17
|
+
find_by_uri(uri: uri, customer_access_token: customer_access_token)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Xs2a
|
3
|
+
class PaymentInitiationRequestAuthorization < Ibanity::BaseResource
|
4
|
+
def self.create(financial_institution_id:, payment_initiation_request_id:, customer_access_token:, idempotency_key: nil, meta: nil, **attributes)
|
5
|
+
path = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["paymentInitiationRequest"]["authorizations"]
|
6
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.gsub("{paymentInitiationRequestId}", payment_initiation_request_id)
|
8
|
+
.gsub("{authorizationId}", "")
|
9
|
+
uri = Ibanity.client.build_uri(path)
|
10
|
+
create_by_uri(
|
11
|
+
uri: uri,
|
12
|
+
resource_type: "authorization",
|
13
|
+
attributes: attributes,
|
14
|
+
customer_access_token: customer_access_token,
|
15
|
+
idempotency_key: idempotency_key,
|
16
|
+
meta: meta
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module Xs2a
|
3
|
+
class PeriodicPaymentInitiationRequest < Ibanity::BaseResource
|
4
|
+
def self.create_for_financial_institution(financial_institution_id:, customer_access_token:, idempotency_key: nil, **attributes)
|
5
|
+
path = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["periodicPaymentInitiationRequests"]
|
6
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
7
|
+
.sub("{paymentInitiationRequestId}", "")
|
8
|
+
uri = Ibanity.client.build_uri(path)
|
9
|
+
create_by_uri(
|
10
|
+
uri: uri,
|
11
|
+
resource_type: "periodicPaymentInitiationRequest",
|
12
|
+
attributes: attributes,
|
13
|
+
customer_access_token: customer_access_token,
|
14
|
+
idempotency_key: idempotency_key
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.find(id:, financial_institution_id:, customer_access_token:)
|
19
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["periodicPaymentInitiationRequests"]
|
20
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
21
|
+
.sub("{paymentInitiationRequestId}", id)
|
22
|
+
find_by_uri(uri: uri, customer_access_token: customer_access_token)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.delete(id:, financial_institution_id:, customer_access_token:)
|
26
|
+
uri = Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["periodicPaymentInitiationRequests"]
|
27
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
28
|
+
.sub("{paymentInitiationRequestId}", id)
|
29
|
+
destroy_by_uri(uri: uri, customer_access_token: customer_access_token)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/ibanity/client.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module Ibanity
|
2
2
|
class Client
|
3
3
|
|
4
|
-
attr_reader :base_uri, :signature_certificate, :signature_key, :
|
4
|
+
attr_reader :base_uri, :signature_certificate, :signature_key, :isabel_connect_client_id, :isabel_connect_client_secret, :ponto_connect_client_id, :ponto_connect_client_secret
|
5
5
|
|
6
|
-
def initialize(certificate:, key:, key_passphrase:, signature_certificate: nil, signature_certificate_id: nil, signature_key: nil, signature_key_passphrase: nil, api_scheme: "https", api_host: "api.ibanity.com", api_port: "443", ssl_ca_file: nil,
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
6
|
+
def initialize(certificate:, key:, key_passphrase:, signature_certificate: nil, signature_certificate_id: nil, signature_key: nil, signature_key_passphrase: nil, api_scheme: "https", api_host: "api.ibanity.com", api_port: "443", ssl_ca_file: nil, isabel_connect_client_id: "valid_client_id", isabel_connect_client_secret: "valid_client_secret", ponto_connect_client_id: nil, ponto_connect_client_secret: nil)
|
7
|
+
@isabel_connect_client_id = isabel_connect_client_id
|
8
|
+
@isabel_connect_client_secret = isabel_connect_client_secret
|
9
|
+
@ponto_connect_client_id = ponto_connect_client_id
|
10
|
+
@ponto_connect_client_secret = ponto_connect_client_secret
|
11
|
+
@certificate = OpenSSL::X509::Certificate.new(certificate)
|
12
|
+
@key = OpenSSL::PKey::RSA.new(key, key_passphrase)
|
11
13
|
if signature_certificate
|
12
14
|
@signature_certificate = OpenSSL::X509::Certificate.new(signature_certificate)
|
13
15
|
@signature_certificate_id = signature_certificate_id
|
@@ -68,8 +70,9 @@ module Ibanity
|
|
68
70
|
}
|
69
71
|
raw_response = RestClient::Request.execute(query) do |response, request, result, &block|
|
70
72
|
if response.code >= 400
|
73
|
+
ibanity_request_id = response.headers[:ibanity_request_id]
|
71
74
|
body = JSON.parse(response.body)
|
72
|
-
raise Ibanity::Error.new(body["errors"]), "Ibanity request failed."
|
75
|
+
raise Ibanity::Error.new(body["errors"] || body, ibanity_request_id), "Ibanity request failed."
|
73
76
|
else
|
74
77
|
response.return!(&block)
|
75
78
|
end
|
data/lib/ibanity/error.rb
CHANGED
@@ -2,14 +2,14 @@ module Ibanity
|
|
2
2
|
class Error < StandardError
|
3
3
|
attr_reader :errors
|
4
4
|
|
5
|
-
def initialize(errors)
|
5
|
+
def initialize(errors, ibanity_request_id)
|
6
6
|
@errors = errors
|
7
|
+
@ibanity_request_id = ibanity_request_id
|
7
8
|
end
|
8
9
|
|
9
10
|
def to_s
|
10
|
-
if @errors && @errors.size > 0
|
11
|
-
@errors.map do |error|
|
12
|
-
p error
|
11
|
+
if @errors.is_a?(Array) && @errors.size > 0
|
12
|
+
formatted_errors = @errors.map do |error|
|
13
13
|
if error["meta"] && error["meta"]["attribute"]
|
14
14
|
"* #{error["code"]}: '#{error["meta"]["attribute"]}' #{error["detail"]}"
|
15
15
|
elsif error["meta"] && error["meta"]["resource"]
|
@@ -17,7 +17,11 @@ module Ibanity
|
|
17
17
|
else
|
18
18
|
"* #{error["code"]}: #{error["detail"]}"
|
19
19
|
end
|
20
|
-
end
|
20
|
+
end
|
21
|
+
formatted_errors << "* ibanity_request_id: #{@ibanity_request_id}"
|
22
|
+
formatted_errors.join("\n")
|
23
|
+
elsif @errors.is_a?(Hash)
|
24
|
+
"* #{@errors["error"]}: #{@errors["error_description"]}\n * Error hint: #{@errors["error_hint"]}\n * ibanity_request_id: #{@ibanity_request_id}"
|
21
25
|
else
|
22
26
|
super
|
23
27
|
end
|
@@ -35,7 +35,7 @@ module Ibanity
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def request_target
|
38
|
-
@uri.query =
|
38
|
+
@uri.query = RestClient::Utils.encode_query_string(@query_params) if @query_params&.keys&.any?
|
39
39
|
"#{@method} #{@uri.request_uri}"
|
40
40
|
end
|
41
41
|
|
data/lib/ibanity/util.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
module Ibanity
|
2
2
|
module Util
|
3
|
-
def self.
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def self.underscorize(obj)
|
4
|
+
case obj
|
5
|
+
when Array
|
6
|
+
obj.map { |e| underscorize(e) }
|
7
|
+
when Hash
|
8
|
+
obj.keys.reduce({}) do |result, key|
|
9
|
+
result[underscore(key)] = underscorize(obj[key])
|
10
|
+
result
|
11
|
+
end
|
12
|
+
else
|
13
|
+
obj
|
7
14
|
end
|
8
15
|
end
|
9
16
|
|
data/lib/ibanity/version.rb
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'ibanity/util'
|
2
|
+
|
3
|
+
RSpec.describe Ibanity::Util do
|
4
|
+
describe ".underscorize" do
|
5
|
+
it "transforms all keys to snake_case" do
|
6
|
+
hash = {
|
7
|
+
"currency" => "EUR",
|
8
|
+
"amount" => 1,
|
9
|
+
"debtorName" => "Sophie Schowalter",
|
10
|
+
"debtorAccountReference" => "BE59823362319793",
|
11
|
+
}
|
12
|
+
|
13
|
+
expected = {
|
14
|
+
"currency" => "EUR",
|
15
|
+
"amount" => 1,
|
16
|
+
"debtor_name" => "Sophie Schowalter",
|
17
|
+
"debtor_account_reference" => "BE59823362319793",
|
18
|
+
}
|
19
|
+
|
20
|
+
expect(Ibanity::Util.underscorize(hash)).to eq(expected)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "processes hashes recursively" do
|
24
|
+
hash = {
|
25
|
+
"currency" => "EUR",
|
26
|
+
"amount" => 1,
|
27
|
+
"debtorName" => "Sophie Schowalter",
|
28
|
+
"details" => {
|
29
|
+
"debtorAccountReference" => "BE59823362319793"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
expected = {
|
34
|
+
"currency" => "EUR",
|
35
|
+
"amount" => 1,
|
36
|
+
"debtor_name" => "Sophie Schowalter",
|
37
|
+
"details" => {
|
38
|
+
"debtor_account_reference" => "BE59823362319793"
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
expect(Ibanity::Util.underscorize(hash)).to eq(expected)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "processes each array element" do
|
46
|
+
hash = {
|
47
|
+
"currency" => "EUR",
|
48
|
+
"amount" => 1,
|
49
|
+
"debtorName" => "Sophie Schowalter",
|
50
|
+
"details" => [
|
51
|
+
{"debtorAccountReference" => "BE59823362319793"}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
|
55
|
+
expected = {
|
56
|
+
"currency" => "EUR",
|
57
|
+
"amount" => 1,
|
58
|
+
"debtor_name" => "Sophie Schowalter",
|
59
|
+
"details" => [
|
60
|
+
{"debtor_account_reference" => "BE59823362319793"}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
|
64
|
+
expect(Ibanity::Util.underscorize(hash)).to eq(expected)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "leaves arrays elements untouched if they are not themselves hashes or arrays" do
|
68
|
+
hash = {
|
69
|
+
"currency" => "EUR",
|
70
|
+
"amount" => 1,
|
71
|
+
"debtorName" => "Sophie Schowalter",
|
72
|
+
"details" => [
|
73
|
+
"BE59823362319793"
|
74
|
+
]
|
75
|
+
}
|
76
|
+
|
77
|
+
expected = {
|
78
|
+
"currency" => "EUR",
|
79
|
+
"amount" => 1,
|
80
|
+
"debtor_name" => "Sophie Schowalter",
|
81
|
+
"details" => [
|
82
|
+
"BE59823362319793"
|
83
|
+
]
|
84
|
+
}
|
85
|
+
|
86
|
+
expect(Ibanity::Util.underscorize(hash)).to eq(expected)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
19
|
+
# assertions if you prefer.
|
20
|
+
config.expect_with :rspec do |expectations|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
23
|
+
# defined using `chain`, e.g.:
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
26
|
+
# ...rather than:
|
27
|
+
# # => "be bigger than 2"
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
33
|
+
config.mock_with :rspec do |mocks|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
+
# a real object. This is generally recommended, and will default to
|
36
|
+
# `true` in RSpec 4.
|
37
|
+
mocks.verify_partial_doubles = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
46
|
+
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
49
|
+
=begin
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
55
|
+
config.filter_run_when_matching :focus
|
56
|
+
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
59
|
+
# you configure your source control system to ignore this file.
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
65
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = "doc"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibanity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ibanity
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -30,28 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.
|
33
|
+
version: 3.9.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: webmock
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.24.2
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 1.24.2
|
40
|
+
version: 3.9.0
|
55
41
|
description: A Ruby wrapper for the Ibanity API.
|
56
42
|
email:
|
57
43
|
- info@ibanity.com
|
@@ -61,6 +47,9 @@ extra_rdoc_files: []
|
|
61
47
|
files:
|
62
48
|
- ".gitignore"
|
63
49
|
- ".gitkeep"
|
50
|
+
- ".rspec"
|
51
|
+
- ".travis.yml"
|
52
|
+
- CHANGELOG.md
|
64
53
|
- Gemfile
|
65
54
|
- LICENSE.txt
|
66
55
|
- README.md
|
@@ -68,23 +57,42 @@ files:
|
|
68
57
|
- ibanity.gemspec
|
69
58
|
- lib/ibanity.rb
|
70
59
|
- lib/ibanity/api/base_resource.rb
|
60
|
+
- lib/ibanity/api/consent/consent.rb
|
61
|
+
- lib/ibanity/api/consent/processing_operation.rb
|
71
62
|
- lib/ibanity/api/isabel_connect/access_token.rb
|
72
63
|
- lib/ibanity/api/isabel_connect/account.rb
|
73
64
|
- lib/ibanity/api/isabel_connect/account_report.rb
|
74
65
|
- lib/ibanity/api/isabel_connect/balance.rb
|
75
66
|
- lib/ibanity/api/isabel_connect/bulk_payment_initiation_request.rb
|
67
|
+
- lib/ibanity/api/isabel_connect/intraday_transaction.rb
|
76
68
|
- lib/ibanity/api/isabel_connect/refresh_token.rb
|
77
69
|
- lib/ibanity/api/isabel_connect/transaction.rb
|
78
70
|
- lib/ibanity/api/o_auth_resource.rb
|
71
|
+
- lib/ibanity/api/ponto_connect/account.rb
|
72
|
+
- lib/ibanity/api/ponto_connect/financial_institution.rb
|
73
|
+
- lib/ibanity/api/ponto_connect/payment.rb
|
74
|
+
- lib/ibanity/api/ponto_connect/sandbox/financial_institution_account.rb
|
75
|
+
- lib/ibanity/api/ponto_connect/sandbox/financial_institution_transaction.rb
|
76
|
+
- lib/ibanity/api/ponto_connect/synchronization.rb
|
77
|
+
- lib/ibanity/api/ponto_connect/token.rb
|
78
|
+
- lib/ibanity/api/ponto_connect/transaction.rb
|
79
|
+
- lib/ibanity/api/ponto_connect/usage.rb
|
80
|
+
- lib/ibanity/api/ponto_connect/user_info.rb
|
79
81
|
- lib/ibanity/api/sandbox/financial_institution_account.rb
|
82
|
+
- lib/ibanity/api/sandbox/financial_institution_holding.rb
|
80
83
|
- lib/ibanity/api/sandbox/financial_institution_transaction.rb
|
81
84
|
- lib/ibanity/api/sandbox/financial_institution_user.rb
|
82
85
|
- lib/ibanity/api/xs2a/account.rb
|
83
86
|
- lib/ibanity/api/xs2a/account_information_access_request.rb
|
87
|
+
- lib/ibanity/api/xs2a/account_information_access_request_authorization.rb
|
88
|
+
- lib/ibanity/api/xs2a/bulk_payment_initiation_request.rb
|
84
89
|
- lib/ibanity/api/xs2a/customer.rb
|
85
90
|
- lib/ibanity/api/xs2a/customer_access_token.rb
|
86
91
|
- lib/ibanity/api/xs2a/financial_institution.rb
|
92
|
+
- lib/ibanity/api/xs2a/holding.rb
|
87
93
|
- lib/ibanity/api/xs2a/payment_initiation_request.rb
|
94
|
+
- lib/ibanity/api/xs2a/payment_initiation_request_authorization.rb
|
95
|
+
- lib/ibanity/api/xs2a/periodic_payment_initiation_request.rb
|
88
96
|
- lib/ibanity/api/xs2a/synchronization.rb
|
89
97
|
- lib/ibanity/api/xs2a/transaction.rb
|
90
98
|
- lib/ibanity/client.rb
|
@@ -93,6 +101,8 @@ files:
|
|
93
101
|
- lib/ibanity/http_signature.rb
|
94
102
|
- lib/ibanity/util.rb
|
95
103
|
- lib/ibanity/version.rb
|
104
|
+
- spec/lib/ibanity/util_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
96
106
|
homepage: https://documentation.ibanity.com/api/ruby
|
97
107
|
licenses:
|
98
108
|
- MIT
|
@@ -112,9 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
122
|
- !ruby/object:Gem::Version
|
113
123
|
version: '0'
|
114
124
|
requirements: []
|
115
|
-
|
116
|
-
rubygems_version: 2.6.14
|
125
|
+
rubygems_version: 3.0.8
|
117
126
|
signing_key:
|
118
127
|
specification_version: 4
|
119
128
|
summary: Ibanity Ruby Client
|
120
|
-
test_files:
|
129
|
+
test_files:
|
130
|
+
- spec/lib/ibanity/util_spec.rb
|
131
|
+
- spec/spec_helper.rb
|