treezor_connect 0.22.0 → 0.24.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/lib/treezor_connect/api_operations/create.rb +3 -8
- data/lib/treezor_connect/api_operations/create_operation.rb +21 -0
- data/lib/treezor_connect/api_operations/nested_create.rb +13 -0
- data/lib/treezor_connect/api_operations/nested_delete.rb +14 -0
- data/lib/treezor_connect/client.rb +9 -8
- data/lib/treezor_connect/resources/mass_payout.rb +1 -0
- data/lib/treezor_connect/resources/user/relationship.rb +17 -0
- data/lib/treezor_connect/resources.rb +1 -0
- data/lib/treezor_connect.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 489fedbc4320d136c1a777a73f9130c831115532c87acba8f5a0ce761f98b67d
|
|
4
|
+
data.tar.gz: 1bd030071387828c890e3d4a5945aa3155dd93b3763b4fe3cb65914af8bda7c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 707ab8362d8b867e3b1b828505ac8adb5e6e6776a69c11d119a5ac27e6d9063c76b3657f8f03e9c9ecf21dba5cec6cfff4970b542b6198d6e649d02ee8f334ec
|
|
7
|
+
data.tar.gz: 6aa16b20660279a1ad58bca84b43f549d09b2cf1d0d870e37dcf344ac3acd43369233c1958a57e47be815db93c51979a7473d5efc3fcc6bd45b9c982436197f5
|
|
@@ -3,15 +3,10 @@
|
|
|
3
3
|
module TreezorConnect
|
|
4
4
|
module ApiOperations
|
|
5
5
|
module Create
|
|
6
|
+
include CreateOperation
|
|
7
|
+
|
|
6
8
|
def create(params = {}, access_token = nil)
|
|
7
|
-
|
|
8
|
-
data = extract_response_data(treezor_response, extract_all_objects: false)
|
|
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
|
|
9
|
+
perform_create(resource_url, params, access_token)
|
|
15
10
|
end
|
|
16
11
|
end
|
|
17
12
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TreezorConnect
|
|
4
|
+
module ApiOperations
|
|
5
|
+
module CreateOperation
|
|
6
|
+
def perform_create(url, params, access_token)
|
|
7
|
+
response = request(:post, url, params: { body: params }, access_token:)
|
|
8
|
+
build_object_from_response(response)
|
|
9
|
+
rescue AlreadyCreatedError => e
|
|
10
|
+
e.object = build_object_from_response(e.treezor_response)
|
|
11
|
+
e.treezor_response = nil
|
|
12
|
+
raise
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def build_object_from_response(response)
|
|
16
|
+
data = extract_response_data(response, extract_all_objects: false)
|
|
17
|
+
Util.convert_to_treezor_object(data, { object_class: self::OBJECT_NAME })
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TreezorConnect
|
|
4
|
+
module ApiOperations
|
|
5
|
+
module NestedCreate
|
|
6
|
+
include CreateOperation
|
|
7
|
+
|
|
8
|
+
def create(parent_id, params = {}, access_token = nil)
|
|
9
|
+
perform_create(resource_url(parent_id), params, access_token)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TreezorConnect
|
|
4
|
+
module ApiOperations
|
|
5
|
+
module NestedDelete
|
|
6
|
+
def delete(parent_id, id, access_token = nil)
|
|
7
|
+
url = [resource_url(parent_id), id].join('/')
|
|
8
|
+
treezor_response = request(:delete, url, access_token:)
|
|
9
|
+
data = extract_response_data(treezor_response, extract_all_objects: false)
|
|
10
|
+
Util.convert_to_treezor_object(data, { object_class: self::OBJECT_NAME })
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -5,7 +5,7 @@ module TreezorConnect
|
|
|
5
5
|
attr_reader :access_token
|
|
6
6
|
|
|
7
7
|
def initialize(access_token)
|
|
8
|
-
@access_token = access_token
|
|
8
|
+
@access_token = access_token || default_access_token
|
|
9
9
|
@conn = Faraday.new(
|
|
10
10
|
url: TreezorConnect.api_base_url,
|
|
11
11
|
headers: { 'Authorization' => "Bearer #{@access_token}" },
|
|
@@ -107,19 +107,20 @@ module TreezorConnect
|
|
|
107
107
|
|
|
108
108
|
decoded_token = JWT.decode(current_access_token, nil, false).first
|
|
109
109
|
decoded_token['exp'] < Time.now.to_i
|
|
110
|
+
rescue JWT::DecodeError
|
|
111
|
+
true
|
|
110
112
|
end
|
|
111
113
|
|
|
112
114
|
def default_access_token
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
end
|
|
115
|
+
return current_access_token unless current_access_token_expired?
|
|
116
|
+
|
|
117
|
+
token = fetch_access_token
|
|
118
|
+
Thread.current[:treezor_default_access_token] = token if ENV['SKIP_ACCESS_TOKEN_IN_THREAD'].nil?
|
|
119
|
+
token
|
|
119
120
|
end
|
|
120
121
|
|
|
121
122
|
def current_access_token
|
|
122
|
-
|
|
123
|
+
Thread.current[:treezor_default_access_token]
|
|
123
124
|
end
|
|
124
125
|
end
|
|
125
126
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TreezorConnect
|
|
4
|
+
class User
|
|
5
|
+
class Relationship < ApiResource
|
|
6
|
+
extend TreezorConnect::ApiOperations::NestedCreate
|
|
7
|
+
extend TreezorConnect::ApiOperations::NestedDelete
|
|
8
|
+
|
|
9
|
+
OBJECT_NAME = 'user/relationship'
|
|
10
|
+
OBJECT_PRIMARY_KEY = 'relationshipId'
|
|
11
|
+
|
|
12
|
+
def self.resource_url(user_id)
|
|
13
|
+
"/v1/users/#{user_id}/relationships"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -10,6 +10,7 @@ require 'treezor_connect/resources/payin'
|
|
|
10
10
|
require 'treezor_connect/resources/payout'
|
|
11
11
|
require 'treezor_connect/resources/tax_residence'
|
|
12
12
|
require 'treezor_connect/resources/user'
|
|
13
|
+
require 'treezor_connect/resources/user/relationship'
|
|
13
14
|
require 'treezor_connect/resources/oauth/token'
|
|
14
15
|
require 'treezor_connect/resources/sca/external_operation'
|
|
15
16
|
require 'treezor_connect/resources/sca/passcode'
|
data/lib/treezor_connect.rb
CHANGED
|
@@ -19,11 +19,14 @@ require 'treezor_connect/errors'
|
|
|
19
19
|
# API operations
|
|
20
20
|
require 'treezor_connect/api_operations/fetch'
|
|
21
21
|
require 'treezor_connect/api_operations/list'
|
|
22
|
+
require 'treezor_connect/api_operations/create_operation'
|
|
22
23
|
require 'treezor_connect/api_operations/create'
|
|
24
|
+
require 'treezor_connect/api_operations/nested_create'
|
|
23
25
|
require 'treezor_connect/api_operations/bulk_create'
|
|
24
26
|
require 'treezor_connect/api_operations/request'
|
|
25
27
|
require 'treezor_connect/api_operations/update'
|
|
26
28
|
require 'treezor_connect/api_operations/delete'
|
|
29
|
+
require 'treezor_connect/api_operations/nested_delete'
|
|
27
30
|
|
|
28
31
|
# API resources
|
|
29
32
|
require 'treezor_connect/api_resource'
|
metadata
CHANGED
|
@@ -1,14 +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.24.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- stefakins
|
|
8
8
|
- jbauzone
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A gem for making HTTP calls to Treezor Connect.
|
|
14
14
|
email: stefan.atkinson69@gmail.com
|
|
@@ -19,9 +19,12 @@ files:
|
|
|
19
19
|
- lib/treezor_connect.rb
|
|
20
20
|
- lib/treezor_connect/api_operations/bulk_create.rb
|
|
21
21
|
- lib/treezor_connect/api_operations/create.rb
|
|
22
|
+
- lib/treezor_connect/api_operations/create_operation.rb
|
|
22
23
|
- lib/treezor_connect/api_operations/delete.rb
|
|
23
24
|
- lib/treezor_connect/api_operations/fetch.rb
|
|
24
25
|
- lib/treezor_connect/api_operations/list.rb
|
|
26
|
+
- lib/treezor_connect/api_operations/nested_create.rb
|
|
27
|
+
- lib/treezor_connect/api_operations/nested_delete.rb
|
|
25
28
|
- lib/treezor_connect/api_operations/request.rb
|
|
26
29
|
- lib/treezor_connect/api_operations/update.rb
|
|
27
30
|
- lib/treezor_connect/api_resource.rb
|
|
@@ -44,6 +47,7 @@ files:
|
|
|
44
47
|
- lib/treezor_connect/resources/sct_inst/recall.rb
|
|
45
48
|
- lib/treezor_connect/resources/tax_residence.rb
|
|
46
49
|
- lib/treezor_connect/resources/user.rb
|
|
50
|
+
- lib/treezor_connect/resources/user/relationship.rb
|
|
47
51
|
- lib/treezor_connect/treezor_object.rb
|
|
48
52
|
- lib/treezor_connect/treezor_response.rb
|
|
49
53
|
- lib/treezor_connect/util.rb
|