assinafy 2.3.0 → 2.4.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 +4 -4
- data/CHANGELOG.md +57 -6
- data/README.en.md +164 -1138
- data/README.md +29 -24
- data/docs/API_REFERENCE.md +113 -137
- data/docs/GUIDE.md +1079 -0
- data/lib/assinafy/client.rb +79 -45
- data/lib/assinafy/configuration.rb +8 -7
- data/lib/assinafy/oauth.rb +12 -15
- data/lib/assinafy/resources/account_resource.rb +13 -10
- data/lib/assinafy/resources/assignment_resource.rb +63 -92
- data/lib/assinafy/resources/base_resource.rb +66 -114
- data/lib/assinafy/resources/contract_resource.rb +17 -33
- data/lib/assinafy/resources/document_resource.rb +73 -61
- data/lib/assinafy/resources/envelope_resource.rb +10 -12
- data/lib/assinafy/resources/field_resource.rb +3 -11
- data/lib/assinafy/resources/oauth_resource.rb +26 -20
- data/lib/assinafy/resources/scheduled_send_resource.rb +10 -5
- data/lib/assinafy/resources/signer_document_resource.rb +24 -14
- data/lib/assinafy/resources/signer_resource.rb +46 -72
- data/lib/assinafy/resources/tag_resource.rb +16 -22
- data/lib/assinafy/resources/template_resource.rb +5 -6
- data/lib/assinafy/resources/user_resource.rb +7 -2
- data/lib/assinafy/resources/webhook_resource.rb +55 -47
- data/lib/assinafy/support/webhook_verifier.rb +2 -2
- data/lib/assinafy/utils.rb +14 -21
- data/lib/assinafy/validation.rb +80 -0
- data/lib/assinafy/version.rb +1 -1
- data/lib/assinafy.rb +1 -1
- data/sig/assinafy.rbs +7 -30
- metadata +6 -6
- data/lib/assinafy/resources/auth_resource.rb +0 -502
|
@@ -11,7 +11,7 @@ module Assinafy
|
|
|
11
11
|
# - {#list} and {#search} authenticate as the signer: they require the access
|
|
12
12
|
# code and never send workspace credentials. The same routes also accept
|
|
13
13
|
# workspace credentials; use {#list_as_workspace} / {#search_as_workspace} for that.
|
|
14
|
-
# - {#download} only
|
|
14
|
+
# - {#download} requires the signer access code and serves only the original.
|
|
15
15
|
#
|
|
16
16
|
# See https://api.assinafy.com.br/v1/docs#signer for the full
|
|
17
17
|
# documentation of these endpoints.
|
|
@@ -46,12 +46,21 @@ module Assinafy
|
|
|
46
46
|
# # "declined_by" => nil,
|
|
47
47
|
# # "created_at" => "2023-07-21T13:43:17Z",
|
|
48
48
|
# # "updated_at" => "2023-07-21T13:43:17Z",
|
|
49
|
+
# # "is_signer_access_closed" => false,
|
|
50
|
+
# # "certified_copy" => { "available" => false, "notification_method" => "Email",
|
|
51
|
+
# # "resends_left" => nil },
|
|
49
52
|
# # "current_signer" => { "id" => "signer-id", "full_name" => "Signer Name",
|
|
50
|
-
# # "email" => "signer@example.com",
|
|
53
|
+
# # "email" => "signer@example.com", "completed" => false,
|
|
51
54
|
# # "verification_method" => "Email", "notification_methods" => ["Email"] },
|
|
52
55
|
# # "assignment" => { "id" => "1", "method" => "virtual", "items" => [{ ... }] }
|
|
53
56
|
# # # ... (see docs for full shape)
|
|
54
57
|
# # }
|
|
58
|
+
# # Once the signer's access has closed, only the status remains:
|
|
59
|
+
# # => { "id" => "document-id", "name" => "my_document.pdf", "status" => "certificated",
|
|
60
|
+
# # "is_signer_access_closed" => true,
|
|
61
|
+
# # "certified_copy" => { "available" => true, "notification_method" => "Email",
|
|
62
|
+
# # "resends_left" => nil },
|
|
63
|
+
# # "current_signer" => { "completed" => true } }
|
|
55
64
|
def current(signer_id, signer_access_code:, expand: nil)
|
|
56
65
|
sid = require_id(signer_id, 'Signer ID')
|
|
57
66
|
access_code = require_signer_access_code(signer_access_code)
|
|
@@ -69,7 +78,8 @@ module Assinafy
|
|
|
69
78
|
# authenticated with the signer access code only (no workspace credentials).
|
|
70
79
|
#
|
|
71
80
|
# @param signer_id [String]
|
|
72
|
-
# @param params [Hash] documented `page` and `
|
|
81
|
+
# @param params [Hash] documented `page`, `per_page` and `envelope_id` (only the members
|
|
82
|
+
# of this envelope) query parameters
|
|
73
83
|
# @param signer_access_code [String] required; may also be given as `params[:signer_access_code]`
|
|
74
84
|
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: { current_page:, per_page:, total:, last_page: } }`
|
|
75
85
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
@@ -113,7 +123,8 @@ module Assinafy
|
|
|
113
123
|
# instead of the signer access code. Same response as {#list}.
|
|
114
124
|
#
|
|
115
125
|
# @param signer_id [String]
|
|
116
|
-
# @param params [Hash] documented `page` and `
|
|
126
|
+
# @param params [Hash] documented `page`, `per_page` and `envelope_id` (only the members of this
|
|
127
|
+
# envelope) query parameters
|
|
117
128
|
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: { current_page:, per_page:, total:, last_page: } }`
|
|
118
129
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
119
130
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
@@ -137,7 +148,8 @@ module Assinafy
|
|
|
137
148
|
#
|
|
138
149
|
# @param signer_id [String]
|
|
139
150
|
# @param query [String, nil] optional free-text search term; nil omits `search`
|
|
140
|
-
# @param params [Hash] optional
|
|
151
|
+
# @param params [Hash] optional query parameters, such as `envelope_id` (only the members
|
|
152
|
+
# of this envelope)
|
|
141
153
|
# @param signer_access_code [String] required; may also be given as `params[:signer_access_code]`
|
|
142
154
|
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: {..} | nil }`
|
|
143
155
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
@@ -165,7 +177,7 @@ module Assinafy
|
|
|
165
177
|
|
|
166
178
|
call_list('Failed to search signer documents') do
|
|
167
179
|
http_get("signers/#{sid}/documents/search",
|
|
168
|
-
filters.merge(search: query, signer_access_code: access_code),
|
|
180
|
+
filters.merge({ search: query, signer_access_code: access_code }.compact),
|
|
169
181
|
workspace_auth: false)
|
|
170
182
|
end
|
|
171
183
|
end
|
|
@@ -175,7 +187,8 @@ module Assinafy
|
|
|
175
187
|
#
|
|
176
188
|
# @param signer_id [String]
|
|
177
189
|
# @param query [String, nil] optional free-text search term; nil omits `search`
|
|
178
|
-
# @param params [Hash] optional
|
|
190
|
+
# @param params [Hash] optional query parameters, such as `envelope_id` (only the members of this
|
|
191
|
+
# envelope)
|
|
179
192
|
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: {..} | nil }`
|
|
180
193
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
181
194
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
@@ -190,7 +203,7 @@ module Assinafy
|
|
|
190
203
|
require_string(query, 'Search query') unless query.nil?
|
|
191
204
|
|
|
192
205
|
call_list('Failed to search signer documents') do
|
|
193
|
-
http_get("signers/#{sid}/documents/search", workspace_query(params).merge(search: query))
|
|
206
|
+
http_get("signers/#{sid}/documents/search", workspace_query(params).merge({ search: query }.compact))
|
|
194
207
|
end
|
|
195
208
|
end
|
|
196
209
|
|
|
@@ -259,7 +272,7 @@ module Assinafy
|
|
|
259
272
|
#
|
|
260
273
|
# @param signer_id [String]
|
|
261
274
|
# @param document_id [String]
|
|
262
|
-
# @param artifact_name [String] original
|
|
275
|
+
# @param artifact_name [String] only `original` is served to a signer
|
|
263
276
|
# @param signer_access_code [String] required; no workspace credentials are transmitted
|
|
264
277
|
# @return [String] binary PDF bytes
|
|
265
278
|
# @raise [Assinafy::ValidationError] on invalid IDs, artifact or access code
|
|
@@ -270,13 +283,10 @@ module Assinafy
|
|
|
270
283
|
# client.signer_documents.download('signer-id', 'document-id', signer_access_code: 'access-code')
|
|
271
284
|
# # GET /signers/signer-id/documents/document-id/download/original?signer-access-code=access-code
|
|
272
285
|
# # => "%PDF-1.7..." # binary String
|
|
273
|
-
def download(signer_id, document_id, artifact_name = 'original', signer_access_code:
|
|
286
|
+
def download(signer_id, document_id, artifact_name = 'original', signer_access_code:)
|
|
274
287
|
sid = require_id(signer_id, 'Signer ID')
|
|
275
288
|
did = require_id(document_id, 'Document ID')
|
|
276
|
-
art =
|
|
277
|
-
unless DocumentResource::ARTIFACT_TYPES.include?(art)
|
|
278
|
-
raise ValidationError.new('Invalid artifact type', { artifact_name: artifact_name })
|
|
279
|
-
end
|
|
289
|
+
art = require_one_of(artifact_name, %w[original], 'artifact')
|
|
280
290
|
|
|
281
291
|
code = require_signer_access_code(signer_access_code)
|
|
282
292
|
|
|
@@ -12,6 +12,8 @@ module Assinafy
|
|
|
12
12
|
class SignerResource < BaseResource
|
|
13
13
|
EMAIL_REGEX = Utils::EMAIL_PATTERN
|
|
14
14
|
SIGNATURE_TYPES = %w[signature initial].freeze
|
|
15
|
+
SIGNATURE_CONTENT_TYPES = %w[image/png image/jpeg].freeze
|
|
16
|
+
private_constant :SIGNATURE_CONTENT_TYPES
|
|
15
17
|
|
|
16
18
|
# Validate and normalize a payload accepted by {#create} without sending
|
|
17
19
|
# a request. Useful for preflighting multi-step workflows before they
|
|
@@ -63,6 +65,7 @@ module Assinafy
|
|
|
63
65
|
# # "full_name" => "Example Signer",
|
|
64
66
|
# # "email" => "signer@example.com",
|
|
65
67
|
# # "whatsapp_phone_number" => nil,
|
|
68
|
+
# # "government_id" => nil,
|
|
66
69
|
# # "has_accepted_terms" => false
|
|
67
70
|
# # }
|
|
68
71
|
def create(payload, account_id_override = nil)
|
|
@@ -94,6 +97,7 @@ module Assinafy
|
|
|
94
97
|
# # "full_name" => "Example Signer",
|
|
95
98
|
# # "email" => "signer@example.com",
|
|
96
99
|
# # "whatsapp_phone_number" => nil,
|
|
100
|
+
# # "government_id" => nil,
|
|
97
101
|
# # "has_accepted_terms" => false
|
|
98
102
|
# # }
|
|
99
103
|
def get(signer_id, account_id_override = nil)
|
|
@@ -124,6 +128,7 @@ module Assinafy
|
|
|
124
128
|
# # "full_name" => "Example Signer",
|
|
125
129
|
# # "email" => "signer@example.com",
|
|
126
130
|
# # "whatsapp_phone_number" => nil,
|
|
131
|
+
# # "government_id" => nil,
|
|
127
132
|
# # "has_accepted_terms" => false
|
|
128
133
|
# # }
|
|
129
134
|
# # # ... (one Hash per signer)
|
|
@@ -149,7 +154,8 @@ module Assinafy
|
|
|
149
154
|
# @option payload [String] :full_name
|
|
150
155
|
# @option payload [String, nil] :email
|
|
151
156
|
# @option payload [String, nil] :whatsapp_phone_number E.164; normalized on save
|
|
152
|
-
# @option payload [String, nil] :phone alias for `:whatsapp_phone_number
|
|
157
|
+
# @option payload [String, nil] :phone alias for `:whatsapp_phone_number`; the canonical key wins when both
|
|
158
|
+
# are given, even when it is nil
|
|
153
159
|
# @option payload [String, nil] :government_id CPF (digits) or CNPJ (may be alphanumeric); normalized on save
|
|
154
160
|
# @param account_id_override [String, nil]
|
|
155
161
|
# @return [Hash] updated signer object (envelope `data` unwrapped)
|
|
@@ -170,6 +176,7 @@ module Assinafy
|
|
|
170
176
|
# # "full_name" => "Updated Signer",
|
|
171
177
|
# # "email" => "signer@example.com",
|
|
172
178
|
# # "whatsapp_phone_number" => nil,
|
|
179
|
+
# # "government_id" => "00000000000",
|
|
173
180
|
# # "has_accepted_terms" => false
|
|
174
181
|
# # }
|
|
175
182
|
def update(signer_id, payload, account_id_override = nil)
|
|
@@ -222,12 +229,13 @@ module Assinafy
|
|
|
222
229
|
# # "full_name" => "Example Signer",
|
|
223
230
|
# # "email" => "signer@example.com",
|
|
224
231
|
# # "whatsapp_phone_number" => nil,
|
|
232
|
+
# # "government_id" => nil,
|
|
225
233
|
# # "has_accepted_terms" => false
|
|
226
234
|
# # }
|
|
227
235
|
# #
|
|
228
236
|
# # => nil # when no returned signer matches
|
|
229
237
|
def find_by_email(email, account_id_override = nil)
|
|
230
|
-
|
|
238
|
+
Utils.require_email(email)
|
|
231
239
|
target = email.downcase
|
|
232
240
|
page = 1
|
|
233
241
|
|
|
@@ -261,7 +269,9 @@ module Assinafy
|
|
|
261
269
|
# # "full_name" => "Signer Name",
|
|
262
270
|
# # "email" => "signer@example.com",
|
|
263
271
|
# # "whatsapp_phone_number" => "+15555550100",
|
|
272
|
+
# # "government_id" => nil,
|
|
264
273
|
# # "has_accepted_terms" => false,
|
|
274
|
+
# # "verification_method" => "Email",
|
|
265
275
|
# # "has_signature" => false, # self-only field
|
|
266
276
|
# # "has_initial" => false, # self-only field
|
|
267
277
|
# # "is_signature_reusable" => false # self-only field
|
|
@@ -391,13 +401,13 @@ module Assinafy
|
|
|
391
401
|
end
|
|
392
402
|
|
|
393
403
|
# Confirm the contact used by the assignment and optionally accept terms. Certificate signers
|
|
394
|
-
# must do both before opening GET /sign.
|
|
395
|
-
#
|
|
404
|
+
# must do both before opening GET /sign. The API reads only email, whatsapp_phone_number and
|
|
405
|
+
# has_accepted_terms, so those are the only keys sent.
|
|
396
406
|
#
|
|
397
407
|
# @param document_id [String]
|
|
398
|
-
# @param payload [Hash] email, whatsapp_phone_number and has_accepted_terms
|
|
408
|
+
# @param payload [Hash] email, whatsapp_phone_number (or its phone alias) and has_accepted_terms
|
|
399
409
|
# @param signer_access_code [String]
|
|
400
|
-
# @return [Array] empty Array on success
|
|
410
|
+
# @return [Array, nil] empty Array on success; nil when the response carries no data
|
|
401
411
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
402
412
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
403
413
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
@@ -410,11 +420,11 @@ module Assinafy
|
|
|
410
420
|
# # => []
|
|
411
421
|
def confirm_data(document_id, payload, signer_access_code:)
|
|
412
422
|
doc_id = require_id(document_id, 'Document ID')
|
|
413
|
-
|
|
423
|
+
raw = require_payload(payload).transform_keys(&:to_s)
|
|
414
424
|
code = require_signer_access_code(signer_access_code)
|
|
415
|
-
|
|
425
|
+
raw['whatsapp_phone_number'] = raw['phone'] unless raw.key?('whatsapp_phone_number')
|
|
426
|
+
body = body_params(raw.slice('email', 'whatsapp_phone_number', 'has_accepted_terms'))
|
|
416
427
|
Utils.require_email(body['email']) if body.key?('email')
|
|
417
|
-
require_string(body['government_id'], 'Government ID') if body.key?('government_id')
|
|
418
428
|
require_string(body['whatsapp_phone_number'], 'WhatsApp number') if body.key?('whatsapp_phone_number')
|
|
419
429
|
require_boolean(body['has_accepted_terms'], 'has_accepted_terms') if body.key?('has_accepted_terms')
|
|
420
430
|
|
|
@@ -424,12 +434,12 @@ module Assinafy
|
|
|
424
434
|
end
|
|
425
435
|
end
|
|
426
436
|
|
|
427
|
-
# Upload the signer's signature image. The request body is raw image bytes.
|
|
437
|
+
# Upload the signer's signature image, PNG or JPEG. The request body is raw image bytes.
|
|
428
438
|
#
|
|
429
439
|
# @param content [String] raw image bytes
|
|
430
440
|
# @param signer_access_code [String]
|
|
431
441
|
# @param type [String] `signature` or `initial`
|
|
432
|
-
# @param content_type [String]
|
|
442
|
+
# @param content_type [String] `image/png` or `image/jpeg`
|
|
433
443
|
# @param reuse [Boolean, nil] when true, marks the signature as
|
|
434
444
|
# reusable for future documents (documented `reuse` query flag)
|
|
435
445
|
# @return [Array, nil] empty Array; nil for older no-data responses
|
|
@@ -455,24 +465,14 @@ module Assinafy
|
|
|
455
465
|
raise ValidationError.new('Signature content must be a non-empty String')
|
|
456
466
|
end
|
|
457
467
|
|
|
458
|
-
|
|
459
|
-
raise ValidationError.new('Signature content type must be image/png')
|
|
460
|
-
end
|
|
461
|
-
|
|
468
|
+
require_one_of(content_type, SIGNATURE_CONTENT_TYPES, 'Signature content type')
|
|
462
469
|
require_boolean(reuse, 'reuse') unless reuse.nil?
|
|
463
470
|
sig_type = signature_type(type)
|
|
464
471
|
code = require_signer_access_code(signer_access_code)
|
|
465
472
|
|
|
466
473
|
call('Failed to upload signer signature') do
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
request,
|
|
470
|
-
{ signer_access_code: code, type: sig_type, reuse: reuse },
|
|
471
|
-
workspace_auth: false
|
|
472
|
-
)
|
|
473
|
-
request.headers['Content-Type'] = content_type
|
|
474
|
-
request.body = content
|
|
475
|
-
end
|
|
474
|
+
http_post('signature', content, { signer_access_code: code, type: sig_type, reuse: reuse },
|
|
475
|
+
workspace_auth: false, headers: { 'Content-Type' => content_type })
|
|
476
476
|
end
|
|
477
477
|
end
|
|
478
478
|
|
|
@@ -546,67 +546,41 @@ module Assinafy
|
|
|
546
546
|
|
|
547
547
|
private
|
|
548
548
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
end
|
|
549
|
+
SIGNER_KEY_ALIASES = { 'full_name' => 'name', 'whatsapp_phone_number' => 'phone' }.freeze
|
|
550
|
+
private_constant :SIGNER_KEY_ALIASES
|
|
552
551
|
|
|
552
|
+
# An alias is read only when its canonical key is absent (on create, also
|
|
553
|
+
# when it is nil), so an update's explicit nil clears the field instead
|
|
554
|
+
# of being replaced by the alias.
|
|
553
555
|
def signer_payload(payload, require_full_name:)
|
|
554
|
-
|
|
555
|
-
p = raw.transform_keys(&:to_s)
|
|
556
|
-
|
|
557
|
-
full_name = signer_full_name(p, require_full_name)
|
|
558
|
-
|
|
559
|
-
email = p['email']
|
|
560
|
-
assert_email!(email) unless email.nil? || (!require_full_name && email == '')
|
|
561
|
-
|
|
562
|
-
phone = signer_phone(p)
|
|
556
|
+
p = signer_fields(require_payload(payload, 'Signer payload').transform_keys(&:to_s), require_full_name)
|
|
563
557
|
|
|
564
|
-
|
|
565
|
-
full_name
|
|
566
|
-
email: email,
|
|
567
|
-
whatsapp_phone_number: phone
|
|
568
|
-
)
|
|
569
|
-
government_id = signer_government_id(p)
|
|
570
|
-
body['government_id'] = government_id unless government_id.nil?
|
|
571
|
-
require_full_name ? body : signer_update_payload(p, body)
|
|
572
|
-
end
|
|
573
|
-
|
|
574
|
-
def signer_update_payload(p, body)
|
|
575
|
-
p['whatsapp_phone_number'] = p['phone'] if !p.key?('whatsapp_phone_number') && p.key?('phone')
|
|
576
|
-
%w[email whatsapp_phone_number government_id].each do |key|
|
|
577
|
-
body[key] = nil if p.key?(key) && p[key].nil?
|
|
558
|
+
if (require_full_name || p.key?('full_name')) && !non_blank_string?(p['full_name'])
|
|
559
|
+
raise ValidationError.new('full_name must be a non-empty String')
|
|
578
560
|
end
|
|
579
|
-
require_string(body['full_name'], 'Full name') if p.key?('full_name') || p.key?('name')
|
|
580
|
-
body
|
|
581
|
-
end
|
|
582
561
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
562
|
+
Utils.require_email(p['email']) unless p['email'].nil? || (!require_full_name && p['email'] == '')
|
|
563
|
+
%w[whatsapp_phone_number government_id].each do |key|
|
|
564
|
+
raise ValidationError.new("#{key} must be a String") unless p[key].nil? || p[key].is_a?(String)
|
|
565
|
+
end
|
|
587
566
|
|
|
588
|
-
|
|
567
|
+
nullable_body(p, require_full_name ? [] : %w[email whatsapp_phone_number government_id])
|
|
589
568
|
end
|
|
590
569
|
|
|
591
|
-
def
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
570
|
+
def signer_fields(raw, create)
|
|
571
|
+
%w[full_name email whatsapp_phone_number government_id].each_with_object({}) do |key, fields|
|
|
572
|
+
source = key
|
|
573
|
+
source = SIGNER_KEY_ALIASES.fetch(key, key) if create ? raw[key].nil? : !raw.key?(key)
|
|
574
|
+
fields[key] = raw[source] if raw.key?(source)
|
|
575
|
+
end
|
|
596
576
|
end
|
|
597
577
|
|
|
598
|
-
def
|
|
599
|
-
|
|
600
|
-
return government_id if government_id.nil? || government_id.is_a?(String)
|
|
601
|
-
|
|
602
|
-
raise ValidationError.new('government_id must be a String')
|
|
578
|
+
def non_blank_string?(value)
|
|
579
|
+
value.is_a?(String) && !value.strip.empty?
|
|
603
580
|
end
|
|
604
581
|
|
|
605
582
|
def signature_type(type)
|
|
606
|
-
|
|
607
|
-
return value if SIGNATURE_TYPES.include?(value)
|
|
608
|
-
|
|
609
|
-
raise ValidationError.new('Signature type must be signature or initial', { type: type })
|
|
583
|
+
require_one_of(type, SIGNATURE_TYPES, 'Signature type')
|
|
610
584
|
end
|
|
611
585
|
end
|
|
612
586
|
end
|
|
@@ -14,7 +14,8 @@ module Assinafy
|
|
|
14
14
|
#
|
|
15
15
|
# @param params [Hash] documented `search` query; additional deployment-specific keys are forwarded
|
|
16
16
|
# @param account_id_override [String, nil]
|
|
17
|
-
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: { ... } }`
|
|
17
|
+
# @return [Hash{Symbol=>Array,Hash}] `{ data: [...], meta: { ... } }`; `meta` is absent when the
|
|
18
|
+
# response carries no pagination headers
|
|
18
19
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
19
20
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
20
21
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
@@ -52,7 +53,8 @@ module Assinafy
|
|
|
52
53
|
#
|
|
53
54
|
# @param payload [Hash]
|
|
54
55
|
# @option payload [String] :name required tag display name
|
|
55
|
-
# @option payload [String, nil] :color optional 6-digit hex color
|
|
56
|
+
# @option payload [String, nil] :color optional 6-digit hex color; a leading `#` is accepted and
|
|
57
|
+
# removed before sending
|
|
56
58
|
# @param account_id_override [String, nil]
|
|
57
59
|
# @return [Hash] the created tag object
|
|
58
60
|
# @raise [Assinafy::ValidationError] if `:name` is missing or blank
|
|
@@ -93,7 +95,8 @@ module Assinafy
|
|
|
93
95
|
# @param tag_id [String]
|
|
94
96
|
# @param payload [Hash]
|
|
95
97
|
# @option payload [String] :name optional new name
|
|
96
|
-
# @option payload [String, nil] :color optional new color
|
|
98
|
+
# @option payload [String, nil] :color optional new 6-digit hex color (a leading `#` is removed);
|
|
99
|
+
# nil clears it
|
|
97
100
|
# @param account_id_override [String, nil]
|
|
98
101
|
# @return [Hash] the updated tag object
|
|
99
102
|
# @raise [Assinafy::ValidationError] if the payload is empty or `:name` is blank
|
|
@@ -163,14 +166,19 @@ module Assinafy
|
|
|
163
166
|
private
|
|
164
167
|
|
|
165
168
|
def tag_payload(payload, require_name:)
|
|
166
|
-
|
|
167
|
-
body = body_params(raw)
|
|
168
|
-
body['color'] = nil if explicit_nil_color?(raw)
|
|
169
|
+
body = nullable_body(require_payload(payload, 'Tag payload'), %w[color])
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
if require_name || body.key?('name')
|
|
172
|
+
problem = require_name ? 'is required' : 'cannot be blank'
|
|
173
|
+
raise ValidationError.new("Tag name #{problem}") if body['name'].to_s.strip.empty?
|
|
174
|
+
|
|
175
|
+
require_string(body['name'], 'Tag name')
|
|
176
|
+
end
|
|
177
|
+
unless body['color'].nil?
|
|
172
178
|
color = require_string(body['color'], 'Tag color')
|
|
173
179
|
raise ValidationError.new('Tag color must be a 6-digit hex color') unless color.match?(/\A#?[0-9a-f]{6}\z/i)
|
|
180
|
+
|
|
181
|
+
body['color'] = color.delete_prefix('#')
|
|
174
182
|
end
|
|
175
183
|
|
|
176
184
|
if !require_name && body.empty?
|
|
@@ -179,20 +187,6 @@ module Assinafy
|
|
|
179
187
|
|
|
180
188
|
body
|
|
181
189
|
end
|
|
182
|
-
|
|
183
|
-
def validate_tag_name!(body, require_name:)
|
|
184
|
-
has_name = body.key?('name')
|
|
185
|
-
require_string(body['name'], 'Tag name') if has_name && !body['name'].to_s.strip.empty?
|
|
186
|
-
blank = body['name'].to_s.strip.empty?
|
|
187
|
-
|
|
188
|
-
raise ValidationError.new('Tag name is required') if require_name && (!has_name || blank)
|
|
189
|
-
raise ValidationError.new('Tag name cannot be blank') if !require_name && has_name && blank
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
def explicit_nil_color?(payload)
|
|
193
|
-
(payload.key?(:color) && payload[:color].nil?) ||
|
|
194
|
-
(payload.key?('color') && payload['color'].nil?)
|
|
195
|
-
end
|
|
196
190
|
end
|
|
197
191
|
end
|
|
198
192
|
end
|
|
@@ -27,7 +27,7 @@ module Assinafy
|
|
|
27
27
|
# # "name" => "sample-contract-one-page.pdf",
|
|
28
28
|
# # "document_name" => "sample-contract-one-page.pdf",
|
|
29
29
|
# # "message" => nil,
|
|
30
|
-
# # "status" => "
|
|
30
|
+
# # "status" => "ready",
|
|
31
31
|
# # "pages" => [{ "id" => "template-page-id", "number" => 1, "fields" => [] }],
|
|
32
32
|
# # "roles" => [{ "id" => "role-id", "name" => "TemplateEditor" }],
|
|
33
33
|
# # "tags" => [{ "id" => "tag-id-3", "name" => "HR" }],
|
|
@@ -65,7 +65,7 @@ module Assinafy
|
|
|
65
65
|
# # "name" => "sample-contract-one-page.pdf",
|
|
66
66
|
# # "document_name" => "sample-contract-one-page.pdf",
|
|
67
67
|
# # "message" => nil,
|
|
68
|
-
# # "status" => "
|
|
68
|
+
# # "status" => "ready",
|
|
69
69
|
# # "pages" => [
|
|
70
70
|
# # {
|
|
71
71
|
# # "id" => "template-page-id", "number" => 1, "height" => 2100, "width" => 1275,
|
|
@@ -114,7 +114,7 @@ module Assinafy
|
|
|
114
114
|
# # "name" => "contract.pdf",
|
|
115
115
|
# # "document_name" => "contract.pdf",
|
|
116
116
|
# # "message" => nil,
|
|
117
|
-
# # "status" => "
|
|
117
|
+
# # "status" => "uploaded",
|
|
118
118
|
# # "pages" => [],
|
|
119
119
|
# # "roles" => [{ "id" => "role-id-2", "name" => "TemplateEditor",
|
|
120
120
|
# # "assignment_type" => "Editor", "created_at" => "2026-07-20T15:57:19Z",
|
|
@@ -127,9 +127,8 @@ module Assinafy
|
|
|
127
127
|
acc_id = account_id(account_id_override)
|
|
128
128
|
options = require_payload(options, 'Template options')
|
|
129
129
|
buffer, file_name = read_source(source, max_bytes: MAX_UPLOAD_BYTES)
|
|
130
|
-
|
|
130
|
+
validate_document_source!(buffer, file_name)
|
|
131
131
|
|
|
132
|
-
# @type var payload: Hash[String | Symbol, untyped]
|
|
133
132
|
payload = { file: file_part(buffer, file_name) }
|
|
134
133
|
options.each { |key, value| payload[key.to_s] = value unless value.nil? }
|
|
135
134
|
|
|
@@ -159,7 +158,7 @@ module Assinafy
|
|
|
159
158
|
# # "name" => "Renamed",
|
|
160
159
|
# # "document_name" => "sample-contract-one-page.pdf",
|
|
161
160
|
# # "message" => "Please sign",
|
|
162
|
-
# # "status" => "
|
|
161
|
+
# # "status" => "ready",
|
|
163
162
|
# # "created_at" => "2024-07-19T15:23:03Z",
|
|
164
163
|
# # "updated_at" => "2024-07-19T16:00:00Z"
|
|
165
164
|
# # # ... (full Template Object: pages, roles, tags; see docs for full shape)
|
|
@@ -37,12 +37,14 @@ module Assinafy
|
|
|
37
37
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
38
38
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
39
39
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
40
|
+
# @note Not available to OAuth access tokens (403); OAuth apps read identity from
|
|
41
|
+
# {OAuthResource#userinfo}.
|
|
40
42
|
# @see GET /users/self
|
|
41
43
|
# @example Fetch the current user
|
|
42
44
|
# # Request: GET /users/self
|
|
43
45
|
# client.users.me
|
|
44
46
|
#
|
|
45
|
-
# # Current OpenAPI response (unwrapped data payload
|
|
47
|
+
# # Current OpenAPI response (unwrapped data payload):
|
|
46
48
|
# {
|
|
47
49
|
# 'id' => 'user-id',
|
|
48
50
|
# 'name' => 'Example User',
|
|
@@ -51,7 +53,6 @@ module Assinafy
|
|
|
51
53
|
# 'government_id' => '',
|
|
52
54
|
# 'is_email_verified' => true,
|
|
53
55
|
# 'has_accepted_terms' => true,
|
|
54
|
-
# 'is_password_set' => true,
|
|
55
56
|
# 'created_at' => '2026-05-12T18:05:11Z',
|
|
56
57
|
# 'to_be_deleted_at' => nil
|
|
57
58
|
# }
|
|
@@ -96,6 +97,8 @@ module Assinafy
|
|
|
96
97
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
97
98
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
98
99
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
100
|
+
# @note Not available to OAuth access tokens (403); OAuth apps read identity from
|
|
101
|
+
# {OAuthResource#userinfo}.
|
|
99
102
|
# @see GET /users/self/stats
|
|
100
103
|
# @example Fetch monthly cross-account KPIs
|
|
101
104
|
# # Request: GET /users/self/stats?granularity=monthly
|
|
@@ -134,6 +137,7 @@ module Assinafy
|
|
|
134
137
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
135
138
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
136
139
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
140
|
+
# @note Not available to third-party OAuth applications (403).
|
|
137
141
|
# @see GET /users/self/notification-preferences
|
|
138
142
|
# @example Fetch the current preferences
|
|
139
143
|
# # Request: GET /users/self/notification-preferences
|
|
@@ -170,6 +174,7 @@ module Assinafy
|
|
|
170
174
|
# @raise [Assinafy::ApiError] on an unsuccessful API response
|
|
171
175
|
# @raise [Assinafy::NetworkError] on transport or TLS failure
|
|
172
176
|
# @raise [Assinafy::ValidationError] on invalid required input
|
|
177
|
+
# @note Not available to third-party OAuth applications (403).
|
|
173
178
|
# @see PUT /users/self/notification-preferences
|
|
174
179
|
# @example Disable one notification
|
|
175
180
|
# client.users.update_notification_preferences(SignerDeclined: false)
|