treezor_connect 0.19.0 → 0.20.1
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 62c84708d568bb28d1d8eadb59c88b312695a1029673830116a0d3c6f989a3f1
|
|
4
|
+
data.tar.gz: 4106207f1adfdee42732981002305e69c05e875e331acab5fae4ce5a204234e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 449e8781d12c198168945f3fb78e9e20aafe3920f47ec6d51769b442c56e7dfcd98ce04581f54d43e77c9ac541cbd5bef6913efe4a75d2943ce011989284b3c0
|
|
7
|
+
data.tar.gz: f30b9b8025ac6494ab73b5f40bf4d7bc6079cbe42499c885f90358ae009ece8ebe8bdd95ca3e2b1d8aaac6caec3766d4f212902a4cacd438054e9874d89af6af
|
|
@@ -7,6 +7,11 @@ module TreezorConnect
|
|
|
7
7
|
treezor_response = request(:post, resource_url, params: { body: params }, access_token:)
|
|
8
8
|
data = extract_response_data(treezor_response, extract_all_objects: false)
|
|
9
9
|
Util.convert_to_treezor_object(data, { object_class: self::OBJECT_NAME })
|
|
10
|
+
rescue AlreadyCreatedError => e
|
|
11
|
+
data = extract_response_data(e.treezor_response, extract_all_objects: false)
|
|
12
|
+
e.treezor_response = nil
|
|
13
|
+
e.object = Util.convert_to_treezor_object(data, { object_class: self::OBJECT_NAME })
|
|
14
|
+
raise
|
|
10
15
|
end
|
|
11
16
|
end
|
|
12
17
|
end
|
|
@@ -13,10 +13,8 @@ module TreezorConnect
|
|
|
13
13
|
headers['Authorization'] = "Bearer #{access_token}"
|
|
14
14
|
response = conn.public_send(method, path, params: params[:query], form: params[:form], json: params[:body],
|
|
15
15
|
headers:)
|
|
16
|
-
http_status = response.status
|
|
17
|
-
raise_api_error(http_status:, http_body: JSON.parse(response.to_s)) unless http_status.success?
|
|
18
16
|
|
|
19
|
-
response
|
|
17
|
+
process_response(response)
|
|
20
18
|
end
|
|
21
19
|
|
|
22
20
|
private
|
|
@@ -42,6 +40,17 @@ module TreezorConnect
|
|
|
42
40
|
oauth_client.client_credentials.get_token.token
|
|
43
41
|
end
|
|
44
42
|
|
|
43
|
+
def process_response(response)
|
|
44
|
+
http_status = response.status
|
|
45
|
+
if http_status.success?
|
|
46
|
+
response
|
|
47
|
+
elsif http_status == 303
|
|
48
|
+
raise AlreadyCreatedError, response
|
|
49
|
+
else
|
|
50
|
+
raise_api_error(http_status:, http_body: JSON.parse(response.to_s))
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
45
54
|
def raise_api_error(http_status:, http_body:)
|
|
46
55
|
raise ApiError.new(
|
|
47
56
|
"API request failed: #{http_body.inspect} (HTTP response code was #{http_status})",
|
|
@@ -10,3 +10,14 @@ class ApiError < StandardError
|
|
|
10
10
|
super(message)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
module TreezorConnect
|
|
15
|
+
class AlreadyCreatedError < ApiError
|
|
16
|
+
attr_accessor :treezor_response, :object
|
|
17
|
+
|
|
18
|
+
def initialize(response)
|
|
19
|
+
@treezor_response = ::TreezorConnect::TreezorResponse.from_http_response(response)
|
|
20
|
+
super('Treezor resource has already been created', {}, 303)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TreezorConnect
|
|
4
|
+
class Document < ApiResource
|
|
5
|
+
extend TreezorConnect::ApiOperations::List
|
|
6
|
+
extend TreezorConnect::ApiOperations::Fetch
|
|
7
|
+
extend TreezorConnect::ApiOperations::Create
|
|
8
|
+
extend TreezorConnect::ApiOperations::Update
|
|
9
|
+
extend TreezorConnect::ApiOperations::Delete
|
|
10
|
+
|
|
11
|
+
OBJECT_NAME = 'document'
|
|
12
|
+
OBJECT_KEY = 'documents'
|
|
13
|
+
OBJECT_PRIMARY_KEY = 'documentId'
|
|
14
|
+
|
|
15
|
+
def self.resource_url
|
|
16
|
+
'/v1/documents'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -4,6 +4,7 @@ require 'treezor_connect/resources/beneficiary'
|
|
|
4
4
|
require 'treezor_connect/resources/beneficiary_validation'
|
|
5
5
|
require 'treezor_connect/resources/card'
|
|
6
6
|
require 'treezor_connect/resources/card_image'
|
|
7
|
+
require 'treezor_connect/resources/document'
|
|
7
8
|
require 'treezor_connect/resources/mass_payout'
|
|
8
9
|
require 'treezor_connect/resources/payin'
|
|
9
10
|
require 'treezor_connect/resources/payout'
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: treezor_connect
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.20.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- stefakins
|
|
8
8
|
- jbauzone
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-11 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
13
|
description: A gem for making HTTP calls to Treezor Connect.
|
|
15
14
|
email: stefan.atkinson69@gmail.com
|
|
@@ -32,6 +31,7 @@ files:
|
|
|
32
31
|
- lib/treezor_connect/resources/beneficiary_validation.rb
|
|
33
32
|
- lib/treezor_connect/resources/card.rb
|
|
34
33
|
- lib/treezor_connect/resources/card_image.rb
|
|
34
|
+
- lib/treezor_connect/resources/document.rb
|
|
35
35
|
- lib/treezor_connect/resources/mass_payout.rb
|
|
36
36
|
- lib/treezor_connect/resources/oauth/token.rb
|
|
37
37
|
- lib/treezor_connect/resources/payin.rb
|
|
@@ -51,7 +51,6 @@ licenses:
|
|
|
51
51
|
- MIT
|
|
52
52
|
metadata:
|
|
53
53
|
rubygems_mfa_required: 'true'
|
|
54
|
-
post_install_message:
|
|
55
54
|
rdoc_options: []
|
|
56
55
|
require_paths:
|
|
57
56
|
- lib
|
|
@@ -66,8 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
66
65
|
- !ruby/object:Gem::Version
|
|
67
66
|
version: '0'
|
|
68
67
|
requirements: []
|
|
69
|
-
rubygems_version: 3.
|
|
70
|
-
signing_key:
|
|
68
|
+
rubygems_version: 3.6.5
|
|
71
69
|
specification_version: 4
|
|
72
70
|
summary: A gem for making HTTP calls to Treezor Connect.
|
|
73
71
|
test_files: []
|