sydecar 0.1.6

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f7ca50a53331e4ebe73abe784b0282097ad56ab1cf9d087bda31919e6670790
4
+ data.tar.gz: edeabcf4a7687a5bb3b46d030ff54ee8e880e3a40baed30b141124125a4446a8
5
+ SHA512:
6
+ metadata.gz: 3ebacf1d4a5f69410fae37d013077ef4097d36805fee933266a2070e7e83733bed0922b61b8fd45c2b30fee02b48e94ac6690cb94e131ba4a9f28e1d5eb672a3
7
+ data.tar.gz: 93faa23340da67d1c6af908a166e0a2fc3786231bae43e08747b19365da8518741eb853f44d07f2ff34e13f52f536e3a6be258b4d19b3bc63c712622fd283904
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ sydecar
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-05-16
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in sydecar.gemspec
6
+ gemspec
7
+ gem "rake", "~> 13.0"
8
+
9
+ group :development do
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sydecar (0.1.6)
5
+ faraday (~> 2.7)
6
+ faraday-multipart (~> 1.0)
7
+ json (~> 2.6)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.8.4)
13
+ public_suffix (>= 2.0.2, < 6.0)
14
+ awesome_print (1.9.2)
15
+ byebug (11.1.3)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.5.0)
19
+ faraday (2.7.4)
20
+ faraday-net_http (>= 2.0, < 3.1)
21
+ ruby2_keywords (>= 0.0.4)
22
+ faraday-multipart (1.0.4)
23
+ multipart-post (~> 2)
24
+ faraday-net_http (3.0.2)
25
+ hashdiff (1.0.1)
26
+ json (2.6.3)
27
+ multipart-post (2.3.0)
28
+ public_suffix (5.0.1)
29
+ rake (13.0.6)
30
+ rexml (3.2.5)
31
+ rspec (3.12.0)
32
+ rspec-core (~> 3.12.0)
33
+ rspec-expectations (~> 3.12.0)
34
+ rspec-mocks (~> 3.12.0)
35
+ rspec-core (3.12.2)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-expectations (3.12.3)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.12.0)
40
+ rspec-mocks (3.12.5)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.12.0)
43
+ rspec-support (3.12.0)
44
+ ruby2_keywords (0.0.5)
45
+ webmock (3.18.1)
46
+ addressable (>= 2.8.0)
47
+ crack (>= 0.3.2)
48
+ hashdiff (>= 0.4.0, < 2.0.0)
49
+
50
+ PLATFORMS
51
+ x86_64-darwin-20
52
+ x86_64-linux
53
+
54
+ DEPENDENCIES
55
+ awesome_print (~> 1.9)
56
+ byebug (~> 11.1)
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ sydecar!
60
+ webmock (~> 3.18)
61
+
62
+ BUNDLED WITH
63
+ 2.4.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 1lyan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # Sydecar
2
+
3
+ This is a ruby gem for Sydecar API https://api-docs.sydecar.io/
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add sydecar
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install sydecar
14
+
15
+ ### Supported endpoints:
16
+ 1. Person: create, find, update, find_all, kyc
17
+ 2. Entity: create, find, update, find_all
18
+ 3. Profile: find, activate_spv, deactivate_spv, find_all, accreditation_qualification_opts
19
+ 4. Bank Account: create, find, update, find_all, delete
20
+ 5. Vendor: create, find, update, find_all
21
+ 6. Expense: create, find, update, find_all, delete, pay, cancel
22
+ 7. SPV: create, find, update, find_all, initiate_close, disburse_close, counter_sign_close, request_approval, request_bank_account, disbursements, adjust_disbursements, adjust_fund_deal_investments
23
+ 8. Subscription: create, funding_countries_list, find, update, delete, create_agreement_preview, create_virtual_bank_account, set_balance, sign, amend, send_ach_with_plaid, refund_ach_with_plaid, refund, find_all
24
+ 9. Document: find, delete, preview, sign, required_fields, sign_arbitrary, find_all, download, upload
25
+
26
+ ### Example usage:
27
+ 1. Create a Person:
28
+ ```
29
+ body = {...} # put your data here
30
+ person = Sydecar::Person.create(body: body, idempotency_key: 'unique')
31
+ ```
32
+ 2. Create an Entity:
33
+ ```
34
+ entity_body = {...} # put your data here
35
+ entity = Sydecar::Entity.create(body: entity_body)
36
+ ```
37
+ 3. Create an Entity Profile:
38
+ ```
39
+ entity_profile_body = {...} # put your data here
40
+ entity_profile_body['person_id'] = person.body['id']
41
+ profile = Sydecar::Profile::Entity.create(body: entity_profile_body)
42
+ ```
43
+ 4. Create Bank Account:
44
+ ```
45
+ bank_account_body['profile_ids'] = [profile.body['id']]
46
+ bank = Sydecar::BankAccount.create(body: bank_account_body, idempotency_key: 'unique')
47
+ ```
48
+ 5. Create SPV:
49
+ ```
50
+ spv_body = {...}
51
+ spv_body['spv_lead_profile_id'] = profile.body['id']
52
+ spv = Sydecar::Spv.create(body: spv_body, idempotency_key: 'unique')
53
+ ```
54
+ 6. Create a Vendor:
55
+ ```
56
+ vendor_body = {...}
57
+ vendor = Sydecar::Vendor(body: vendor_body)
58
+ ```
59
+ 7. Create Expense:
60
+ ```
61
+ expense_body = {...}
62
+ expense_body['spv_id'] = spv.body['id']
63
+ expense_body['vendor_id'] = vendor.body['id']
64
+ expense = Sydecar::Expense.create(body: expense_body)
65
+ ```
66
+ 8. Create a Subscription:
67
+ ```
68
+ sub_body = {...}
69
+ sub_body['spv_id'] = spv.body['id']
70
+ sub_body['subscriptions'][0]['profile_id'] = profile.body['id']
71
+ subscription = Sydecar::Subscription.create(body: sub_body, idempotency_key: 'unique')
72
+ ```
73
+ 9. Upload a Document:
74
+ ```
75
+ doc_boby = {
76
+ type: 'DRAFT_INVESTMENT',
77
+ name: 'file_name', # Faraday expects here just name without extension
78
+ profile_id: profile.body['id'], # it's possible to set only 1 id from the following list
79
+ spv_id: spv.body['id'],
80
+ subscription_id: subscription.body['id'],
81
+ expense_id: expense.body['id']
82
+ }
83
+
84
+ doc = Sydecar::Document.upload(body: doc_body, idempotency_key: 'unique')
85
+ ```
86
+
87
+ ## Development
88
+
89
+ After checking out the repo, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
90
+
91
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
92
+
93
+ ## Contributing
94
+
95
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Play-Money/sydecar.
96
+
97
+ ## License
98
+
99
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class BankAccount
5
+ URL = '/v1/bank_accounts'
6
+ CREATE_URL = "#{URL}/create"
7
+ class << self
8
+ # @param [Hash] body
9
+ def create(body:, idempotency_key:)
10
+ Connection.instance.post(CREATE_URL, body, { 'idempotency-key': idempotency_key })
11
+ end
12
+
13
+ # @param [UUID] id
14
+ def find(id:)
15
+ Connection.instance.get("#{URL}/#{id}", { reveal_pii: true, include: 'spvs' })
16
+ end
17
+
18
+ # @param [UUID] id
19
+ # @param [Hash] body
20
+ def update(id:, body:)
21
+ Connection.instance.patch("#{URL}/#{id}", body)
22
+ end
23
+
24
+ # @param [Hash] params argument expects to have the following keys
25
+ # [String] sort: asc / desc
26
+ # [Integer] limit
27
+ # [Integer] offset
28
+ # [String] start_date (format: yyyy-mm-dd)
29
+ # [String] end_date (format: yyyy-mm-dd)
30
+ # @param [Hash] body: expects to have "ids" key
31
+ def find_all(params: {}, body: {})
32
+ query = '?'
33
+ query += URI.encode_www_form(params)
34
+ Connection.instance.post("#{URL}#{query}", body)
35
+ end
36
+
37
+ # @param [UUID] id
38
+ def delete(id:)
39
+ Connection.instance.delete("#{URL}/#{id}")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module Sydecar
2
+ class BaseConnection
3
+ class << self
4
+ attr_accessor :token, :base_url, :env
5
+
6
+ def common_headers
7
+ {
8
+ 'Authorization' => "Bearer #{token}",
9
+ 'User-Agent' => 'Faraday',
10
+ 'Connection' => 'keep-alive',
11
+ 'Accept' => 'application/json',
12
+ }
13
+ end
14
+
15
+ def instance
16
+ unless token
17
+ raise TokenNotSetError
18
+ end
19
+
20
+ unless base_url
21
+ raise BaseUrlNotSetError
22
+ end
23
+ end
24
+
25
+ protected
26
+
27
+ def create_instance(headers, base_url, env, format_of_request: :json)
28
+ Faraday.new(url: base_url, headers: headers) do |f|
29
+ f.request format_of_request
30
+ f.response :json
31
+ f.response :logger if %w[development].include?(env)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,223 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class CapitalCall
5
+
6
+ CAPITAL_CALL_EVENTS_URL = 'v1/capital_call_events'
7
+ class << self
8
+ # Fetch all capital call events for an SPV
9
+ # @param
10
+ # Query parameters [Hash]
11
+ # - 'sort' [String] (Enum: 'asc', 'desc')
12
+ # - 'limit' [Number] (<=100)
13
+ # - 'offset' [Number]
14
+ # - 'start_date' [String]
15
+ # - 'end_date' [String]
16
+ # - 'include' [String] (Value: 'capital_calls')
17
+ # REQUEST BODY SCHEMA: application/json
18
+ # - 'ids' [Array of string]
19
+ # @example
20
+ # RESPONSE DATA (Sample):
21
+ # {
22
+ # "data": [
23
+ # {
24
+ # "id": "string",
25
+ # "created_at": "2019-08-24T14:15:22Z",
26
+ # "updated_at": "2019-08-24T14:15:22Z",
27
+ # "spv_id": "string",
28
+ # "memo": "string",
29
+ # "percentage": 0,
30
+ # "capital_calls": [
31
+ # {
32
+ # "id": "string",
33
+ # "created_at": "2019-08-24T14:15:22Z",
34
+ # "updated_at": "2019-08-24T14:15:22Z",
35
+ # "amount": 0,
36
+ # "amount_funded": 0,
37
+ # "due_date": "2019-08-24T14:15:22Z",
38
+ # "stage": "CREATED",
39
+ # "subscription_id": "string",
40
+ # "capital_call_event_id": "string"
41
+ # }
42
+ # ]
43
+ # }
44
+ # ],
45
+ # "pagination": {
46
+ # "limit": 0,
47
+ # "offset": 0,
48
+ # "total": 0
49
+ # }
50
+ # }
51
+ # @return See example RESPONSES: > '200'
52
+ #
53
+ # See on the https://api-docs.sydecar.io/api/#tag/Capital-Call-Management/operation/getAllCapitalCallEvents
54
+ def fetch_capital_calls_for_spv(params: {}, body: {})
55
+ query = '?'
56
+ query += URI.encode_www_form(params)
57
+ Connection.instance.post("#{CAPITAL_CALL_EVENTS_URL}#{query}", body)
58
+ end
59
+ # This method create an SPV capital call event
60
+ # @param
61
+ # HEADER PARAMETERS:
62
+ # - idempotency-key [String]
63
+ # REQUEST BODY SCHEMA: application/json
64
+ # - {
65
+ # "capital_call_events": [ (required)
66
+ # {
67
+ # "percentage": 100, (required 0..100)
68
+ # "memo": "string"
69
+ # }
70
+ # ],
71
+ # "spv_id": "string" (required)
72
+ # }
73
+ # - Create one or more capital call events. A valid SPV id is needed.
74
+ # @example
75
+ # RESPONSE SAMPLE
76
+ # {
77
+ # "data": [
78
+ # {
79
+ # "id": "string",
80
+ # "created_at": "2019-08-24T14:15:22Z",
81
+ # "updated_at": "2019-08-24T14:15:22Z",
82
+ # "spv_id": "string",
83
+ # "memo": "string",
84
+ # "percentage": 0,
85
+ # "capital_calls": [
86
+ # {
87
+ # "id": "string",
88
+ # "created_at": "2019-08-24T14:15:22Z",
89
+ # "updated_at": "2019-08-24T14:15:22Z",
90
+ # "amount": 0,
91
+ # "amount_funded": 0,
92
+ # "due_date": "2019-08-24T14:15:22Z",
93
+ # "stage": "CREATED",
94
+ # "subscription_id": "string",
95
+ # "capital_call_event_id": "string"
96
+ # }
97
+ # ]
98
+ # }
99
+ # ]
100
+ # }
101
+ # More detail see on the
102
+ # https://api-docs.sydecar.io/api/#tag/Capital-Call-Management/operation/createOneOrMoreCapitalCallEvents
103
+ # @return [Hash] Responses: > '201'
104
+ def create_spv_capital_call(body:, idempotency_key:)
105
+ Connection.instance.post("#{CAPITAL_CALL_EVENTS_URL}/create", body, { 'idempotency-key': idempotency_key })
106
+ end
107
+ # Fetch an SPV capital call event by id
108
+ # @param
109
+ # PATH PARAMETERS
110
+ # - 'capital_call_event_id' [String] (required)
111
+ # QUERY PARAMETERS
112
+ # - 'include' [String] (Value: "capital_calls")
113
+ # @EXAMPLE
114
+ # Response samples:
115
+ # {
116
+ # "id": "string",
117
+ # "created_at": "2019-08-24T14:15:22Z",
118
+ # "updated_at": "2019-08-24T14:15:22Z",
119
+ # "spv_id": "string",
120
+ # "memo": "string",
121
+ # "percentage": 0,
122
+ # "capital_calls": [
123
+ # {
124
+ # "id": "string",
125
+ # "created_at": "2019-08-24T14:15:22Z",
126
+ # "updated_at": "2019-08-24T14:15:22Z",
127
+ # "amount": 0,
128
+ # "amount_funded": 0,
129
+ # "due_date": "2019-08-24T14:15:22Z",
130
+ # "stage": "CREATED",
131
+ # "subscription_id": "string",
132
+ # "capital_call_event_id": "string"
133
+ # }
134
+ # ]
135
+ # }
136
+ # @return [Hash] see example
137
+ # Response: > '200'
138
+ def fetch_spv_capital_call(capital_call_event_id:, query: {})
139
+ query = "?#{URI.encode_www_form(query)}"
140
+ Connection.instance.get("#{CAPITAL_CALL_EVENTS_URL}/#{capital_call_event_id}#{query}")
141
+ end
142
+ # Update an SPV capital call event
143
+ # @param
144
+ # PATH PARAMETERS
145
+ # - 'capital_call_event_id' [String] (required)
146
+ # REQUEST BODY SCHEMA: application/json
147
+ # - 'percentage' [Number] [ 0 .. 100 ]
148
+ # - 'memo' [String]
149
+ #
150
+ # Update an SPV capital call event. You can only update a capital call event before subscription captial calls
151
+ # have been made (e.g. if the capital call event has been created and the spv has no subscriptions created yet).
152
+ #
153
+ # @EXAMPLE
154
+ # Response samples:
155
+ # {
156
+ # "id": "string",
157
+ # "created_at": "2019-08-24T14:15:22Z",
158
+ # "updated_at": "2019-08-24T14:15:22Z",
159
+ # "spv_id": "string",
160
+ # "memo": "string",
161
+ # "percentage": 0
162
+ # }
163
+ # More detail see on the
164
+ # https://api-docs.sydecar.io/api/#tag/Capital-Call-Management/operation/updateCapitalCallEvent
165
+ # @return [Hash] see example
166
+ # Response: > '200'
167
+ def update_spv_capital_call(capital_call_event_id:, body: {})
168
+ Connection.instance.patch("#{CAPITAL_CALL_EVENTS_URL}/#{capital_call_event_id}", body)
169
+ end
170
+ # Delete an SPV capital call event by id
171
+ # @param
172
+ # PATH PARAMETERS
173
+ # - 'capital_call_event_id' [String] (required)
174
+ #
175
+ # Delete an SPV capital call event. You can only delete a capital call event before subscription captial calls
176
+ # have been made (e.g. if the capital call event has been created but no subscriptions have been created for the spv so far).
177
+ #
178
+ # @EXAMPLE
179
+ # Response samples:
180
+ # {
181
+ # "id": "string",
182
+ # "created_at": "2019-08-24T14:15:22Z",
183
+ # "updated_at": "2019-08-24T14:15:22Z",
184
+ # "spv_id": "string",
185
+ # "memo": "string",
186
+ # "percentage": 0
187
+ # }
188
+ # More detail see on the
189
+ # https://api-docs.sydecar.io/api/#tag/Capital-Call-Management/operation/removeCapitalCallEvent
190
+ # @return [Hash] see example
191
+ # Response: > '200'
192
+ def delete_spv_capital_call(capital_call_event_id:)
193
+ Connection.instance.delete("#{CAPITAL_CALL_EVENTS_URL}/#{capital_call_event_id}")
194
+ end
195
+ # Get the capital call needed for a disbursement
196
+ # @param
197
+ # QUERY PARAMETERS
198
+ # - 'use_spv_allocation' [boolean] (optional)
199
+ # REQUEST BODY SCHEMA: application/json
200
+ # - 'spv_id' [String] (required)
201
+ # - 'disbursement' [Number >=0 ] (required)
202
+ #
203
+ # Returns the capital call percentage needed for sufficient funds for a given disbursement. Uses reserved
204
+ # subscription amounts, unless 'use_spv_allocation' is passed as 'true'.
205
+ #
206
+ # @EXAMPLE
207
+ # Response samples:
208
+ # {
209
+ # "data": {
210
+ # "capital_call_percentage": 0
211
+ # }
212
+ # }
213
+ # More detail see on the
214
+ # https://api-docs.sydecar.io/api/#tag/Capital-Call-Management/operation/getCapitalCallNeededForDisbursement
215
+ # @return [Hash] see example
216
+ # Response: > '200'
217
+ def get_capital_call_for_disbursement(body:, query: {})
218
+ query = "?#{URI.encode_www_form(query)}"
219
+ Connection.instance.post("#{CAPITAL_CALL_EVENTS_URL}/capital_call_needed_for_disbursement#{query}", body)
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,23 @@
1
+ module Sydecar
2
+ class Connection < BaseConnection
3
+ class << self
4
+ def headers
5
+ common_headers.merge('Content-Type' => 'application/json')
6
+ end
7
+
8
+ def instance
9
+ super
10
+ return @@instance if @@instance
11
+
12
+ @@instance = create_instance(headers, base_url, env, format_of_request: :json)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ @@instance = nil
19
+
20
+ def initialize
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ module Sydecar
3
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class Document
5
+ URL = '/v1/documents'
6
+ UPLOAD_URL = "#{URL}/upload"
7
+ SIGN_ARBITRARY_URL = '/v1/documents/click-sign?streamable_file=true'
8
+ class << self
9
+ # @param [UUID] id
10
+ def find(id:)
11
+ Connection.instance.get("#{URL}/#{id}")
12
+ end
13
+ # @param [UUID] id
14
+ def delete(id:)
15
+ Connection.instance.delete("#{URL}/#{id}")
16
+ end
17
+
18
+ # @param [UUID] id
19
+ def preview_url(id:)
20
+ "/v1/documents/#{id}/preview?streamable_file=false"
21
+ end
22
+
23
+ # @param [UUID] id
24
+ # @param [Hash] body
25
+ def preview(id:, body:)
26
+ url = preview_url(id: id)
27
+ Connection.instance.post(url, body)
28
+ end
29
+
30
+ # @param [UUID] id
31
+ def sign_url(id:)
32
+ "/v1/documents/#{id}/click-sign?streamable_file=false"
33
+ end
34
+
35
+ # @param [UUID] id
36
+ # @param [Hash] body
37
+ def sign(id:, body:)
38
+ url = sign_url(id: id)
39
+ Connection.instance.post(url, body)
40
+ end
41
+
42
+ # @param [UUID] id
43
+ def required_fields_url(id:)
44
+ "/v1/documents/#{id}/fields"
45
+ end
46
+
47
+ # @param [UUID] id
48
+ def required_fields(id:)
49
+ url = required_fields_url(id: id)
50
+ Connection.instance.get(url)
51
+ end
52
+
53
+ def sign_arbitrary(body:, idempotency_key:)
54
+ Connection.instance.post(SIGN_ARBITRARY_URL, body, { 'idempotency-key': idempotency_key })
55
+ end
56
+
57
+ # @param [Hash] params argument expects to have the following keys:
58
+ # [String] sort: asc / desc
59
+ # [Integer] limit
60
+ # [Integer] offset
61
+ # [String] start_date (format: yyyy-mm-dd)
62
+ # [String] end_date (format: yyyy-mm-dd)
63
+ # @param [Hash] body: expects to have "ids" key
64
+ def find_all(params: {}, body: {})
65
+ query = '?'
66
+ query += URI.encode_www_form(params)
67
+ Connection.instance.post("#{URL}#{query}", body)
68
+ end
69
+
70
+ def download_url(id:)
71
+ "/v1/documents/#{id}/get_download_url"
72
+ end
73
+
74
+ def download(id:)
75
+ url = download_url(id: id)
76
+ Connection.instance.get(url)
77
+ end
78
+
79
+ def upload(body:, idempotency_key:)
80
+ FileConnection.instance.post(UPLOAD_URL, body, { 'idempotency-key': idempotency_key })
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sydecar
4
+ class Entity
5
+ URL = '/v1/entities'
6
+ CREATE_URL = "#{URL}/create"
7
+ class << self
8
+ # @param [Hash] body
9
+ def create(body:)
10
+ Connection.instance.post(CREATE_URL, body)
11
+ end
12
+
13
+ # @param [UUID] id
14
+ def find(id:)
15
+ Connection.instance.get("#{URL}/#{id}", { reveal_pii: true })
16
+ end
17
+
18
+ # @param [UUID] id
19
+ # @param [Hash] body
20
+ def update(id:, body:)
21
+ Connection.instance.patch("#{URL}/#{id}", body)
22
+ end
23
+
24
+ # @param [Hash] params argument expects to have the following keys
25
+ # [String] sort: asc / desc
26
+ # [Integer] limit
27
+ # [Integer] offset
28
+ # [String] start_date (format: yyyy-mm-dd)
29
+ # [String] end_date (format: yyyy-mm-dd)
30
+ # @param [Hash] body: expects to have "ids" key
31
+ def find_all(params: {}, body: {})
32
+ query = '?'
33
+ query += URI.encode_www_form(params)
34
+ Connection.instance.post("#{URL}#{query}", body)
35
+ end
36
+ end
37
+ end
38
+ end