ibanity 1.7.0 → 1.8.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/CHANGELOG.md +11 -0
- data/lib/ibanity.rb +4 -2
- data/lib/ibanity/api/base_resource.rb +50 -22
- data/lib/ibanity/api/isabel_connect/bulk_payment_initiation_request.rb +4 -2
- data/lib/ibanity/api/ponto_connect/bulk_payment.rb +20 -0
- data/lib/ibanity/api/sandbox/financial_institution_transaction.rb +10 -0
- data/lib/ibanity/api/xs2a/transaction.rb +10 -5
- data/lib/ibanity/client.rb +75 -6
- data/lib/ibanity/http_signature.rb +28 -5
- data/lib/ibanity/version.rb +1 -1
- data/spec/lib/ibanity/base_resource_spec.rb +42 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/fixture.rb +8 -0
- data/spec/support/fixtures/json/relationships/data_with_type.json +21 -0
- data/spec/support/fixtures/json/relationships/data_without_type.json +20 -0
- data/spec/support/fixtures/json/relationships/meta_with_type.json +20 -0
- data/spec/support/fixtures/json/relationships/no_links_related.json +15 -0
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee5dc6fa3f4a5aa0cd9d8f94bddac6a5878f79b1f4b6a530509e8845887bda47
|
4
|
+
data.tar.gz: 6a6668fdbacdee52cbfa1d9c461378048c767e4b8f14e25690ad897425128d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f9cd020c0f3876846974717d27165d84b10f6b67476d192dd517277c36d15802786b566ab4f56c3e9cd964e1e228f5bc8c685bf2375a5f8482d2a800b8a5eaa
|
7
|
+
data.tar.gz: 721bf40a3596845d1858e8bf7376fca539280bf3f8bb733818b24ec74701f0b4966b10d436ae7a8469468d1b7e97dc04151a6de943540dd83d460c0794324cb8
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
# Changelog
|
2
|
+
|
3
|
+
## 1.8
|
4
|
+
|
5
|
+
* [XS2A] Update sandbox transactions
|
6
|
+
|
7
|
+
* [XS2A] Add support to list updated transaction using `synchronization_id`
|
8
|
+
|
9
|
+
* [Ponto Connect] Add support to BulkPayments
|
10
|
+
|
11
|
+
* [Isabel Connect] Add `hideDetails` and `isShared` parameters to `BulkPaymentInititationRequest.create`
|
12
|
+
|
2
13
|
## 1.7
|
3
14
|
### Enhancements
|
4
15
|
|
data/lib/ibanity.rb
CHANGED
@@ -46,6 +46,7 @@ require_relative "ibanity/api/ponto_connect/synchronization"
|
|
46
46
|
require_relative "ibanity/api/consent/consent"
|
47
47
|
require_relative "ibanity/api/consent/processing_operation"
|
48
48
|
require_relative "ibanity/api/ponto_connect/payment"
|
49
|
+
require_relative "ibanity/api/ponto_connect/bulk_payment"
|
49
50
|
require_relative "ibanity/api/ponto_connect/user_info"
|
50
51
|
require_relative "ibanity/api/ponto_connect/usage"
|
51
52
|
require_relative "ibanity/api/ponto_connect/integration"
|
@@ -57,7 +58,7 @@ module Ibanity
|
|
57
58
|
class << self
|
58
59
|
def client
|
59
60
|
options = configuration.to_h.delete_if { |_, v| v.nil? }
|
60
|
-
@client ||= Ibanity::Client.new(options)
|
61
|
+
@client ||= Ibanity::Client.new(**options)
|
61
62
|
end
|
62
63
|
|
63
64
|
def configure
|
@@ -87,7 +88,8 @@ module Ibanity
|
|
87
88
|
:api_scheme,
|
88
89
|
:api_host,
|
89
90
|
:api_port,
|
90
|
-
:ssl_ca_file
|
91
|
+
:ssl_ca_file,
|
92
|
+
:debug_http_requests
|
91
93
|
).new
|
92
94
|
end
|
93
95
|
|
@@ -86,6 +86,8 @@ module Ibanity
|
|
86
86
|
private
|
87
87
|
|
88
88
|
def prepare_attributes(raw)
|
89
|
+
raise "Unexpected raw type, expected hash, got #{raw}" unless raw.is_a?(Hash)
|
90
|
+
|
89
91
|
base = {
|
90
92
|
"id" => raw["id"],
|
91
93
|
}
|
@@ -97,23 +99,47 @@ module Ibanity
|
|
97
99
|
|
98
100
|
def setup_relationships(relationships, customer_access_token = nil)
|
99
101
|
relationships.each do |key, relationship|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
102
|
+
url = relationship.dig("links", "related")
|
103
|
+
id = relationship.dig("data", "id")
|
104
|
+
|
105
|
+
if url
|
106
|
+
setup_relationship(customer_access_token, key, relationship, url)
|
107
|
+
elsif id
|
108
|
+
self[Ibanity::Util.underscore("#{key}_id")] = id
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def setup_relationship(customer_access_token, key, relationship, url)
|
114
|
+
if relationship["data"]
|
115
|
+
resource = relationship.dig("data", "type") || key
|
116
|
+
klass = relationship_klass(resource)
|
117
|
+
method_name = Ibanity::Util.underscore(key)
|
118
|
+
define_singleton_method(method_name) do |headers: nil|
|
119
|
+
klass.find_by_uri(uri: url, headers: headers, customer_access_token: customer_access_token)
|
120
|
+
end
|
121
|
+
self[Ibanity::Util.underscore("#{key}_id")] = relationship.dig("data", "id")
|
122
|
+
elsif relationship["meta"]
|
123
|
+
resource = relationship.dig("meta", "type")
|
124
|
+
klass = relationship_klass(resource)
|
125
|
+
method_name = Ibanity::Util.underscore(key)
|
126
|
+
define_singleton_method(method_name) do |headers: nil|
|
127
|
+
klass.find_by_uri(uri: url, headers: headers, customer_access_token: customer_access_token)
|
128
|
+
end
|
129
|
+
elsif relationship.dig("links", "meta", "type")
|
130
|
+
resource = relationship.dig("links", "meta", "type")
|
131
|
+
klass = relationship_klass(resource)
|
132
|
+
method_name = Ibanity::Util.underscore(key)
|
133
|
+
define_singleton_method(method_name) do |headers: nil|
|
134
|
+
klass.list_by_uri(uri: url, headers: headers, customer_access_token: customer_access_token)
|
135
|
+
end
|
136
|
+
else
|
137
|
+
resource = key
|
138
|
+
singular_resource = resource[0..-2]
|
139
|
+
klass = relationship_klass(singular_resource)
|
140
|
+
method_name = Ibanity::Util.underscore(resource)
|
141
|
+
define_singleton_method(method_name) do |headers: nil, **query_params|
|
142
|
+
klass.list_by_uri(uri: url, headers: headers, query_params: query_params, customer_access_token: customer_access_token)
|
117
143
|
end
|
118
144
|
end
|
119
145
|
end
|
@@ -126,11 +152,13 @@ module Ibanity
|
|
126
152
|
|
127
153
|
def relationship_klass(name)
|
128
154
|
camelized_name = Ibanity::Util.camelize(name)
|
129
|
-
enclosing_module =
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
155
|
+
enclosing_module =
|
156
|
+
if camelized_name == "FinancialInstitution"
|
157
|
+
Ibanity::Xs2a
|
158
|
+
else
|
159
|
+
Object.const_get(self.class.to_s.split("::")[0...-1].join("::"))
|
160
|
+
end
|
161
|
+
|
134
162
|
enclosing_module.const_get(camelized_name)
|
135
163
|
end
|
136
164
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Ibanity
|
2
2
|
module IsabelConnect
|
3
3
|
class BulkPaymentInitiationRequest < Ibanity::BaseResource
|
4
|
-
def self.create(access_token:, raw_content:, filename:, idempotency_key: nil)
|
4
|
+
def self.create(access_token:, raw_content:, filename:, idempotency_key: nil, is_shared: true, hide_details: false)
|
5
5
|
uri = Ibanity.isabel_connect_api_schema["bulkPaymentInitiationRequests"].sub("{bulkPaymentInitiationRequestId}", "")
|
6
6
|
create_file_by_uri(
|
7
7
|
uri: uri,
|
@@ -11,7 +11,9 @@ module Ibanity
|
|
11
11
|
idempotency_key: idempotency_key,
|
12
12
|
headers: {
|
13
13
|
content_type: :xml,
|
14
|
-
"Content-Disposition": "inline; filename=#{filename}"
|
14
|
+
"Content-Disposition": "inline; filename=#{filename}",
|
15
|
+
"Is-Shared": is_shared,
|
16
|
+
"Hide-Details": hide_details
|
15
17
|
}
|
16
18
|
)
|
17
19
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Ibanity
|
2
|
+
module PontoConnect
|
3
|
+
class BulkPayment < Ibanity::BaseResource
|
4
|
+
def self.find(access_token:, account_id:, id:)
|
5
|
+
uri = Ibanity.ponto_connect_api_schema["account"]["bulkPayments"].sub("{accountId}", account_id).sub("{bulkPaymentId}", 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"]["bulkPayments"].gsub("{accountId}", account_id).gsub("{bulkPaymentId}", "")
|
11
|
+
create_by_uri(uri: uri, resource_type: "bulkPayment", 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"]["bulkPayments"].gsub("{accountId}", account_id).gsub("{bulkPaymentId}", id)
|
16
|
+
destroy_by_uri(uri: uri, customer_access_token: access_token)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -31,6 +31,16 @@ module Ibanity
|
|
31
31
|
find_by_uri(uri: uri)
|
32
32
|
end
|
33
33
|
|
34
|
+
def self.update(id:, financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:, idempotency_key: nil, **attributes)
|
35
|
+
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionTransactions"]
|
36
|
+
.gsub("{financialInstitutionId}", financial_institution_id)
|
37
|
+
.gsub("{financialInstitutionUserId}", financial_institution_user_id)
|
38
|
+
.gsub("{financialInstitutionAccountId}", financial_institution_account_id)
|
39
|
+
.gsub("{financialInstitutionTransactionId}", id)
|
40
|
+
uri = Ibanity.client.build_uri(path)
|
41
|
+
update_by_uri(uri: uri, resource_type: "financialInstitutionTransaction", attributes: attributes, idempotency_key: idempotency_key)
|
42
|
+
end
|
43
|
+
|
34
44
|
def self.delete(id:, financial_institution_user_id:, financial_institution_id:, financial_institution_account_id:)
|
35
45
|
path = Ibanity.sandbox_api_schema["financialInstitution"]["financialInstitutionAccount"]["financialInstitutionTransactions"]
|
36
46
|
.gsub("{financialInstitutionId}", financial_institution_id)
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module Ibanity
|
2
2
|
module Xs2a
|
3
3
|
class Transaction < Ibanity::BaseResource
|
4
|
-
def self.list(financial_institution_id
|
5
|
-
uri =
|
6
|
-
.
|
7
|
-
.sub("{
|
8
|
-
|
4
|
+
def self.list(financial_institution_id: nil, account_id: nil, synchronization_id: nil, customer_access_token:, headers: nil, **query_params)
|
5
|
+
uri = if synchronization_id
|
6
|
+
Ibanity.xs2a_api_schema["customer"]["synchronization"]["updatedTransactions"]
|
7
|
+
.sub("{synchronizationId}", synchronization_id)
|
8
|
+
else
|
9
|
+
Ibanity.xs2a_api_schema["customer"]["financialInstitution"]["transactions"]
|
10
|
+
.sub("{financialInstitutionId}", financial_institution_id)
|
11
|
+
.sub("{accountId}", account_id)
|
12
|
+
.sub("{transactionId}", "")
|
13
|
+
end
|
9
14
|
list_by_uri(uri: uri, query_params: query_params, customer_access_token: customer_access_token, headers: headers)
|
10
15
|
end
|
11
16
|
|
data/lib/ibanity/client.rb
CHANGED
@@ -3,13 +3,30 @@ module Ibanity
|
|
3
3
|
|
4
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(
|
6
|
+
def initialize(
|
7
|
+
certificate:,
|
8
|
+
key:,
|
9
|
+
key_passphrase:,
|
10
|
+
signature_certificate: nil,
|
11
|
+
signature_certificate_id: nil,
|
12
|
+
signature_key: nil,
|
13
|
+
signature_key_passphrase: nil,
|
14
|
+
api_scheme: "https",
|
15
|
+
api_host: "api.ibanity.com",
|
16
|
+
api_port: "443",
|
17
|
+
ssl_ca_file: nil,
|
18
|
+
isabel_connect_client_id: "valid_client_id",
|
19
|
+
isabel_connect_client_secret: "valid_client_secret",
|
20
|
+
ponto_connect_client_id: nil,
|
21
|
+
ponto_connect_client_secret: nil,
|
22
|
+
debug_http_requests: false)
|
7
23
|
@isabel_connect_client_id = isabel_connect_client_id
|
8
24
|
@isabel_connect_client_secret = isabel_connect_client_secret
|
9
25
|
@ponto_connect_client_id = ponto_connect_client_id
|
10
26
|
@ponto_connect_client_secret = ponto_connect_client_secret
|
11
27
|
@certificate = OpenSSL::X509::Certificate.new(certificate)
|
12
28
|
@key = OpenSSL::PKey::RSA.new(key, key_passphrase)
|
29
|
+
@http_debug = debug_http_requests
|
13
30
|
if signature_certificate
|
14
31
|
@signature_certificate = OpenSSL::X509::Certificate.new(signature_certificate)
|
15
32
|
@signature_certificate_id = signature_certificate_id
|
@@ -25,12 +42,12 @@ module Ibanity
|
|
25
42
|
end
|
26
43
|
|
27
44
|
def post(uri:, payload:, query_params: {}, customer_access_token: nil, idempotency_key: nil, json: true, headers: nil)
|
28
|
-
headers = build_headers(customer_access_token: customer_access_token, idempotency_key: idempotency_key, extra_headers: headers, json: json)
|
45
|
+
headers = build_headers(customer_access_token: customer_access_token, idempotency_key: idempotency_key, extra_headers: headers, json: json, payload: payload)
|
29
46
|
execute(method: :post, uri: uri, headers: headers, query_params: query_params, payload: payload, json: json)
|
30
47
|
end
|
31
48
|
|
32
49
|
def patch(uri:, payload:, query_params: {}, customer_access_token: nil, idempotency_key: nil, json: true)
|
33
|
-
headers = build_headers(customer_access_token: customer_access_token, idempotency_key: idempotency_key, json: json)
|
50
|
+
headers = build_headers(customer_access_token: customer_access_token, idempotency_key: idempotency_key, json: json, payload: payload)
|
34
51
|
execute(method: :patch, uri: uri, headers: headers, query_params: query_params, payload: payload, json: json)
|
35
52
|
end
|
36
53
|
|
@@ -46,6 +63,15 @@ module Ibanity
|
|
46
63
|
private
|
47
64
|
|
48
65
|
def execute(method:, uri:, headers:, query_params: {}, payload: nil, json:)
|
66
|
+
case payload
|
67
|
+
when NilClass
|
68
|
+
payload = ''
|
69
|
+
when Hash
|
70
|
+
payload = json ? payload.to_json : payload
|
71
|
+
when Pathname
|
72
|
+
payload = File.open(payload, 'rb')
|
73
|
+
end
|
74
|
+
|
49
75
|
if @signature_certificate
|
50
76
|
signature = Ibanity::HttpSignature.new(
|
51
77
|
certificate: @signature_certificate,
|
@@ -55,23 +81,30 @@ module Ibanity
|
|
55
81
|
uri: uri,
|
56
82
|
query_params: query_params,
|
57
83
|
headers: headers,
|
58
|
-
payload: payload
|
84
|
+
payload: payload
|
59
85
|
)
|
60
86
|
headers.merge!(signature.signature_headers)
|
61
87
|
end
|
88
|
+
|
62
89
|
query = {
|
63
90
|
method: method,
|
64
91
|
url: uri,
|
65
92
|
headers: headers.merge(params: query_params),
|
66
|
-
payload: payload
|
93
|
+
payload: payload,
|
67
94
|
ssl_client_cert: @certificate,
|
68
95
|
ssl_client_key: @key,
|
69
96
|
ssl_ca_file: @ssl_ca_file
|
70
97
|
}
|
98
|
+
|
99
|
+
log("HTTP Request", query) if @http_debug
|
100
|
+
|
71
101
|
raw_response = RestClient::Request.execute(query) do |response, request, result, &block|
|
102
|
+
log("HTTP response", { status: response.code, headers: response.headers, body: response.body }) if @http_debug
|
103
|
+
|
72
104
|
if response.code >= 400
|
73
105
|
ibanity_request_id = response.headers[:ibanity_request_id]
|
74
106
|
body = JSON.parse(response.body)
|
107
|
+
|
75
108
|
raise Ibanity::Error.new(body["errors"] || body, ibanity_request_id), "Ibanity request failed."
|
76
109
|
else
|
77
110
|
response.return!(&block)
|
@@ -80,12 +113,15 @@ module Ibanity
|
|
80
113
|
JSON.parse(raw_response)
|
81
114
|
rescue JSON::ParserError => e
|
82
115
|
return raw_response.body
|
116
|
+
ensure
|
117
|
+
payload.close if payload.is_a?(File)
|
83
118
|
end
|
84
119
|
|
85
|
-
def build_headers(customer_access_token: nil, idempotency_key: nil, extra_headers: nil, json:)
|
120
|
+
def build_headers(customer_access_token: nil, idempotency_key: nil, extra_headers: nil, json:, payload: nil)
|
86
121
|
headers = {
|
87
122
|
accept: :json,
|
88
123
|
}
|
124
|
+
headers["Transfer-Encoding"] = "chunked" if payload.is_a?(Pathname)
|
89
125
|
headers[:content_type] = :json if json
|
90
126
|
headers["Authorization"] = "Bearer #{customer_access_token}" unless customer_access_token.nil?
|
91
127
|
headers["Ibanity-Idempotency-Key"] = idempotency_key unless idempotency_key.nil?
|
@@ -95,5 +131,38 @@ module Ibanity
|
|
95
131
|
headers.merge(extra_headers)
|
96
132
|
end
|
97
133
|
end
|
134
|
+
|
135
|
+
def log(tag, info)
|
136
|
+
unless info.is_a?(Hash)
|
137
|
+
puts "[DEBUG] #{tag}: #{info}"
|
138
|
+
return
|
139
|
+
end
|
140
|
+
|
141
|
+
info = JSON.parse(info.to_json)
|
142
|
+
|
143
|
+
if info.dig("headers", "Authorization")
|
144
|
+
info["headers"]["Authorization"] = "[filtered]"
|
145
|
+
end
|
146
|
+
info.delete("proxy")
|
147
|
+
info.delete("ssl_client_cert")
|
148
|
+
info.delete("ssl_client_key")
|
149
|
+
if info.dig("payload").is_a?(Hash) && info.dig("payload", "client_secret")
|
150
|
+
info["payload"]["client_secret"] = "[filtered]"
|
151
|
+
end
|
152
|
+
|
153
|
+
if info["body"]&.is_a?(String)
|
154
|
+
begin
|
155
|
+
info["body"] = JSON.parse(info["body"])
|
156
|
+
rescue => exception
|
157
|
+
info["body"] = Base64.strict_encode64(info["body"])
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
begin
|
162
|
+
puts "[DEBUG] #{tag}: #{info.to_json}"
|
163
|
+
rescue => e
|
164
|
+
puts "[DEBUG] #{tag}: #{info}"
|
165
|
+
end
|
166
|
+
end
|
98
167
|
end
|
99
168
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "base64"
|
2
|
+
require "pathname"
|
2
3
|
|
3
4
|
module Ibanity
|
4
5
|
class HttpSignature
|
@@ -29,16 +30,38 @@ module Ibanity
|
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
32
|
-
private
|
33
|
-
|
34
33
|
def payload_digest
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
@payload_digest ||= compute_digest
|
35
|
+
end
|
36
|
+
|
37
|
+
def compute_digest
|
38
|
+
case @payload
|
39
|
+
when NilClass
|
40
|
+
digest = compute_digest_string("")
|
41
|
+
when String
|
42
|
+
digest = compute_digest_string(@payload)
|
43
|
+
when File
|
44
|
+
digest = compute_digest_file(@payload)
|
45
|
+
end
|
38
46
|
base64 = Base64.urlsafe_encode64(digest.digest)
|
39
47
|
"SHA-512=#{base64}"
|
40
48
|
end
|
41
49
|
|
50
|
+
def compute_digest_string(str)
|
51
|
+
digest = OpenSSL::Digest::SHA512.new
|
52
|
+
digest.update(str)
|
53
|
+
end
|
54
|
+
|
55
|
+
def compute_digest_file(pathname)
|
56
|
+
digest = OpenSSL::Digest::SHA512.new
|
57
|
+
File.open(pathname, 'rb') do |f|
|
58
|
+
while buffer = f.read(256_000)
|
59
|
+
digest << buffer
|
60
|
+
end
|
61
|
+
end
|
62
|
+
digest
|
63
|
+
end
|
64
|
+
|
42
65
|
def headers_to_sign
|
43
66
|
result = ["(request-target)", "host", "digest", "(created)"]
|
44
67
|
result << "authorization" unless @headers["Authorization"].nil?
|
data/lib/ibanity/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "ibanity"
|
2
|
+
|
3
|
+
class Ibanity::Xs2a::Car < Ibanity::BaseResource; end
|
4
|
+
class Ibanity::Xs2a::Manufacturer < Ibanity::BaseResource; end
|
5
|
+
|
6
|
+
RSpec.describe Ibanity::BaseResource do
|
7
|
+
describe "#relationship_klass" do
|
8
|
+
context "when 'data' attribute is present" do
|
9
|
+
it "retrieves the resource name from the 'type' attribute if it is present" do
|
10
|
+
car = Ibanity::Xs2a::Car.new(Fixture.load_json("relationships/data_with_type.json"))
|
11
|
+
|
12
|
+
expect(car).to respond_to(:maker)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "falls back to the element name otherwise" do
|
16
|
+
car = Ibanity::Xs2a::Car.new(Fixture.load_json("relationships/data_without_type.json"))
|
17
|
+
|
18
|
+
expect(car).to respond_to(:manufacturer)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when the 'links' attribute is present" do
|
23
|
+
it "retrieves the resource name from the 'type' attribute within the 'links' attribute" do
|
24
|
+
car = Ibanity::Xs2a::Car.new(Fixture.load_json("relationships/meta_with_type.json"))
|
25
|
+
|
26
|
+
expect(car).to respond_to(:manufacturer)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when there's no 'links/related' element" do
|
31
|
+
let(:car) { Ibanity::Xs2a::Car.new(Fixture.load_json("relationships/no_links_related.json")) }
|
32
|
+
|
33
|
+
it "sets up a '<relationship_key>_id' property when there is a 'data/id' element" do
|
34
|
+
expect(car.manufacturer_id).to eq("6680437c")
|
35
|
+
end
|
36
|
+
|
37
|
+
it "discards the relationship" do
|
38
|
+
expect(car).not_to respond_to(:manufacturer)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,10 +12,16 @@
|
|
12
12
|
# the additional setup, and require it from the spec files that actually need
|
13
13
|
# it.
|
14
14
|
#
|
15
|
+
|
16
|
+
Pathname.glob(Pathname.pwd().join("spec", "support", "**/*.rb")).each do |f|
|
17
|
+
require f
|
18
|
+
end
|
19
|
+
|
15
20
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
21
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
17
22
|
|
18
23
|
RSpec.configure do |config|
|
24
|
+
config.include(Fixture)
|
19
25
|
# rspec-expectations config goes here. You can use an alternate
|
20
26
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
21
27
|
# assertions if you prefer.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"attributes": {
|
3
|
+
"color": "blue"
|
4
|
+
},
|
5
|
+
"id": "62ebd4687e",
|
6
|
+
"links": {
|
7
|
+
"self": "https://www.cardb.com/models/62ebd4687e"
|
8
|
+
},
|
9
|
+
"relationships": {
|
10
|
+
"maker": {
|
11
|
+
"data": {
|
12
|
+
"id": "c4ebf0f7",
|
13
|
+
"type": "manufacturer"
|
14
|
+
},
|
15
|
+
"links": {
|
16
|
+
"related": "https://www.cardb.com/manufacturers/c4ebf0f7"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"type": "car"
|
21
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"attributes": {
|
3
|
+
"color": "blue"
|
4
|
+
},
|
5
|
+
"id": "62ebd4687e",
|
6
|
+
"links": {
|
7
|
+
"self": "https://www.cardb.com/models/62ebd4687e"
|
8
|
+
},
|
9
|
+
"relationships": {
|
10
|
+
"manufacturer": {
|
11
|
+
"data": {
|
12
|
+
"id": "c4ebf0f7"
|
13
|
+
},
|
14
|
+
"links": {
|
15
|
+
"related": "https://www.cardb.com/manufacturers/c4ebf0f7"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"type": "car"
|
20
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"attributes": {
|
3
|
+
"color": "blue"
|
4
|
+
},
|
5
|
+
"id": "62ebd4687e",
|
6
|
+
"links": {
|
7
|
+
"self": "https://www.cardb.com/models/62ebd4687e"
|
8
|
+
},
|
9
|
+
"relationships": {
|
10
|
+
"manufacturer": {
|
11
|
+
"links": {
|
12
|
+
"related": "https://www.cardb.com/manufacturers/c4ebf0f7"
|
13
|
+
},
|
14
|
+
"meta": {
|
15
|
+
"type": "manufacturer"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"type": "car"
|
20
|
+
}
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ibanity
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/ibanity/api/isabel_connect/transaction.rb
|
71
71
|
- lib/ibanity/api/o_auth_resource.rb
|
72
72
|
- lib/ibanity/api/ponto_connect/account.rb
|
73
|
+
- lib/ibanity/api/ponto_connect/bulk_payment.rb
|
73
74
|
- lib/ibanity/api/ponto_connect/financial_institution.rb
|
74
75
|
- lib/ibanity/api/ponto_connect/integration.rb
|
75
76
|
- lib/ibanity/api/ponto_connect/onboarding_details.rb
|
@@ -105,10 +106,16 @@ files:
|
|
105
106
|
- lib/ibanity/http_signature.rb
|
106
107
|
- lib/ibanity/util.rb
|
107
108
|
- lib/ibanity/version.rb
|
109
|
+
- spec/lib/ibanity/base_resource_spec.rb
|
108
110
|
- spec/lib/ibanity/http_signature_spec.rb
|
109
111
|
- spec/lib/ibanity/util_spec.rb
|
110
112
|
- spec/spec_helper.rb
|
111
113
|
- spec/support/crypto_helper.rb
|
114
|
+
- spec/support/fixture.rb
|
115
|
+
- spec/support/fixtures/json/relationships/data_with_type.json
|
116
|
+
- spec/support/fixtures/json/relationships/data_without_type.json
|
117
|
+
- spec/support/fixtures/json/relationships/meta_with_type.json
|
118
|
+
- spec/support/fixtures/json/relationships/no_links_related.json
|
112
119
|
- spec/support/fixtures/signature/test-certificate.pem
|
113
120
|
- spec/support/fixtures/signature/test-private_key.pem
|
114
121
|
- spec/support/fixtures/signature/test-public_key.pem
|
@@ -131,15 +138,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
138
|
- !ruby/object:Gem::Version
|
132
139
|
version: '0'
|
133
140
|
requirements: []
|
134
|
-
rubygems_version: 3.0.3
|
141
|
+
rubygems_version: 3.0.3.1
|
135
142
|
signing_key:
|
136
143
|
specification_version: 4
|
137
144
|
summary: Ibanity Ruby Client
|
138
145
|
test_files:
|
146
|
+
- spec/lib/ibanity/base_resource_spec.rb
|
139
147
|
- spec/lib/ibanity/http_signature_spec.rb
|
140
148
|
- spec/lib/ibanity/util_spec.rb
|
141
149
|
- spec/spec_helper.rb
|
142
150
|
- spec/support/crypto_helper.rb
|
151
|
+
- spec/support/fixture.rb
|
152
|
+
- spec/support/fixtures/json/relationships/data_with_type.json
|
153
|
+
- spec/support/fixtures/json/relationships/data_without_type.json
|
154
|
+
- spec/support/fixtures/json/relationships/meta_with_type.json
|
155
|
+
- spec/support/fixtures/json/relationships/no_links_related.json
|
143
156
|
- spec/support/fixtures/signature/test-certificate.pem
|
144
157
|
- spec/support/fixtures/signature/test-private_key.pem
|
145
158
|
- spec/support/fixtures/signature/test-public_key.pem
|