groupdocs 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +9 -9
- data/CHANGELOG.md +482 -477
- data/Gemfile +3 -3
- data/LICENSE.txt +21 -21
- data/README.md +94 -94
- data/Rakefile +9 -9
- data/examples/README.md +12 -12
- data/examples/api-samples/Gemfile +5 -5
- data/examples/api-samples/Gemfile.lock +49 -49
- data/examples/api-samples/README.md +23 -23
- data/examples/api-samples/public/css/style.css +229 -229
- data/examples/api-samples/public/docs/annotation-sample.html +167 -167
- data/examples/api-samples/public/docs/docco.css +500 -500
- data/examples/api-samples/public/docs/envelope-sample.html +374 -374
- data/examples/api-samples/public/docs/sample01.html +181 -181
- data/examples/api-samples/public/docs/sample02.html +199 -199
- data/examples/api-samples/public/docs/sample03.html +318 -318
- data/examples/api-samples/public/docs/sample04.html +217 -217
- data/examples/api-samples/public/docs/sample05.html +296 -296
- data/examples/api-samples/public/docs/sample06.html +347 -347
- data/examples/api-samples/public/docs/sample07.html +209 -209
- data/examples/api-samples/public/docs/sample08.html +277 -277
- data/examples/api-samples/public/docs/sample09.html +314 -314
- data/examples/api-samples/public/docs/sample10.html +270 -270
- data/examples/api-samples/public/docs/sample11.html +462 -462
- data/examples/api-samples/public/docs/sample12.html +199 -199
- data/examples/api-samples/public/docs/sample13.html +201 -201
- data/examples/api-samples/public/docs/sample14.html +204 -204
- data/examples/api-samples/public/docs/sample15.html +182 -182
- data/examples/api-samples/public/docs/sample16.html +234 -234
- data/examples/api-samples/public/docs/sample17.html +309 -309
- data/examples/api-samples/public/docs/sample18.html +721 -721
- data/examples/api-samples/public/docs/sample19.html +631 -631
- data/examples/api-samples/public/docs/sample20.html +230 -230
- data/examples/api-samples/public/docs/sample21.html +790 -790
- data/examples/api-samples/public/docs/sample22.html +408 -408
- data/examples/api-samples/public/docs/sample25.html +550 -550
- data/examples/api-samples/public/templates/base-simple_source.html +191 -191
- data/examples/api-samples/public/templates/testdocument.html +100 -100
- data/examples/api-samples/public/templates/welcome.htm +137 -137
- data/examples/api-samples/samples/annotation-sample.rb +56 -56
- data/examples/api-samples/samples/envelope-sample.rb +133 -133
- data/examples/api-samples/samples/sample01.rb +44 -44
- data/examples/api-samples/samples/sample02.rb +50 -50
- data/examples/api-samples/samples/sample03.rb +79 -79
- data/examples/api-samples/samples/sample04.rb +54 -54
- data/examples/api-samples/samples/sample05.rb +83 -83
- data/examples/api-samples/samples/sample06.rb +86 -86
- data/examples/api-samples/samples/sample07.rb +59 -59
- data/examples/api-samples/samples/sample08.rb +76 -76
- data/examples/api-samples/samples/sample09.rb +85 -85
- data/examples/api-samples/samples/sample10.rb +70 -70
- data/examples/api-samples/samples/sample11.rb +132 -132
- data/examples/api-samples/samples/sample12.rb +48 -48
- data/examples/api-samples/samples/sample13.rb +49 -49
- data/examples/api-samples/samples/sample14.rb +54 -54
- data/examples/api-samples/samples/sample15.rb +43 -43
- data/examples/api-samples/samples/sample16.rb +57 -57
- data/examples/api-samples/samples/sample17.rb +70 -70
- data/examples/api-samples/samples/sample18.rb +190 -190
- data/examples/api-samples/samples/sample19.rb +188 -188
- data/examples/api-samples/samples/sample20.rb +68 -68
- data/examples/api-samples/samples/sample21.rb +212 -212
- data/examples/api-samples/samples/sample22.rb +109 -109
- data/examples/api-samples/samples/sample25.rb +127 -127
- data/examples/api-samples/views/_others_samples.haml +233 -233
- data/examples/api-samples/views/annotation_sample.haml +63 -63
- data/examples/api-samples/views/envelope_sample.haml +72 -72
- data/examples/api-samples/views/index.haml +235 -235
- data/examples/api-samples/views/layout.haml +3 -3
- data/examples/api-samples/views/sample01.haml +63 -63
- data/examples/api-samples/views/sample02.haml +52 -52
- data/examples/api-samples/views/sample03.haml +87 -87
- data/examples/api-samples/views/sample04.haml +55 -55
- data/examples/api-samples/views/sample05.haml +86 -86
- data/examples/api-samples/views/sample06.haml +58 -58
- data/examples/api-samples/views/sample07.haml +52 -52
- data/examples/api-samples/views/sample08.haml +100 -100
- data/examples/api-samples/views/sample09.haml +95 -95
- data/examples/api-samples/views/sample10.haml +93 -93
- data/examples/api-samples/views/sample11.haml +140 -140
- data/examples/api-samples/views/sample12.haml +68 -68
- data/examples/api-samples/views/sample13.haml +64 -64
- data/examples/api-samples/views/sample14.haml +60 -60
- data/examples/api-samples/views/sample15.haml +51 -51
- data/examples/api-samples/views/sample16.haml +50 -50
- data/examples/api-samples/views/sample17.haml +54 -54
- data/examples/api-samples/views/sample18.haml +143 -143
- data/examples/api-samples/views/sample19.haml +92 -92
- data/examples/api-samples/views/sample20.haml +54 -54
- data/examples/api-samples/views/sample21.haml +123 -123
- data/examples/api-samples/views/sample22.haml +106 -106
- data/examples/api-samples/views/sample25.haml +101 -101
- data/examples/api-samples/views/sample31.haml +2 -2
- data/examples/api-samples/web.rb +20 -20
- data/examples/viewer/Gemfile +5 -5
- data/examples/viewer/app.rb +52 -52
- data/groupdocs.gemspec +31 -31
- data/lib/groupdocs.rb +62 -62
- data/lib/groupdocs/api.rb +6 -6
- data/lib/groupdocs/api/entity.rb +112 -112
- data/lib/groupdocs/api/helpers.rb +11 -11
- data/lib/groupdocs/api/helpers/access_mode_helper.rb +27 -27
- data/lib/groupdocs/api/helpers/access_rights_helper.rb +55 -55
- data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -30
- data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -49
- data/lib/groupdocs/api/helpers/credentials_helper.rb +35 -35
- data/lib/groupdocs/api/helpers/mime_helper.rb +21 -21
- data/lib/groupdocs/api/helpers/path_helper.rb +28 -28
- data/lib/groupdocs/api/helpers/rest_helper.rb +99 -99
- data/lib/groupdocs/api/helpers/signature_public_helper.rb +22 -22
- data/lib/groupdocs/api/helpers/status_helper.rb +27 -27
- data/lib/groupdocs/api/helpers/url_helper.rb +101 -101
- data/lib/groupdocs/api/request.rb +91 -91
- data/lib/groupdocs/datasource.rb +249 -249
- data/lib/groupdocs/datasource/field.rb +39 -39
- data/lib/groupdocs/document.rb +1550 -1550
- data/lib/groupdocs/document/annotation.rb +421 -421
- data/lib/groupdocs/document/annotation/reply.rb +173 -173
- data/lib/groupdocs/document/annotation/reviewer.rb +66 -66
- data/lib/groupdocs/document/change.rb +56 -56
- data/lib/groupdocs/document/field.rb +53 -53
- data/lib/groupdocs/document/metadata.rb +32 -32
- data/lib/groupdocs/document/rectangle.rb +18 -18
- data/lib/groupdocs/document/view.rb +36 -36
- data/lib/groupdocs/errors.rb +8 -8
- data/lib/groupdocs/job.rb +468 -468
- data/lib/groupdocs/questionnaire.rb +530 -530
- data/lib/groupdocs/questionnaire/collector.rb +335 -335
- data/lib/groupdocs/questionnaire/execution.rb +181 -181
- data/lib/groupdocs/questionnaire/page.rb +43 -43
- data/lib/groupdocs/questionnaire/question.rb +108 -108
- data/lib/groupdocs/questionnaire/question/answer.rb +15 -15
- data/lib/groupdocs/signature.rb +380 -380
- data/lib/groupdocs/signature/contact.rb +181 -181
- data/lib/groupdocs/signature/envelope.rb +747 -747
- data/lib/groupdocs/signature/envelope/log.rb +20 -20
- data/lib/groupdocs/signature/field.rb +286 -286
- data/lib/groupdocs/signature/field/location.rb +71 -71
- data/lib/groupdocs/signature/form.rb +804 -804
- data/lib/groupdocs/signature/list.rb +92 -92
- data/lib/groupdocs/signature/recipient.rb +79 -79
- data/lib/groupdocs/signature/role.rb +54 -54
- data/lib/groupdocs/signature/shared.rb +6 -6
- data/lib/groupdocs/signature/shared/document_methods.rb +158 -158
- data/lib/groupdocs/signature/shared/entity_fields.rb +76 -76
- data/lib/groupdocs/signature/shared/entity_methods.rb +144 -144
- data/lib/groupdocs/signature/shared/field_methods.rb +354 -354
- data/lib/groupdocs/signature/shared/recipient_methods.rb +75 -75
- data/lib/groupdocs/signature/shared/resource_methods.rb +65 -65
- data/lib/groupdocs/signature/template.rb +124 -124
- data/lib/groupdocs/storage.rb +44 -44
- data/lib/groupdocs/storage/file.rb +432 -432
- data/lib/groupdocs/storage/folder.rb +288 -288
- data/lib/groupdocs/storage/package.rb +48 -48
- data/lib/groupdocs/storage/provider.rb +32 -32
- data/lib/groupdocs/subscription.rb +323 -323
- data/lib/groupdocs/subscription/limit.rb +20 -20
- data/lib/groupdocs/user.rb +955 -930
- data/lib/groupdocs/version.rb +3 -3
- data/spec/groupdocs/api/entity_spec.rb +55 -55
- data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +21 -21
- data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -43
- data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -16
- data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -23
- data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +48 -48
- data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -16
- data/spec/groupdocs/api/helpers/path_helper_spec.rb +15 -15
- data/spec/groupdocs/api/helpers/rest_helper_spec.rb +161 -161
- data/spec/groupdocs/api/helpers/signature_public_helper_spec.rb +21 -21
- data/spec/groupdocs/api/helpers/status_helper_spec.rb +22 -22
- data/spec/groupdocs/api/helpers/url_helper_spec.rb +112 -112
- data/spec/groupdocs/api/request_spec.rb +112 -112
- data/spec/groupdocs/datasource/field_spec.rb +29 -29
- data/spec/groupdocs/datasource_spec.rb +145 -145
- data/spec/groupdocs/document/annotation/reply_spec.rb +154 -154
- data/spec/groupdocs/document/annotation/reviewer_spec.rb +51 -51
- data/spec/groupdocs/document/annotation_spec.rb +234 -234
- data/spec/groupdocs/document/change_spec.rb +39 -39
- data/spec/groupdocs/document/field_spec.rb +28 -28
- data/spec/groupdocs/document/metadata_spec.rb +21 -21
- data/spec/groupdocs/document/rectangle_spec.rb +14 -14
- data/spec/groupdocs/document/view_spec.rb +33 -33
- data/spec/groupdocs/document_spec.rb +859 -859
- data/spec/groupdocs/errors_spec.rb +7 -7
- data/spec/groupdocs/job_spec.rb +323 -323
- data/spec/groupdocs/questionnaire/collector_spec.rb +197 -197
- data/spec/groupdocs/questionnaire/execution_spec.rb +162 -162
- data/spec/groupdocs/questionnaire/page_spec.rb +47 -47
- data/spec/groupdocs/questionnaire/question/answer_spec.rb +9 -9
- data/spec/groupdocs/questionnaire/question_spec.rb +75 -75
- data/spec/groupdocs/questionnaire_spec.rb +295 -295
- data/spec/groupdocs/signature/contact_spec.rb +142 -142
- data/spec/groupdocs/signature/envelope/log_spec.rb +15 -15
- data/spec/groupdocs/signature/envelope_spec.rb +384 -384
- data/spec/groupdocs/signature/field/location_spec.rb +40 -40
- data/spec/groupdocs/signature/field_spec.rb +235 -235
- data/spec/groupdocs/signature/form_spec.rb +205 -205
- data/spec/groupdocs/signature/list_spec.rb +87 -87
- data/spec/groupdocs/signature/recipient_spec.rb +26 -26
- data/spec/groupdocs/signature/role_spec.rb +47 -47
- data/spec/groupdocs/signature/template_spec.rb +80 -80
- data/spec/groupdocs/signature_spec.rb +194 -194
- data/spec/groupdocs/storage/file_spec.rb +303 -303
- data/spec/groupdocs/storage/folder_spec.rb +270 -270
- data/spec/groupdocs/storage/package_spec.rb +38 -38
- data/spec/groupdocs/storage/provider_spec.rb +21 -21
- data/spec/groupdocs/storage_spec.rb +27 -27
- data/spec/groupdocs/subscription/limit_spec.rb +16 -16
- data/spec/groupdocs/subscription_spec.rb +74 -74
- data/spec/groupdocs/user_spec.rb +257 -257
- data/spec/groupdocs_spec.rb +63 -63
- data/spec/spec_helper.rb +73 -73
- data/spec/support/json/annotation_access_set.json +11 -11
- data/spec/support/json/annotation_collaborators_get.json +16 -16
- data/spec/support/json/annotation_collaborators_set.json +16 -16
- data/spec/support/json/annotation_create.json +12 -12
- data/spec/support/json/annotation_list.json +32 -32
- data/spec/support/json/annotation_marker_move.json +10 -10
- data/spec/support/json/annotation_move.json +8 -8
- data/spec/support/json/annotation_remove.json +9 -9
- data/spec/support/json/annotation_replies_create.json +9 -9
- data/spec/support/json/annotation_replies_get.json +25 -25
- data/spec/support/json/annotation_reviewers_get.json +18 -18
- data/spec/support/json/comparison_changes.json +46 -46
- data/spec/support/json/comparison_compare.json +8 -8
- data/spec/support/json/comparison_document.json +10 -10
- data/spec/support/json/contact_add.json +12 -12
- data/spec/support/json/contacts_get.json +19 -19
- data/spec/support/json/contacts_import.json +8 -8
- data/spec/support/json/datasource_add.json +8 -8
- data/spec/support/json/datasource_get.json +22 -22
- data/spec/support/json/datasource_remove.json +8 -8
- data/spec/support/json/datasource_update.json +8 -8
- data/spec/support/json/delete_account.json +9 -9
- data/spec/support/json/document_access_info_get.json +14 -14
- data/spec/support/json/document_convert.json +8 -8
- data/spec/support/json/document_datasource.json +10 -10
- data/spec/support/json/document_fields.json +34 -34
- data/spec/support/json/document_formats.json +8 -8
- data/spec/support/json/document_metadata.json +15 -15
- data/spec/support/json/document_page_images_get.json +20 -20
- data/spec/support/json/document_questionnaire_create.json +9 -9
- data/spec/support/json/document_questionnaires.json +23 -23
- data/spec/support/json/document_sharers_remove.json +8 -8
- data/spec/support/json/document_sharers_set.json +16 -16
- data/spec/support/json/document_thumbnails.json +24 -24
- data/spec/support/json/document_views.json +32 -32
- data/spec/support/json/envelope_get.json +46 -46
- data/spec/support/json/envelope_logs.json +16 -16
- data/spec/support/json/envelope_recipient_add.json +26 -26
- data/spec/support/json/envelopes_all.json +48 -48
- data/spec/support/json/envelopes_resources.json +31 -31
- data/spec/support/json/file_compress.json +8 -8
- data/spec/support/json/file_copy.json +14 -14
- data/spec/support/json/file_delete.json +5 -5
- data/spec/support/json/file_move.json +14 -14
- data/spec/support/json/file_upload.json +8 -8
- data/spec/support/json/folder_create.json +8 -8
- data/spec/support/json/folder_delete.json +5 -5
- data/spec/support/json/folder_list.json +22 -22
- data/spec/support/json/folder_move.json +8 -8
- data/spec/support/json/folder_sharers_get.json +16 -16
- data/spec/support/json/folder_sharers_remove.json +8 -8
- data/spec/support/json/folder_sharers_set.json +16 -16
- data/spec/support/json/form_get.json +21 -21
- data/spec/support/json/forms_all.json +23 -23
- data/spec/support/json/job_add_url.json +8 -8
- data/spec/support/json/job_create.json +8 -8
- data/spec/support/json/job_documents.json +40 -40
- data/spec/support/json/job_file_add.json +8 -8
- data/spec/support/json/job_get.json +30 -30
- data/spec/support/json/job_update.json +7 -7
- data/spec/support/json/jobs_get.json +58 -58
- data/spec/support/json/list_add.json +12 -12
- data/spec/support/json/lists_get.json +19 -19
- data/spec/support/json/package_create.json +7 -7
- data/spec/support/json/questionnaire_collector.json +17 -17
- data/spec/support/json/questionnaire_collectors.json +38 -38
- data/spec/support/json/questionnaire_collectors_add.json +10 -10
- data/spec/support/json/questionnaire_create.json +10 -10
- data/spec/support/json/questionnaire_datasources.json +26 -26
- data/spec/support/json/questionnaire_execution_add.json +9 -9
- data/spec/support/json/questionnaire_execution_status_set.json +8 -8
- data/spec/support/json/questionnaire_execution_update.json +8 -8
- data/spec/support/json/questionnaire_executions.json +28 -28
- data/spec/support/json/questionnaire_get.json +17 -17
- data/spec/support/json/questionnaire_remove.json +8 -8
- data/spec/support/json/questionnaire_update.json +8 -8
- data/spec/support/json/questionnaires_get.json +40 -40
- data/spec/support/json/sign_documents.json +16 -16
- data/spec/support/json/signature_create.json +12 -12
- data/spec/support/json/signature_field_add.json +25 -25
- data/spec/support/json/signature_fields_get.json +27 -27
- data/spec/support/json/signature_roles_get.json +17 -17
- data/spec/support/json/signatures_get.json +19 -19
- data/spec/support/json/storage_info.json +10 -10
- data/spec/support/json/subscription_plan_get.json +9 -9
- data/spec/support/json/subscription_plans_get.json +17 -17
- data/spec/support/json/template_get.json +35 -35
- data/spec/support/json/template_get_documents.json +15 -15
- data/spec/support/json/template_get_recipients.json +20 -20
- data/spec/support/json/templates_all.json +37 -37
- data/spec/support/json/templates_get.json +21 -21
- data/spec/support/json/update_account.json +10 -10
- data/spec/support/json/user_area.json +67 -67
- data/spec/support/json/user_embed_key.json +38 -38
- data/spec/support/json/user_get_embed_key.json +67 -67
- data/spec/support/json/user_login.json +67 -67
- data/spec/support/json/user_profile_get.json +24 -24
- data/spec/support/json/user_providers.json +31 -31
- data/spec/support/json/user_roles.json +25 -25
- data/spec/support/json/user_users_get.json +27 -27
- data/spec/support/shared_examples/api/entity.rb +39 -39
- data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +11 -11
- data/spec/support/shared_examples/api/helpers/status_helper.rb +11 -11
- data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -68
- data/spec/support/shared_examples/signature/shared/entity_fields.rb +56 -56
- data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -116
- data/spec/support/shared_examples/signature/shared/field_methods.rb +220 -220
- data/spec/support/shared_examples/signature/shared/recipient_methods.rb +46 -46
- data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -46
- metadata +35 -55
@@ -1,181 +1,181 @@
|
|
1
|
-
module GroupDocs
|
2
|
-
class Signature::Contact < Api::Entity
|
3
|
-
|
4
|
-
INTEGRATION_PROVIDERS = {
|
5
|
-
:local => 0,
|
6
|
-
:groupdocs => 1,
|
7
|
-
:google => 2,
|
8
|
-
}
|
9
|
-
|
10
|
-
#
|
11
|
-
# Returns a list of all contacts.
|
12
|
-
#
|
13
|
-
# @param [Hash] options Hash of options
|
14
|
-
# @option options [Integer] :page Page to start with
|
15
|
-
# @option options [Integer] :records How many items to list
|
16
|
-
# @option options [String] :firstName Filter by first name
|
17
|
-
# @option options [String] :lastName Filter by last name
|
18
|
-
# @option options [String] :email Filter by last name
|
19
|
-
# @param [Hash] access Access credentials
|
20
|
-
# @option access [String] :client_id
|
21
|
-
# @option access [String] :private_key
|
22
|
-
# @return [Array<GroupDocs::Signature::Contact>]
|
23
|
-
#
|
24
|
-
def self.get!(options = {}, access = {})
|
25
|
-
api = Api::Request.new do |request|
|
26
|
-
request[:access] = access
|
27
|
-
request[:method] = :GET
|
28
|
-
request[:path] = '/signature/{{client_id}}/contacts'
|
29
|
-
end
|
30
|
-
api.add_params(options)
|
31
|
-
json = api.execute!
|
32
|
-
|
33
|
-
json[:contacts].map do |contact|
|
34
|
-
new(contact)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# Imports array of contacts.
|
40
|
-
#
|
41
|
-
# @example
|
42
|
-
# contact_one = GroupDocs::Signature::Contact.new
|
43
|
-
# contact_one.first_name = 'John'
|
44
|
-
# contact_one.last_name = 'Smith'
|
45
|
-
# contact_one.email = 'john@smith.com'
|
46
|
-
# contact_two = GroupDocs::Signature::Contact.new
|
47
|
-
# contact_two.first_name = 'Carla'
|
48
|
-
# contact_two.last_name = 'Smith'
|
49
|
-
# contact_two.email = 'carla@smith.com'
|
50
|
-
# GroupDocs::Signature::Contact.import!([contact_one, contact_two])
|
51
|
-
#
|
52
|
-
# @param [Array<GroupDocs::Signature::Contact>] contacts
|
53
|
-
# @param [Hash] access Access credentials
|
54
|
-
# @option access [String] :client_id
|
55
|
-
# @option access [String] :private_key
|
56
|
-
#
|
57
|
-
def self.import!(contacts, access = {})
|
58
|
-
contacts.is_a?(Array) or raise ArgumentError, "Contacts should be array, received: #{contacts.inspect}"
|
59
|
-
contacts.each do |contact|
|
60
|
-
contact.is_a?(GroupDocs::Signature::Contact) or raise ArgumentError, "Contact should be GroupDocs::Signature::Contact, received: #{contact.inspect}"
|
61
|
-
end
|
62
|
-
|
63
|
-
Api::Request.new do |request|
|
64
|
-
request[:access] = access
|
65
|
-
request[:method] = :POST
|
66
|
-
request[:path] = '/signature/{{client_id}}/contacts'
|
67
|
-
request[:request_body] = contacts.map { |contact| contact.to_hash }
|
68
|
-
end.execute!
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Adds contact integration.
|
73
|
-
#
|
74
|
-
# @example Add Google contacts integration
|
75
|
-
# integration = {
|
76
|
-
# provider: :google,
|
77
|
-
# refresh_token: 'token',
|
78
|
-
# access_token: 'token',
|
79
|
-
# access_token_expiration: '2014-12-12'
|
80
|
-
# }
|
81
|
-
#
|
82
|
-
# @param [Hash] integration
|
83
|
-
# @option integration [Symbol] provider One of :local, :groupdocs or :google
|
84
|
-
# @option integration [String] refresh_token
|
85
|
-
# @option integration [String] access_token
|
86
|
-
# @option integration [String] access_token_exipration
|
87
|
-
# @param [Hash] access Access credentials
|
88
|
-
# @option access [String] :client_id
|
89
|
-
# @option access [String] :private_key
|
90
|
-
#
|
91
|
-
def self.add_integration!(integration, access = {})
|
92
|
-
payload = {
|
93
|
-
:provider => INTEGRATION_PROVIDERS[integration[:provider]],
|
94
|
-
:refreshToken => integration[:refresh_token],
|
95
|
-
:accessToken => integration[:access_token],
|
96
|
-
:accessTokenExpiration => integration[:access_token_expiration],
|
97
|
-
}
|
98
|
-
|
99
|
-
Api::Request.new do |request|
|
100
|
-
request[:access] = access
|
101
|
-
request[:method] = :POST
|
102
|
-
request[:path] = '/signature/{{client_id}}/integration'
|
103
|
-
request[:request_body] = payload
|
104
|
-
end.execute!
|
105
|
-
end
|
106
|
-
|
107
|
-
# @attr [String] id
|
108
|
-
attr_accessor :id
|
109
|
-
# @attr [String] firstName
|
110
|
-
attr_accessor :firstName
|
111
|
-
# @attr [String] lastName
|
112
|
-
attr_accessor :lastName
|
113
|
-
# @attr [String] nickname
|
114
|
-
attr_accessor :nickname
|
115
|
-
# @attr [String] email
|
116
|
-
attr_accessor :email
|
117
|
-
# @attr [String] provider
|
118
|
-
attr_accessor :provider
|
119
|
-
|
120
|
-
# Human-readable accessors
|
121
|
-
alias_accessor :first_name, :firstName
|
122
|
-
alias_accessor :last_name, :lastName
|
123
|
-
|
124
|
-
#
|
125
|
-
# Adds contact.
|
126
|
-
#
|
127
|
-
# @example
|
128
|
-
# contact = GroupDocs::Signature::Contact.new
|
129
|
-
# contact.first_name = 'John'
|
130
|
-
# contact.last_name = 'Smith'
|
131
|
-
# contact.email = 'john@smith.com'
|
132
|
-
# contact.add!
|
133
|
-
#
|
134
|
-
# @param [Hash] access Access credentials
|
135
|
-
# @option access [String] :client_id
|
136
|
-
# @option access [String] :private_key
|
137
|
-
#
|
138
|
-
def add!(access = {})
|
139
|
-
json = Api::Request.new do |request|
|
140
|
-
request[:access] = access
|
141
|
-
request[:method] = :POST
|
142
|
-
request[:path] = '/signature/{{client_id}}/contact'
|
143
|
-
request[:request_body] = to_hash
|
144
|
-
end.execute!
|
145
|
-
|
146
|
-
self.id = json[:contact][:id]
|
147
|
-
end
|
148
|
-
|
149
|
-
#
|
150
|
-
# Updates contact.
|
151
|
-
#
|
152
|
-
# @param [Hash] access Access credentials
|
153
|
-
# @option access [String] :client_id
|
154
|
-
# @option access [String] :private_key
|
155
|
-
#
|
156
|
-
def update!(access = {})
|
157
|
-
Api::Request.new do |request|
|
158
|
-
request[:access] = access
|
159
|
-
request[:method] = :POST
|
160
|
-
request[:path] = "/signature/{{client_id}}/contacts/#{id}"
|
161
|
-
request[:request_body] = to_hash
|
162
|
-
end.execute!
|
163
|
-
end
|
164
|
-
|
165
|
-
#
|
166
|
-
# Deletes contact.
|
167
|
-
#
|
168
|
-
# @param [Hash] access Access credentials
|
169
|
-
# @option access [String] :client_id
|
170
|
-
# @option access [String] :private_key
|
171
|
-
#
|
172
|
-
def delete!(access = {})
|
173
|
-
Api::Request.new do |request|
|
174
|
-
request[:access] = access
|
175
|
-
request[:method] = :DELETE
|
176
|
-
request[:path] = "/signature/{{client_id}}/contacts/#{id}"
|
177
|
-
end.execute!
|
178
|
-
end
|
179
|
-
|
180
|
-
end # Signature::Contact
|
181
|
-
end # GroupDocs
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Contact < Api::Entity
|
3
|
+
|
4
|
+
INTEGRATION_PROVIDERS = {
|
5
|
+
:local => 0,
|
6
|
+
:groupdocs => 1,
|
7
|
+
:google => 2,
|
8
|
+
}
|
9
|
+
|
10
|
+
#
|
11
|
+
# Returns a list of all contacts.
|
12
|
+
#
|
13
|
+
# @param [Hash] options Hash of options
|
14
|
+
# @option options [Integer] :page Page to start with
|
15
|
+
# @option options [Integer] :records How many items to list
|
16
|
+
# @option options [String] :firstName Filter by first name
|
17
|
+
# @option options [String] :lastName Filter by last name
|
18
|
+
# @option options [String] :email Filter by last name
|
19
|
+
# @param [Hash] access Access credentials
|
20
|
+
# @option access [String] :client_id
|
21
|
+
# @option access [String] :private_key
|
22
|
+
# @return [Array<GroupDocs::Signature::Contact>]
|
23
|
+
#
|
24
|
+
def self.get!(options = {}, access = {})
|
25
|
+
api = Api::Request.new do |request|
|
26
|
+
request[:access] = access
|
27
|
+
request[:method] = :GET
|
28
|
+
request[:path] = '/signature/{{client_id}}/contacts'
|
29
|
+
end
|
30
|
+
api.add_params(options)
|
31
|
+
json = api.execute!
|
32
|
+
|
33
|
+
json[:contacts].map do |contact|
|
34
|
+
new(contact)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Imports array of contacts.
|
40
|
+
#
|
41
|
+
# @example
|
42
|
+
# contact_one = GroupDocs::Signature::Contact.new
|
43
|
+
# contact_one.first_name = 'John'
|
44
|
+
# contact_one.last_name = 'Smith'
|
45
|
+
# contact_one.email = 'john@smith.com'
|
46
|
+
# contact_two = GroupDocs::Signature::Contact.new
|
47
|
+
# contact_two.first_name = 'Carla'
|
48
|
+
# contact_two.last_name = 'Smith'
|
49
|
+
# contact_two.email = 'carla@smith.com'
|
50
|
+
# GroupDocs::Signature::Contact.import!([contact_one, contact_two])
|
51
|
+
#
|
52
|
+
# @param [Array<GroupDocs::Signature::Contact>] contacts
|
53
|
+
# @param [Hash] access Access credentials
|
54
|
+
# @option access [String] :client_id
|
55
|
+
# @option access [String] :private_key
|
56
|
+
#
|
57
|
+
def self.import!(contacts, access = {})
|
58
|
+
contacts.is_a?(Array) or raise ArgumentError, "Contacts should be array, received: #{contacts.inspect}"
|
59
|
+
contacts.each do |contact|
|
60
|
+
contact.is_a?(GroupDocs::Signature::Contact) or raise ArgumentError, "Contact should be GroupDocs::Signature::Contact, received: #{contact.inspect}"
|
61
|
+
end
|
62
|
+
|
63
|
+
Api::Request.new do |request|
|
64
|
+
request[:access] = access
|
65
|
+
request[:method] = :POST
|
66
|
+
request[:path] = '/signature/{{client_id}}/contacts'
|
67
|
+
request[:request_body] = contacts.map { |contact| contact.to_hash }
|
68
|
+
end.execute!
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Adds contact integration.
|
73
|
+
#
|
74
|
+
# @example Add Google contacts integration
|
75
|
+
# integration = {
|
76
|
+
# provider: :google,
|
77
|
+
# refresh_token: 'token',
|
78
|
+
# access_token: 'token',
|
79
|
+
# access_token_expiration: '2014-12-12'
|
80
|
+
# }
|
81
|
+
#
|
82
|
+
# @param [Hash] integration
|
83
|
+
# @option integration [Symbol] provider One of :local, :groupdocs or :google
|
84
|
+
# @option integration [String] refresh_token
|
85
|
+
# @option integration [String] access_token
|
86
|
+
# @option integration [String] access_token_exipration
|
87
|
+
# @param [Hash] access Access credentials
|
88
|
+
# @option access [String] :client_id
|
89
|
+
# @option access [String] :private_key
|
90
|
+
#
|
91
|
+
def self.add_integration!(integration, access = {})
|
92
|
+
payload = {
|
93
|
+
:provider => INTEGRATION_PROVIDERS[integration[:provider]],
|
94
|
+
:refreshToken => integration[:refresh_token],
|
95
|
+
:accessToken => integration[:access_token],
|
96
|
+
:accessTokenExpiration => integration[:access_token_expiration],
|
97
|
+
}
|
98
|
+
|
99
|
+
Api::Request.new do |request|
|
100
|
+
request[:access] = access
|
101
|
+
request[:method] = :POST
|
102
|
+
request[:path] = '/signature/{{client_id}}/integration'
|
103
|
+
request[:request_body] = payload
|
104
|
+
end.execute!
|
105
|
+
end
|
106
|
+
|
107
|
+
# @attr [String] id
|
108
|
+
attr_accessor :id
|
109
|
+
# @attr [String] firstName
|
110
|
+
attr_accessor :firstName
|
111
|
+
# @attr [String] lastName
|
112
|
+
attr_accessor :lastName
|
113
|
+
# @attr [String] nickname
|
114
|
+
attr_accessor :nickname
|
115
|
+
# @attr [String] email
|
116
|
+
attr_accessor :email
|
117
|
+
# @attr [String] provider
|
118
|
+
attr_accessor :provider
|
119
|
+
|
120
|
+
# Human-readable accessors
|
121
|
+
alias_accessor :first_name, :firstName
|
122
|
+
alias_accessor :last_name, :lastName
|
123
|
+
|
124
|
+
#
|
125
|
+
# Adds contact.
|
126
|
+
#
|
127
|
+
# @example
|
128
|
+
# contact = GroupDocs::Signature::Contact.new
|
129
|
+
# contact.first_name = 'John'
|
130
|
+
# contact.last_name = 'Smith'
|
131
|
+
# contact.email = 'john@smith.com'
|
132
|
+
# contact.add!
|
133
|
+
#
|
134
|
+
# @param [Hash] access Access credentials
|
135
|
+
# @option access [String] :client_id
|
136
|
+
# @option access [String] :private_key
|
137
|
+
#
|
138
|
+
def add!(access = {})
|
139
|
+
json = Api::Request.new do |request|
|
140
|
+
request[:access] = access
|
141
|
+
request[:method] = :POST
|
142
|
+
request[:path] = '/signature/{{client_id}}/contact'
|
143
|
+
request[:request_body] = to_hash
|
144
|
+
end.execute!
|
145
|
+
|
146
|
+
self.id = json[:contact][:id]
|
147
|
+
end
|
148
|
+
|
149
|
+
#
|
150
|
+
# Updates contact.
|
151
|
+
#
|
152
|
+
# @param [Hash] access Access credentials
|
153
|
+
# @option access [String] :client_id
|
154
|
+
# @option access [String] :private_key
|
155
|
+
#
|
156
|
+
def update!(access = {})
|
157
|
+
Api::Request.new do |request|
|
158
|
+
request[:access] = access
|
159
|
+
request[:method] = :POST
|
160
|
+
request[:path] = "/signature/{{client_id}}/contacts/#{id}"
|
161
|
+
request[:request_body] = to_hash
|
162
|
+
end.execute!
|
163
|
+
end
|
164
|
+
|
165
|
+
#
|
166
|
+
# Deletes contact.
|
167
|
+
#
|
168
|
+
# @param [Hash] access Access credentials
|
169
|
+
# @option access [String] :client_id
|
170
|
+
# @option access [String] :private_key
|
171
|
+
#
|
172
|
+
def delete!(access = {})
|
173
|
+
Api::Request.new do |request|
|
174
|
+
request[:access] = access
|
175
|
+
request[:method] = :DELETE
|
176
|
+
request[:path] = "/signature/{{client_id}}/contacts/#{id}"
|
177
|
+
end.execute!
|
178
|
+
end
|
179
|
+
|
180
|
+
end # Signature::Contact
|
181
|
+
end # GroupDocs
|
@@ -1,747 +1,747 @@
|
|
1
|
-
module GroupDocs
|
2
|
-
class Signature::Envelope < Api::Entity
|
3
|
-
|
4
|
-
require 'groupdocs/signature/envelope/log'
|
5
|
-
|
6
|
-
STATUSES = {
|
7
|
-
:draft => -1,
|
8
|
-
:annotation => 0,
|
9
|
-
:in_progress => 1,
|
10
|
-
:expired => 2,
|
11
|
-
:canceled => 3,
|
12
|
-
:failed => 4,
|
13
|
-
:completed => 5,
|
14
|
-
:archived => 6,
|
15
|
-
:scheduled => 99,
|
16
|
-
}
|
17
|
-
|
18
|
-
include Api::Helpers::SignaturePublic
|
19
|
-
include Signature::DocumentMethods
|
20
|
-
include Signature::EntityFields
|
21
|
-
include Signature::EntityMethods
|
22
|
-
include Signature::FieldMethods
|
23
|
-
include Signature::RecipientMethods
|
24
|
-
extend Signature::ResourceMethods
|
25
|
-
|
26
|
-
#
|
27
|
-
# Changed in release 1.7.0
|
28
|
-
#
|
29
|
-
#
|
30
|
-
# Returns a list of all envelopes.
|
31
|
-
#
|
32
|
-
# @param [Hash] options Hash of options
|
33
|
-
# @option options [Integer] :page Page to start with
|
34
|
-
# @option options [Integer] :records How many items to list
|
35
|
-
# @option options [Integer] :status_id Filter envelopes by status identifier
|
36
|
-
# @option options [String] :document Filter envelopes by document GUID
|
37
|
-
# @option options [String] :recipient Filter envelopes by recipient email
|
38
|
-
# @option options [String] :date Filter envelopes by date
|
39
|
-
# @option options [String] :name Filter envelopes by name
|
40
|
-
# @option options [String] :tag Filter envelopes by tag
|
41
|
-
# @param [Hash] access Access credentials
|
42
|
-
# @option access [String] :client_id
|
43
|
-
# @option access [String] :private_key
|
44
|
-
# @return [Array<GroupDocs::Signature::Envelope>]
|
45
|
-
#
|
46
|
-
def self.all!(options = {}, access = {})
|
47
|
-
status_id = options.delete(:status_id)
|
48
|
-
options[:statusId] = status_id if status_id
|
49
|
-
|
50
|
-
api = Api::Request.new do |request|
|
51
|
-
request[:access] = access
|
52
|
-
request[:method] = :GET
|
53
|
-
request[:path] = '/signature/{{client_id}}/envelopes'
|
54
|
-
end
|
55
|
-
api.add_params(options)
|
56
|
-
json = api.execute!
|
57
|
-
|
58
|
-
json[:envelopes].map do |envelope|
|
59
|
-
new(envelope)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
#
|
64
|
-
# Returns a list of all envelopes where user is recipient.
|
65
|
-
#
|
66
|
-
# @param [Hash] options Hash of options
|
67
|
-
# @option options [Integer] :page Page to start with
|
68
|
-
# @option options [Integer] :records How many items to list
|
69
|
-
# @option options [Integer] :statusId Filter by status identifier
|
70
|
-
# @param [Hash] access Access credentials
|
71
|
-
# @option access [String] :client_id
|
72
|
-
# @option access [String] :private_key
|
73
|
-
# @return [Array<GroupDocs::Signature::Envelope>]
|
74
|
-
#
|
75
|
-
def self.for_me!(options = {}, access = {})
|
76
|
-
api = Api::Request.new do |request|
|
77
|
-
request[:access] = access
|
78
|
-
request[:method] = :GET
|
79
|
-
request[:path] = '/signature/{{client_id}}/envelopes/recipient'
|
80
|
-
end
|
81
|
-
api.add_params(options)
|
82
|
-
json = api.execute!
|
83
|
-
|
84
|
-
json[:envelopes].map do |envelope|
|
85
|
-
new(envelope)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# @attr [String] creationDateTime
|
90
|
-
attr_accessor :creationDateTime
|
91
|
-
# @attr [Symbol] status
|
92
|
-
attr_accessor :status
|
93
|
-
# @attr [String] statusDateTime
|
94
|
-
attr_accessor :statusDateTime
|
95
|
-
# @attr [Integer] envelopeExpireTime
|
96
|
-
attr_accessor :envelopeExpireTime
|
97
|
-
# @attr [Boolean] isDemo
|
98
|
-
attr_accessor :isDemo
|
99
|
-
|
100
|
-
# added in release 1.7.0
|
101
|
-
# @attr [String] updatedDateTime
|
102
|
-
attr_accessor :updatedDateTime
|
103
|
-
# @attr [Boolean] attachSignedDocument
|
104
|
-
attr_accessor :attachSignedDocument
|
105
|
-
# @attr [Boolean] includeViewLink
|
106
|
-
attr_accessor :includeViewLink
|
107
|
-
# @attr [Boolean] canBeCommented
|
108
|
-
attr_accessor :canBeCommented
|
109
|
-
# @attr [Boolean] inPersonSign
|
110
|
-
attr_accessor :inPersonSign
|
111
|
-
# @attr [String] ownerName
|
112
|
-
attr_accessor :ownerName
|
113
|
-
# @attr [Boolean] enableTypedSignature
|
114
|
-
attr_accessor :enableTypedSignature
|
115
|
-
# @attr [Boolean] enableUploadedSignature
|
116
|
-
attr_accessor :enableUploadedSignature
|
117
|
-
# @attr [Boolean] requireUserAuthForSign
|
118
|
-
attr_accessor :requireUserAuthForSign
|
119
|
-
# @attr [Boolean] requestUserAuthByPhoto
|
120
|
-
attr_accessor :requestUserAuthByPhoto
|
121
|
-
# @attr [Boolean] showRecipientCommentInSignedDocument
|
122
|
-
attr_accessor :showRecipientCommentInSignedDocument
|
123
|
-
# @attr [String] tags
|
124
|
-
attr_accessor :tags
|
125
|
-
|
126
|
-
# added in release 1.9.0
|
127
|
-
# @attr [Boolean] lockDuringSign
|
128
|
-
attr_accessor :lockDuringSign
|
129
|
-
|
130
|
-
# Human-readable accessors
|
131
|
-
alias_accessor :creation_date_time, :creationDateTime
|
132
|
-
alias_accessor :status_date_time, :statusDateTime
|
133
|
-
alias_accessor :envelope_expire_time, :envelopeExpireTime
|
134
|
-
alias_accessor :is_demo, :isDemo
|
135
|
-
|
136
|
-
#
|
137
|
-
# Converts status to human-readable format.
|
138
|
-
# @return [Symbol]
|
139
|
-
#
|
140
|
-
def status
|
141
|
-
STATUSES.invert[@status]
|
142
|
-
end
|
143
|
-
|
144
|
-
#
|
145
|
-
# Changed in release 1.5.8
|
146
|
-
#
|
147
|
-
# Adds recipient to envelope.
|
148
|
-
#
|
149
|
-
# @example
|
150
|
-
# roles = GroupDocs::Signature::Role.get!
|
151
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
152
|
-
# recipient = GroupDocs::Signature::Recipient.new
|
153
|
-
# recipient.email = 'john@smith.com'
|
154
|
-
# recipient.first_name = 'John'
|
155
|
-
# recipient.last_name = 'Smith'
|
156
|
-
# recipient.role_id = roles.detect { |role| role.name == "Signer" }.id
|
157
|
-
# envelope.add_recipient! recipient
|
158
|
-
#
|
159
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
160
|
-
# @param [Hash] access Access credentials
|
161
|
-
# @option access [String] :client_id
|
162
|
-
# @option access [String] :private_key
|
163
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
164
|
-
#
|
165
|
-
def add_recipient!(recipient, access = {})
|
166
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
167
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
168
|
-
|
169
|
-
api = Api::Request.new do |request|
|
170
|
-
request[:access] = access
|
171
|
-
request[:method] = :POST
|
172
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient"
|
173
|
-
end
|
174
|
-
api.add_params(:email => recipient.email,
|
175
|
-
:firstname => recipient.first_name,
|
176
|
-
:lastname => recipient.last_name,
|
177
|
-
:role => recipient.role_id,
|
178
|
-
:order => recipient.order)
|
179
|
-
json = api.execute!
|
180
|
-
Signature::Recipient.new(json[:recipient])
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
#
|
185
|
-
# Modify recipient of envelope.
|
186
|
-
#
|
187
|
-
# @example
|
188
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
189
|
-
# recipient = envelope.recipients!.first
|
190
|
-
# recipient.first_name = 'Johnny'
|
191
|
-
# envelope.modify_recipient! recipient
|
192
|
-
#
|
193
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
194
|
-
# @param [Hash] access Access credentials
|
195
|
-
# @option access [String] :client_id
|
196
|
-
# @option access [String] :private_key
|
197
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
198
|
-
#
|
199
|
-
def modify_recipient!(recipient, access = {})
|
200
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
201
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
202
|
-
|
203
|
-
api = Api::Request.new do |request|
|
204
|
-
request[:access] = access
|
205
|
-
request[:method] = :PUT
|
206
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}"
|
207
|
-
end
|
208
|
-
api.add_params(:email => recipient.email,
|
209
|
-
:firstname => recipient.first_name,
|
210
|
-
:lastname => recipient.last_name,
|
211
|
-
:role => recipient.role_id,
|
212
|
-
:order => recipient.order)
|
213
|
-
api.execute!
|
214
|
-
end
|
215
|
-
|
216
|
-
#
|
217
|
-
# Delegates recipient to another one.
|
218
|
-
#
|
219
|
-
# @example
|
220
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
221
|
-
# old = envelope.recipients!.first
|
222
|
-
# old.first_name = 'Johnny'
|
223
|
-
# new = GroupDocs::Signature::Recipient.new
|
224
|
-
# new.email = 'john@smith.com'
|
225
|
-
# new.first_name = 'John'
|
226
|
-
# new.last_name = 'Smith'
|
227
|
-
# envelope.delegate_recipient! old, new
|
228
|
-
#
|
229
|
-
# @param [GroupDocs::Signature::Recipient] old
|
230
|
-
# @param [GroupDocs::Signature::Recipient] new
|
231
|
-
# @param [Hash] access Access credentials
|
232
|
-
# @option access [String] :client_id
|
233
|
-
# @option access [String] :private_key
|
234
|
-
# @raise [ArgumentError] if old recipient is not GroupDocs::Signature::Recipient
|
235
|
-
# @raise [ArgumentError] if new recipient is not GroupDocs::Signature::Recipient
|
236
|
-
#
|
237
|
-
def delegate_recipient!(old, new, access = {})
|
238
|
-
old.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
239
|
-
"Old recipient should be GroupDocs::Signature::Recipient object, received: #{old.inspect}"
|
240
|
-
new.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
241
|
-
"New recipient should be GroupDocs::Signature::Recipient object, received: #{new.inspect}"
|
242
|
-
|
243
|
-
api = Api::Request.new do |request|
|
244
|
-
request[:access] = access
|
245
|
-
request[:method] = :POST
|
246
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{old.id}/delegate"
|
247
|
-
end
|
248
|
-
api.add_params(:email => new.email,
|
249
|
-
:firstname => new.first_name,
|
250
|
-
:lastname => new.last_name)
|
251
|
-
api.execute!
|
252
|
-
end
|
253
|
-
|
254
|
-
#
|
255
|
-
# Fills field with value.
|
256
|
-
#
|
257
|
-
# Value differs depending on field type. See examples below.
|
258
|
-
#
|
259
|
-
# @example Fill single line field
|
260
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
261
|
-
# document = envelope.documents!.first
|
262
|
-
# recipient = envelope.recipients!.first
|
263
|
-
# field = envelope.fields!(document, recipient).first
|
264
|
-
# envelope.fill_field! "my_data", field, document, recipient
|
265
|
-
#
|
266
|
-
# @example Fill signature field
|
267
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
268
|
-
# document = envelope.documents!.first
|
269
|
-
# recipient = envelope.recipients!.first
|
270
|
-
# field = envelope.fields!(document, recipient).first
|
271
|
-
# signature = GroupDocs::Signature.get!.first
|
272
|
-
# envelope.fill_field! signature, field, document, recipient
|
273
|
-
#
|
274
|
-
# @example Fill checkbox field
|
275
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
276
|
-
# document = envelope.documents!.first
|
277
|
-
# recipient = envelope.recipients!.first
|
278
|
-
# field = envelope.fields!(document, recipient).first
|
279
|
-
# envelope.fill_field! false, field, document, recipient
|
280
|
-
#
|
281
|
-
# @param [String, Boolean, GroupDocs::Signature] value
|
282
|
-
# @param [GroupDocs::Signature::Field] field
|
283
|
-
# @param [GroupDocs::Document] document
|
284
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
285
|
-
# @param [Hash] options
|
286
|
-
# @option options [Boolean] :public Defaults to false
|
287
|
-
# @param [Hash] access Access credentials
|
288
|
-
# @option access [String] :client_id
|
289
|
-
# @option access [String] :private_key
|
290
|
-
# @return [GroupDocs::Signature::Field] filled field
|
291
|
-
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
292
|
-
# @raise [ArgumentError] if document is not GroupDocs::Document
|
293
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
294
|
-
#
|
295
|
-
def fill_field!(value, field, document, recipient, options = {}, access = {})
|
296
|
-
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
297
|
-
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
298
|
-
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
299
|
-
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
300
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
301
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
302
|
-
|
303
|
-
client_id = client_id(options[:public])
|
304
|
-
api = Api::Request.new do |request|
|
305
|
-
request[:access] = access
|
306
|
-
request[:method] = :PUT
|
307
|
-
request[:path] = "/signature/#{client_id}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/field/#{field.id}"
|
308
|
-
end
|
309
|
-
|
310
|
-
type = field.field_type
|
311
|
-
if type == :signature && value.is_a?(GroupDocs::Signature)
|
312
|
-
api.add_params(:signatureId => value.id)
|
313
|
-
else
|
314
|
-
if type == :checkbox
|
315
|
-
value = (value ? 'on' : 'off')
|
316
|
-
end
|
317
|
-
api.options[:request_body] = value
|
318
|
-
api.options[:plain] = true
|
319
|
-
end
|
320
|
-
|
321
|
-
json = api.execute!
|
322
|
-
Signature::Field.new(json[:field])
|
323
|
-
end
|
324
|
-
|
325
|
-
#
|
326
|
-
# Changed in release 1.7.0
|
327
|
-
#
|
328
|
-
# Signs envelope.
|
329
|
-
#
|
330
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
331
|
-
# @param [Hash] settings
|
332
|
-
# @option settings [String] :authData (required)
|
333
|
-
# @option settings [String] :comment (required)
|
334
|
-
# @param [Hash] options
|
335
|
-
# @option options [Boolean] :public Defaults to false
|
336
|
-
# @param [Hash] access Access credentials
|
337
|
-
# @option access [String] :client_id
|
338
|
-
# @option access [String] :private_key
|
339
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
340
|
-
#
|
341
|
-
def sign!(recipient, settings = {}, options = {}, access = {})
|
342
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
343
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
344
|
-
|
345
|
-
client_id = client_id(options[:public])
|
346
|
-
Api::Request.new do |request|
|
347
|
-
request[:access] = access
|
348
|
-
request[:method] = :PUT
|
349
|
-
request[:path] = "/signature/#{client_id}/envelopes/#{id}/recipient/#{recipient.id}/sign"
|
350
|
-
request[:request_body] = settings
|
351
|
-
end.execute!
|
352
|
-
end
|
353
|
-
|
354
|
-
#
|
355
|
-
# Declines envelope.
|
356
|
-
#
|
357
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
358
|
-
# @param [Hash] access Access credentials
|
359
|
-
# @option access [String] :client_id
|
360
|
-
# @option access [String] :private_key
|
361
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
362
|
-
#
|
363
|
-
def decline!(recipient, access = {})
|
364
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
365
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
366
|
-
|
367
|
-
Api::Request.new do |request|
|
368
|
-
request[:access] = access
|
369
|
-
request[:method] = :PUT
|
370
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}/decline"
|
371
|
-
end.execute!
|
372
|
-
end
|
373
|
-
|
374
|
-
#
|
375
|
-
# Downloads signed documents to given path.
|
376
|
-
# If there is only one file in envelope, it's saved as PDF.
|
377
|
-
# If there are two or more files in envelope, it's saved as ZIP.
|
378
|
-
#
|
379
|
-
# @param [String] path Directory to download file to
|
380
|
-
# @param [Hash] access Access credentials
|
381
|
-
# @option access [String] :client_id
|
382
|
-
# @option access [String] :private_key
|
383
|
-
# @return [String] path to file
|
384
|
-
#
|
385
|
-
def signed_documents!(path, access = {})
|
386
|
-
response = Api::Request.new do |request|
|
387
|
-
request[:access] = access
|
388
|
-
request[:method] = :DOWNLOAD
|
389
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/get"
|
390
|
-
end.execute!
|
391
|
-
|
392
|
-
filepath = "#{path}/#{name}."
|
393
|
-
if documents!.size == 1
|
394
|
-
filepath << 'pdf'
|
395
|
-
else
|
396
|
-
filepath << 'zip'
|
397
|
-
end
|
398
|
-
|
399
|
-
Object::File.open(filepath, 'wb') do |file|
|
400
|
-
file.write(response)
|
401
|
-
end
|
402
|
-
|
403
|
-
filepath
|
404
|
-
end
|
405
|
-
|
406
|
-
#
|
407
|
-
# Changed in release 1.5.8
|
408
|
-
#
|
409
|
-
# Downloads signed document to given path.
|
410
|
-
#
|
411
|
-
# @param [GroupDocs::Document] document Signed document
|
412
|
-
# @param [String] path Directory to download file to
|
413
|
-
# @param [Hash] access Access credentials
|
414
|
-
# @option access [String] :client_id
|
415
|
-
# @option access [String] :private_key
|
416
|
-
# @return [String] path to file
|
417
|
-
#
|
418
|
-
def signed_document!(document, path, access = {})
|
419
|
-
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
420
|
-
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
421
|
-
|
422
|
-
response = Api::Request.new do |request|
|
423
|
-
request[:access] = access
|
424
|
-
request[:method] = :DOWNLOAD
|
425
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}"
|
426
|
-
end.execute!
|
427
|
-
|
428
|
-
document.file.name ? filepath = "#{path}/#{document.file.name}" : filepath = "#{path}/#{name}.pdf"
|
429
|
-
|
430
|
-
Object::File.open(filepath, 'wb') do |file|
|
431
|
-
file.write(response)
|
432
|
-
end
|
433
|
-
|
434
|
-
filepath
|
435
|
-
end
|
436
|
-
|
437
|
-
#
|
438
|
-
# Returns a list of audit logs.
|
439
|
-
#
|
440
|
-
# @param [Hash] access Access credentials
|
441
|
-
# @option access [String] :client_id
|
442
|
-
# @option access [String] :private_key
|
443
|
-
# @return [Array<GroupDocs::Signature::Envelope::Log>]
|
444
|
-
#
|
445
|
-
def logs!(access = {})
|
446
|
-
json = Api::Request.new do |request|
|
447
|
-
request[:access] = access
|
448
|
-
request[:method] = :GET
|
449
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/logs"
|
450
|
-
end.execute!
|
451
|
-
|
452
|
-
json[:logs].map do |log|
|
453
|
-
Log.new(log)
|
454
|
-
end
|
455
|
-
end
|
456
|
-
|
457
|
-
#
|
458
|
-
# Sends envelope.
|
459
|
-
#
|
460
|
-
# @param [Hash] webhook URL to be hooked after envelope is completed
|
461
|
-
# @option webhook [String] :callbackUrl
|
462
|
-
# @param [Hash] access Access credentials
|
463
|
-
# @option access [String] :client_id
|
464
|
-
# @option access [String] :private_key
|
465
|
-
#
|
466
|
-
def send!(webhook = {}, access = {})
|
467
|
-
Api::Request.new do |request|
|
468
|
-
request[:access] = access
|
469
|
-
request[:method] = :PUT
|
470
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/send"
|
471
|
-
request[:request_body] = webhook
|
472
|
-
end.execute!
|
473
|
-
end
|
474
|
-
|
475
|
-
#
|
476
|
-
# Archives completed envelope.
|
477
|
-
#
|
478
|
-
# @param [Hash] access Access credentials
|
479
|
-
# @option access [String] :client_id
|
480
|
-
# @option access [String] :private_key
|
481
|
-
#
|
482
|
-
def archive!(access = {})
|
483
|
-
Api::Request.new do |request|
|
484
|
-
request[:access] = access
|
485
|
-
request[:method] = :PUT
|
486
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/archive"
|
487
|
-
end.execute!
|
488
|
-
end
|
489
|
-
|
490
|
-
#
|
491
|
-
# Restarts expired envelope.
|
492
|
-
#
|
493
|
-
# @param [Hash] access Access credentials
|
494
|
-
# @option access [String] :client_id
|
495
|
-
# @option access [String] :private_key
|
496
|
-
#
|
497
|
-
def restart!(access = {})
|
498
|
-
Api::Request.new do |request|
|
499
|
-
request[:access] = access
|
500
|
-
request[:method] = :PUT
|
501
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/restart"
|
502
|
-
end.execute!
|
503
|
-
end
|
504
|
-
|
505
|
-
#
|
506
|
-
# Get signed envelope document.
|
507
|
-
#
|
508
|
-
# @example
|
509
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
510
|
-
# document = GroupDocs::Storage::Folder.list!.last.to_document
|
511
|
-
# envelope.add_document! document
|
512
|
-
#
|
513
|
-
# @param [GroupDocs::Document] document
|
514
|
-
# @param [Hash] access Access credentials
|
515
|
-
# @option access [String] :client_id
|
516
|
-
# @option access [String] :private_key
|
517
|
-
# @raise [ArgumentError] if document is not GroupDocs::Document
|
518
|
-
#
|
519
|
-
def get_envelope!(path, document, access = {})
|
520
|
-
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
521
|
-
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
522
|
-
|
523
|
-
response = Api::Request.new do |request|
|
524
|
-
request[:access] = access
|
525
|
-
request[:method] = :GET
|
526
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}"
|
527
|
-
end.execute!
|
528
|
-
|
529
|
-
filepath = "#{path}/#{name}."
|
530
|
-
|
531
|
-
if documents!.size == 1
|
532
|
-
filepath << 'pdf'
|
533
|
-
else
|
534
|
-
filepath << 'zip'
|
535
|
-
end
|
536
|
-
|
537
|
-
Object::File.open(filepath, 'wb') do |file|
|
538
|
-
file.write(response)
|
539
|
-
end
|
540
|
-
|
541
|
-
filepath
|
542
|
-
end
|
543
|
-
|
544
|
-
#
|
545
|
-
# Cancel envelope.
|
546
|
-
#
|
547
|
-
# @param [Hash] access Access credentials
|
548
|
-
# @option access [String] :client_id
|
549
|
-
# @option access [String] :private_key
|
550
|
-
#
|
551
|
-
def cancel!( access = {})
|
552
|
-
Api::Request.new do |request|
|
553
|
-
request[:access] = access
|
554
|
-
request[:method] = :PUT
|
555
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/cancel"
|
556
|
-
end.execute!
|
557
|
-
end
|
558
|
-
|
559
|
-
#
|
560
|
-
# Retry sign envelope.
|
561
|
-
#
|
562
|
-
# @param [Hash] access Access credentials
|
563
|
-
# @option access [String] :client_id
|
564
|
-
# @option access [String] :private_key
|
565
|
-
#
|
566
|
-
def retry!(access = {})
|
567
|
-
Api::Request.new do |request|
|
568
|
-
request[:access] = access
|
569
|
-
request[:method] = :PUT
|
570
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/retry"
|
571
|
-
end.execute!
|
572
|
-
end
|
573
|
-
|
574
|
-
#
|
575
|
-
# Update envelope.
|
576
|
-
#
|
577
|
-
# @param [Hash] access Access credentials
|
578
|
-
# @option access [String] :client_id
|
579
|
-
# @option access [String] :private_key
|
580
|
-
# @return [Array]
|
581
|
-
#
|
582
|
-
def update_envelope!(template, access = {})
|
583
|
-
json = Api::Request.new do |request|
|
584
|
-
request[:access] = access
|
585
|
-
request[:method] = :POST
|
586
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/templates/#{template}"
|
587
|
-
end.execute!
|
588
|
-
|
589
|
-
json[:envelope]
|
590
|
-
|
591
|
-
end
|
592
|
-
|
593
|
-
#
|
594
|
-
# Modify signature envelope field location.
|
595
|
-
#
|
596
|
-
# @example Modify field location in envelope
|
597
|
-
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
598
|
-
# document = envelope.documents!.first
|
599
|
-
# recipient = envelope.recipients!.first
|
600
|
-
# field = envelope.fields!(document, recipient).first
|
601
|
-
# location = field.locations.first
|
602
|
-
# envelope.modify_field_location! location, field, document, recipient
|
603
|
-
#
|
604
|
-
# @param [GroupDocs::Signature::Field::Location] location
|
605
|
-
# @param [GroupDocs::Signature::Field] field
|
606
|
-
# @param [GroupDocs::Document] document
|
607
|
-
# @param [GroupDocs::Signature::Recipient] recipient
|
608
|
-
# @param [Integer] order Location order
|
609
|
-
# @param [Hash] access Access credentials
|
610
|
-
# @option access [String] :client_id
|
611
|
-
# @option access [String] :private_key
|
612
|
-
# @raise [ArgumentError] if location is not GroupDocs::Signature::Field::Location
|
613
|
-
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
614
|
-
# @raise [ArgumentError] if document is not GroupDocs::Document
|
615
|
-
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
616
|
-
#
|
617
|
-
def modify_field_location!(location, field, document, recipient, order, access = {})
|
618
|
-
location.is_a?(GroupDocs::Signature::Field::Location) or raise ArgumentError,
|
619
|
-
"Location should be GroupDocs::Signature::Field::Location object, received: #{location.inspect}"
|
620
|
-
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
621
|
-
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
622
|
-
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
623
|
-
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
624
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
625
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
626
|
-
|
627
|
-
api = Api::Request.new do |request|
|
628
|
-
request[:access] = access
|
629
|
-
request[:method] = :PUT
|
630
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/fields/#{field.id}/locations/#{location.id}"
|
631
|
-
end
|
632
|
-
api.add_params(:order => order)
|
633
|
-
api.execute!
|
634
|
-
end
|
635
|
-
|
636
|
-
#
|
637
|
-
# Changed in release 1.5.8
|
638
|
-
#
|
639
|
-
# Get signature envelope.
|
640
|
-
#
|
641
|
-
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
642
|
-
# @param [Hash] access Access credentials
|
643
|
-
# @option access [String] :client_id
|
644
|
-
# @option access [String] :private_key
|
645
|
-
# @return [Array]
|
646
|
-
#
|
647
|
-
def public_get!(recipient, access = {})
|
648
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
649
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
650
|
-
|
651
|
-
json = Api::Request.new do |request|
|
652
|
-
request[:access] = access
|
653
|
-
request[:method] = :GET
|
654
|
-
request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}"
|
655
|
-
end.execute!
|
656
|
-
|
657
|
-
Signature::Envelope.new(json[:envelope])
|
658
|
-
end
|
659
|
-
|
660
|
-
#
|
661
|
-
# Changed in release 1.5.8
|
662
|
-
#
|
663
|
-
# Public downloads signed documents to given path.
|
664
|
-
#
|
665
|
-
# If there is only one file in envelope, it's saved as PDF.
|
666
|
-
# If there are two or more files in envelope, it's saved as ZIP.
|
667
|
-
#
|
668
|
-
# @param [String] path Directory to download file to
|
669
|
-
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
670
|
-
# @param [Hash] access Access credentials
|
671
|
-
# @option access [String] :client_id
|
672
|
-
# @option access [String] :private_key
|
673
|
-
# @return [Array]
|
674
|
-
#
|
675
|
-
def public_signed_documents!(path, recipient, access = {})
|
676
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
677
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
678
|
-
json = Api::Request.new do |request|
|
679
|
-
request[:access] = access
|
680
|
-
request[:method] = :DOWNLOAD
|
681
|
-
request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}/documents/get"
|
682
|
-
end.execute!
|
683
|
-
filepath = "#{path}/#{name}."
|
684
|
-
if documents!.size == 1
|
685
|
-
filepath << 'pdf'
|
686
|
-
else
|
687
|
-
filepath << 'zip'
|
688
|
-
end
|
689
|
-
|
690
|
-
Object::File.open(filepath, 'wb') do |file|
|
691
|
-
file.write(json)
|
692
|
-
end
|
693
|
-
|
694
|
-
filepath
|
695
|
-
end
|
696
|
-
|
697
|
-
|
698
|
-
#
|
699
|
-
# Changed in release 1.5.8
|
700
|
-
#
|
701
|
-
#
|
702
|
-
# Get signed envelope field data.
|
703
|
-
#
|
704
|
-
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
705
|
-
# @param [GroupDocs::Signature::Field] field Field GUID
|
706
|
-
# @param [Hash] access Access credentials
|
707
|
-
# @option access [String] :client_id
|
708
|
-
# @option access [String] :private_key
|
709
|
-
# @return [Array]
|
710
|
-
#
|
711
|
-
def date!(recipient, field, access = {})
|
712
|
-
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
713
|
-
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
714
|
-
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
715
|
-
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
716
|
-
|
717
|
-
Api::Request.new do |request|
|
718
|
-
request[:access] = access
|
719
|
-
request[:method] = :GET
|
720
|
-
request[:path] = "/signature/public/envelopes/#{id}/fields/recipient/#{recipient.id}/field/#{field.id}"
|
721
|
-
end.execute!
|
722
|
-
end
|
723
|
-
|
724
|
-
|
725
|
-
#
|
726
|
-
# added in release 1.6.0
|
727
|
-
#
|
728
|
-
#
|
729
|
-
# Resend envelope email notification.
|
730
|
-
#
|
731
|
-
# @param [Hash] access Access credentials
|
732
|
-
# @option access [String] :client_id
|
733
|
-
# @option access [String] :private_key
|
734
|
-
#
|
735
|
-
def resend!(access = {})
|
736
|
-
Api::Request.new do |request|
|
737
|
-
request[:access] = access
|
738
|
-
request[:method] = :PUT
|
739
|
-
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/resend-notification"
|
740
|
-
end.execute!
|
741
|
-
end
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
end # Signature::Envelope
|
747
|
-
end # GroupDocs
|
1
|
+
module GroupDocs
|
2
|
+
class Signature::Envelope < Api::Entity
|
3
|
+
|
4
|
+
require 'groupdocs/signature/envelope/log'
|
5
|
+
|
6
|
+
STATUSES = {
|
7
|
+
:draft => -1,
|
8
|
+
:annotation => 0,
|
9
|
+
:in_progress => 1,
|
10
|
+
:expired => 2,
|
11
|
+
:canceled => 3,
|
12
|
+
:failed => 4,
|
13
|
+
:completed => 5,
|
14
|
+
:archived => 6,
|
15
|
+
:scheduled => 99,
|
16
|
+
}
|
17
|
+
|
18
|
+
include Api::Helpers::SignaturePublic
|
19
|
+
include Signature::DocumentMethods
|
20
|
+
include Signature::EntityFields
|
21
|
+
include Signature::EntityMethods
|
22
|
+
include Signature::FieldMethods
|
23
|
+
include Signature::RecipientMethods
|
24
|
+
extend Signature::ResourceMethods
|
25
|
+
|
26
|
+
#
|
27
|
+
# Changed in release 1.7.0
|
28
|
+
#
|
29
|
+
#
|
30
|
+
# Returns a list of all envelopes.
|
31
|
+
#
|
32
|
+
# @param [Hash] options Hash of options
|
33
|
+
# @option options [Integer] :page Page to start with
|
34
|
+
# @option options [Integer] :records How many items to list
|
35
|
+
# @option options [Integer] :status_id Filter envelopes by status identifier
|
36
|
+
# @option options [String] :document Filter envelopes by document GUID
|
37
|
+
# @option options [String] :recipient Filter envelopes by recipient email
|
38
|
+
# @option options [String] :date Filter envelopes by date
|
39
|
+
# @option options [String] :name Filter envelopes by name
|
40
|
+
# @option options [String] :tag Filter envelopes by tag
|
41
|
+
# @param [Hash] access Access credentials
|
42
|
+
# @option access [String] :client_id
|
43
|
+
# @option access [String] :private_key
|
44
|
+
# @return [Array<GroupDocs::Signature::Envelope>]
|
45
|
+
#
|
46
|
+
def self.all!(options = {}, access = {})
|
47
|
+
status_id = options.delete(:status_id)
|
48
|
+
options[:statusId] = status_id if status_id
|
49
|
+
|
50
|
+
api = Api::Request.new do |request|
|
51
|
+
request[:access] = access
|
52
|
+
request[:method] = :GET
|
53
|
+
request[:path] = '/signature/{{client_id}}/envelopes'
|
54
|
+
end
|
55
|
+
api.add_params(options)
|
56
|
+
json = api.execute!
|
57
|
+
|
58
|
+
json[:envelopes].map do |envelope|
|
59
|
+
new(envelope)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Returns a list of all envelopes where user is recipient.
|
65
|
+
#
|
66
|
+
# @param [Hash] options Hash of options
|
67
|
+
# @option options [Integer] :page Page to start with
|
68
|
+
# @option options [Integer] :records How many items to list
|
69
|
+
# @option options [Integer] :statusId Filter by status identifier
|
70
|
+
# @param [Hash] access Access credentials
|
71
|
+
# @option access [String] :client_id
|
72
|
+
# @option access [String] :private_key
|
73
|
+
# @return [Array<GroupDocs::Signature::Envelope>]
|
74
|
+
#
|
75
|
+
def self.for_me!(options = {}, access = {})
|
76
|
+
api = Api::Request.new do |request|
|
77
|
+
request[:access] = access
|
78
|
+
request[:method] = :GET
|
79
|
+
request[:path] = '/signature/{{client_id}}/envelopes/recipient'
|
80
|
+
end
|
81
|
+
api.add_params(options)
|
82
|
+
json = api.execute!
|
83
|
+
|
84
|
+
json[:envelopes].map do |envelope|
|
85
|
+
new(envelope)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# @attr [String] creationDateTime
|
90
|
+
attr_accessor :creationDateTime
|
91
|
+
# @attr [Symbol] status
|
92
|
+
attr_accessor :status
|
93
|
+
# @attr [String] statusDateTime
|
94
|
+
attr_accessor :statusDateTime
|
95
|
+
# @attr [Integer] envelopeExpireTime
|
96
|
+
attr_accessor :envelopeExpireTime
|
97
|
+
# @attr [Boolean] isDemo
|
98
|
+
attr_accessor :isDemo
|
99
|
+
|
100
|
+
# added in release 1.7.0
|
101
|
+
# @attr [String] updatedDateTime
|
102
|
+
attr_accessor :updatedDateTime
|
103
|
+
# @attr [Boolean] attachSignedDocument
|
104
|
+
attr_accessor :attachSignedDocument
|
105
|
+
# @attr [Boolean] includeViewLink
|
106
|
+
attr_accessor :includeViewLink
|
107
|
+
# @attr [Boolean] canBeCommented
|
108
|
+
attr_accessor :canBeCommented
|
109
|
+
# @attr [Boolean] inPersonSign
|
110
|
+
attr_accessor :inPersonSign
|
111
|
+
# @attr [String] ownerName
|
112
|
+
attr_accessor :ownerName
|
113
|
+
# @attr [Boolean] enableTypedSignature
|
114
|
+
attr_accessor :enableTypedSignature
|
115
|
+
# @attr [Boolean] enableUploadedSignature
|
116
|
+
attr_accessor :enableUploadedSignature
|
117
|
+
# @attr [Boolean] requireUserAuthForSign
|
118
|
+
attr_accessor :requireUserAuthForSign
|
119
|
+
# @attr [Boolean] requestUserAuthByPhoto
|
120
|
+
attr_accessor :requestUserAuthByPhoto
|
121
|
+
# @attr [Boolean] showRecipientCommentInSignedDocument
|
122
|
+
attr_accessor :showRecipientCommentInSignedDocument
|
123
|
+
# @attr [String] tags
|
124
|
+
attr_accessor :tags
|
125
|
+
|
126
|
+
# added in release 1.9.0
|
127
|
+
# @attr [Boolean] lockDuringSign
|
128
|
+
attr_accessor :lockDuringSign
|
129
|
+
|
130
|
+
# Human-readable accessors
|
131
|
+
alias_accessor :creation_date_time, :creationDateTime
|
132
|
+
alias_accessor :status_date_time, :statusDateTime
|
133
|
+
alias_accessor :envelope_expire_time, :envelopeExpireTime
|
134
|
+
alias_accessor :is_demo, :isDemo
|
135
|
+
|
136
|
+
#
|
137
|
+
# Converts status to human-readable format.
|
138
|
+
# @return [Symbol]
|
139
|
+
#
|
140
|
+
def status
|
141
|
+
STATUSES.invert[@status]
|
142
|
+
end
|
143
|
+
|
144
|
+
#
|
145
|
+
# Changed in release 1.5.8
|
146
|
+
#
|
147
|
+
# Adds recipient to envelope.
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# roles = GroupDocs::Signature::Role.get!
|
151
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
152
|
+
# recipient = GroupDocs::Signature::Recipient.new
|
153
|
+
# recipient.email = 'john@smith.com'
|
154
|
+
# recipient.first_name = 'John'
|
155
|
+
# recipient.last_name = 'Smith'
|
156
|
+
# recipient.role_id = roles.detect { |role| role.name == "Signer" }.id
|
157
|
+
# envelope.add_recipient! recipient
|
158
|
+
#
|
159
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
160
|
+
# @param [Hash] access Access credentials
|
161
|
+
# @option access [String] :client_id
|
162
|
+
# @option access [String] :private_key
|
163
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
164
|
+
#
|
165
|
+
def add_recipient!(recipient, access = {})
|
166
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
167
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
168
|
+
|
169
|
+
api = Api::Request.new do |request|
|
170
|
+
request[:access] = access
|
171
|
+
request[:method] = :POST
|
172
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient"
|
173
|
+
end
|
174
|
+
api.add_params(:email => recipient.email,
|
175
|
+
:firstname => recipient.first_name,
|
176
|
+
:lastname => recipient.last_name,
|
177
|
+
:role => recipient.role_id,
|
178
|
+
:order => recipient.order)
|
179
|
+
json = api.execute!
|
180
|
+
Signature::Recipient.new(json[:recipient])
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
#
|
185
|
+
# Modify recipient of envelope.
|
186
|
+
#
|
187
|
+
# @example
|
188
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
189
|
+
# recipient = envelope.recipients!.first
|
190
|
+
# recipient.first_name = 'Johnny'
|
191
|
+
# envelope.modify_recipient! recipient
|
192
|
+
#
|
193
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
194
|
+
# @param [Hash] access Access credentials
|
195
|
+
# @option access [String] :client_id
|
196
|
+
# @option access [String] :private_key
|
197
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
198
|
+
#
|
199
|
+
def modify_recipient!(recipient, access = {})
|
200
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
201
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
202
|
+
|
203
|
+
api = Api::Request.new do |request|
|
204
|
+
request[:access] = access
|
205
|
+
request[:method] = :PUT
|
206
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}"
|
207
|
+
end
|
208
|
+
api.add_params(:email => recipient.email,
|
209
|
+
:firstname => recipient.first_name,
|
210
|
+
:lastname => recipient.last_name,
|
211
|
+
:role => recipient.role_id,
|
212
|
+
:order => recipient.order)
|
213
|
+
api.execute!
|
214
|
+
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# Delegates recipient to another one.
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
221
|
+
# old = envelope.recipients!.first
|
222
|
+
# old.first_name = 'Johnny'
|
223
|
+
# new = GroupDocs::Signature::Recipient.new
|
224
|
+
# new.email = 'john@smith.com'
|
225
|
+
# new.first_name = 'John'
|
226
|
+
# new.last_name = 'Smith'
|
227
|
+
# envelope.delegate_recipient! old, new
|
228
|
+
#
|
229
|
+
# @param [GroupDocs::Signature::Recipient] old
|
230
|
+
# @param [GroupDocs::Signature::Recipient] new
|
231
|
+
# @param [Hash] access Access credentials
|
232
|
+
# @option access [String] :client_id
|
233
|
+
# @option access [String] :private_key
|
234
|
+
# @raise [ArgumentError] if old recipient is not GroupDocs::Signature::Recipient
|
235
|
+
# @raise [ArgumentError] if new recipient is not GroupDocs::Signature::Recipient
|
236
|
+
#
|
237
|
+
def delegate_recipient!(old, new, access = {})
|
238
|
+
old.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
239
|
+
"Old recipient should be GroupDocs::Signature::Recipient object, received: #{old.inspect}"
|
240
|
+
new.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
241
|
+
"New recipient should be GroupDocs::Signature::Recipient object, received: #{new.inspect}"
|
242
|
+
|
243
|
+
api = Api::Request.new do |request|
|
244
|
+
request[:access] = access
|
245
|
+
request[:method] = :POST
|
246
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{old.id}/delegate"
|
247
|
+
end
|
248
|
+
api.add_params(:email => new.email,
|
249
|
+
:firstname => new.first_name,
|
250
|
+
:lastname => new.last_name)
|
251
|
+
api.execute!
|
252
|
+
end
|
253
|
+
|
254
|
+
#
|
255
|
+
# Fills field with value.
|
256
|
+
#
|
257
|
+
# Value differs depending on field type. See examples below.
|
258
|
+
#
|
259
|
+
# @example Fill single line field
|
260
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
261
|
+
# document = envelope.documents!.first
|
262
|
+
# recipient = envelope.recipients!.first
|
263
|
+
# field = envelope.fields!(document, recipient).first
|
264
|
+
# envelope.fill_field! "my_data", field, document, recipient
|
265
|
+
#
|
266
|
+
# @example Fill signature field
|
267
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
268
|
+
# document = envelope.documents!.first
|
269
|
+
# recipient = envelope.recipients!.first
|
270
|
+
# field = envelope.fields!(document, recipient).first
|
271
|
+
# signature = GroupDocs::Signature.get!.first
|
272
|
+
# envelope.fill_field! signature, field, document, recipient
|
273
|
+
#
|
274
|
+
# @example Fill checkbox field
|
275
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
276
|
+
# document = envelope.documents!.first
|
277
|
+
# recipient = envelope.recipients!.first
|
278
|
+
# field = envelope.fields!(document, recipient).first
|
279
|
+
# envelope.fill_field! false, field, document, recipient
|
280
|
+
#
|
281
|
+
# @param [String, Boolean, GroupDocs::Signature] value
|
282
|
+
# @param [GroupDocs::Signature::Field] field
|
283
|
+
# @param [GroupDocs::Document] document
|
284
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
285
|
+
# @param [Hash] options
|
286
|
+
# @option options [Boolean] :public Defaults to false
|
287
|
+
# @param [Hash] access Access credentials
|
288
|
+
# @option access [String] :client_id
|
289
|
+
# @option access [String] :private_key
|
290
|
+
# @return [GroupDocs::Signature::Field] filled field
|
291
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
292
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
293
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
294
|
+
#
|
295
|
+
def fill_field!(value, field, document, recipient, options = {}, access = {})
|
296
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
297
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
298
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
299
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
300
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
301
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
302
|
+
|
303
|
+
client_id = client_id(options[:public])
|
304
|
+
api = Api::Request.new do |request|
|
305
|
+
request[:access] = access
|
306
|
+
request[:method] = :PUT
|
307
|
+
request[:path] = "/signature/#{client_id}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/field/#{field.id}"
|
308
|
+
end
|
309
|
+
|
310
|
+
type = field.field_type
|
311
|
+
if type == :signature && value.is_a?(GroupDocs::Signature)
|
312
|
+
api.add_params(:signatureId => value.id)
|
313
|
+
else
|
314
|
+
if type == :checkbox
|
315
|
+
value = (value ? 'on' : 'off')
|
316
|
+
end
|
317
|
+
api.options[:request_body] = value
|
318
|
+
api.options[:plain] = true
|
319
|
+
end
|
320
|
+
|
321
|
+
json = api.execute!
|
322
|
+
Signature::Field.new(json[:field])
|
323
|
+
end
|
324
|
+
|
325
|
+
#
|
326
|
+
# Changed in release 1.7.0
|
327
|
+
#
|
328
|
+
# Signs envelope.
|
329
|
+
#
|
330
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
331
|
+
# @param [Hash] settings
|
332
|
+
# @option settings [String] :authData (required)
|
333
|
+
# @option settings [String] :comment (required)
|
334
|
+
# @param [Hash] options
|
335
|
+
# @option options [Boolean] :public Defaults to false
|
336
|
+
# @param [Hash] access Access credentials
|
337
|
+
# @option access [String] :client_id
|
338
|
+
# @option access [String] :private_key
|
339
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
340
|
+
#
|
341
|
+
def sign!(recipient, settings = {}, options = {}, access = {})
|
342
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
343
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
344
|
+
|
345
|
+
client_id = client_id(options[:public])
|
346
|
+
Api::Request.new do |request|
|
347
|
+
request[:access] = access
|
348
|
+
request[:method] = :PUT
|
349
|
+
request[:path] = "/signature/#{client_id}/envelopes/#{id}/recipient/#{recipient.id}/sign"
|
350
|
+
request[:request_body] = settings
|
351
|
+
end.execute!
|
352
|
+
end
|
353
|
+
|
354
|
+
#
|
355
|
+
# Declines envelope.
|
356
|
+
#
|
357
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
358
|
+
# @param [Hash] access Access credentials
|
359
|
+
# @option access [String] :client_id
|
360
|
+
# @option access [String] :private_key
|
361
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
362
|
+
#
|
363
|
+
def decline!(recipient, access = {})
|
364
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
365
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
366
|
+
|
367
|
+
Api::Request.new do |request|
|
368
|
+
request[:access] = access
|
369
|
+
request[:method] = :PUT
|
370
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}/decline"
|
371
|
+
end.execute!
|
372
|
+
end
|
373
|
+
|
374
|
+
#
|
375
|
+
# Downloads signed documents to given path.
|
376
|
+
# If there is only one file in envelope, it's saved as PDF.
|
377
|
+
# If there are two or more files in envelope, it's saved as ZIP.
|
378
|
+
#
|
379
|
+
# @param [String] path Directory to download file to
|
380
|
+
# @param [Hash] access Access credentials
|
381
|
+
# @option access [String] :client_id
|
382
|
+
# @option access [String] :private_key
|
383
|
+
# @return [String] path to file
|
384
|
+
#
|
385
|
+
def signed_documents!(path, access = {})
|
386
|
+
response = Api::Request.new do |request|
|
387
|
+
request[:access] = access
|
388
|
+
request[:method] = :DOWNLOAD
|
389
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/get"
|
390
|
+
end.execute!
|
391
|
+
|
392
|
+
filepath = "#{path}/#{name}."
|
393
|
+
if documents!.size == 1
|
394
|
+
filepath << 'pdf'
|
395
|
+
else
|
396
|
+
filepath << 'zip'
|
397
|
+
end
|
398
|
+
|
399
|
+
Object::File.open(filepath, 'wb') do |file|
|
400
|
+
file.write(response)
|
401
|
+
end
|
402
|
+
|
403
|
+
filepath
|
404
|
+
end
|
405
|
+
|
406
|
+
#
|
407
|
+
# Changed in release 1.5.8
|
408
|
+
#
|
409
|
+
# Downloads signed document to given path.
|
410
|
+
#
|
411
|
+
# @param [GroupDocs::Document] document Signed document
|
412
|
+
# @param [String] path Directory to download file to
|
413
|
+
# @param [Hash] access Access credentials
|
414
|
+
# @option access [String] :client_id
|
415
|
+
# @option access [String] :private_key
|
416
|
+
# @return [String] path to file
|
417
|
+
#
|
418
|
+
def signed_document!(document, path, access = {})
|
419
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
420
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
421
|
+
|
422
|
+
response = Api::Request.new do |request|
|
423
|
+
request[:access] = access
|
424
|
+
request[:method] = :DOWNLOAD
|
425
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}"
|
426
|
+
end.execute!
|
427
|
+
|
428
|
+
document.file.name ? filepath = "#{path}/#{document.file.name}" : filepath = "#{path}/#{name}.pdf"
|
429
|
+
|
430
|
+
Object::File.open(filepath, 'wb') do |file|
|
431
|
+
file.write(response)
|
432
|
+
end
|
433
|
+
|
434
|
+
filepath
|
435
|
+
end
|
436
|
+
|
437
|
+
#
|
438
|
+
# Returns a list of audit logs.
|
439
|
+
#
|
440
|
+
# @param [Hash] access Access credentials
|
441
|
+
# @option access [String] :client_id
|
442
|
+
# @option access [String] :private_key
|
443
|
+
# @return [Array<GroupDocs::Signature::Envelope::Log>]
|
444
|
+
#
|
445
|
+
def logs!(access = {})
|
446
|
+
json = Api::Request.new do |request|
|
447
|
+
request[:access] = access
|
448
|
+
request[:method] = :GET
|
449
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/logs"
|
450
|
+
end.execute!
|
451
|
+
|
452
|
+
json[:logs].map do |log|
|
453
|
+
Log.new(log)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
#
|
458
|
+
# Sends envelope.
|
459
|
+
#
|
460
|
+
# @param [Hash] webhook URL to be hooked after envelope is completed
|
461
|
+
# @option webhook [String] :callbackUrl
|
462
|
+
# @param [Hash] access Access credentials
|
463
|
+
# @option access [String] :client_id
|
464
|
+
# @option access [String] :private_key
|
465
|
+
#
|
466
|
+
def send!(webhook = {}, access = {})
|
467
|
+
Api::Request.new do |request|
|
468
|
+
request[:access] = access
|
469
|
+
request[:method] = :PUT
|
470
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/send"
|
471
|
+
request[:request_body] = webhook
|
472
|
+
end.execute!
|
473
|
+
end
|
474
|
+
|
475
|
+
#
|
476
|
+
# Archives completed envelope.
|
477
|
+
#
|
478
|
+
# @param [Hash] access Access credentials
|
479
|
+
# @option access [String] :client_id
|
480
|
+
# @option access [String] :private_key
|
481
|
+
#
|
482
|
+
def archive!(access = {})
|
483
|
+
Api::Request.new do |request|
|
484
|
+
request[:access] = access
|
485
|
+
request[:method] = :PUT
|
486
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/archive"
|
487
|
+
end.execute!
|
488
|
+
end
|
489
|
+
|
490
|
+
#
|
491
|
+
# Restarts expired envelope.
|
492
|
+
#
|
493
|
+
# @param [Hash] access Access credentials
|
494
|
+
# @option access [String] :client_id
|
495
|
+
# @option access [String] :private_key
|
496
|
+
#
|
497
|
+
def restart!(access = {})
|
498
|
+
Api::Request.new do |request|
|
499
|
+
request[:access] = access
|
500
|
+
request[:method] = :PUT
|
501
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/restart"
|
502
|
+
end.execute!
|
503
|
+
end
|
504
|
+
|
505
|
+
#
|
506
|
+
# Get signed envelope document.
|
507
|
+
#
|
508
|
+
# @example
|
509
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
510
|
+
# document = GroupDocs::Storage::Folder.list!.last.to_document
|
511
|
+
# envelope.add_document! document
|
512
|
+
#
|
513
|
+
# @param [GroupDocs::Document] document
|
514
|
+
# @param [Hash] access Access credentials
|
515
|
+
# @option access [String] :client_id
|
516
|
+
# @option access [String] :private_key
|
517
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
518
|
+
#
|
519
|
+
def get_envelope!(path, document, access = {})
|
520
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
521
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
522
|
+
|
523
|
+
response = Api::Request.new do |request|
|
524
|
+
request[:access] = access
|
525
|
+
request[:method] = :GET
|
526
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}"
|
527
|
+
end.execute!
|
528
|
+
|
529
|
+
filepath = "#{path}/#{name}."
|
530
|
+
|
531
|
+
if documents!.size == 1
|
532
|
+
filepath << 'pdf'
|
533
|
+
else
|
534
|
+
filepath << 'zip'
|
535
|
+
end
|
536
|
+
|
537
|
+
Object::File.open(filepath, 'wb') do |file|
|
538
|
+
file.write(response)
|
539
|
+
end
|
540
|
+
|
541
|
+
filepath
|
542
|
+
end
|
543
|
+
|
544
|
+
#
|
545
|
+
# Cancel envelope.
|
546
|
+
#
|
547
|
+
# @param [Hash] access Access credentials
|
548
|
+
# @option access [String] :client_id
|
549
|
+
# @option access [String] :private_key
|
550
|
+
#
|
551
|
+
def cancel!( access = {})
|
552
|
+
Api::Request.new do |request|
|
553
|
+
request[:access] = access
|
554
|
+
request[:method] = :PUT
|
555
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/cancel"
|
556
|
+
end.execute!
|
557
|
+
end
|
558
|
+
|
559
|
+
#
|
560
|
+
# Retry sign envelope.
|
561
|
+
#
|
562
|
+
# @param [Hash] access Access credentials
|
563
|
+
# @option access [String] :client_id
|
564
|
+
# @option access [String] :private_key
|
565
|
+
#
|
566
|
+
def retry!(access = {})
|
567
|
+
Api::Request.new do |request|
|
568
|
+
request[:access] = access
|
569
|
+
request[:method] = :PUT
|
570
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/retry"
|
571
|
+
end.execute!
|
572
|
+
end
|
573
|
+
|
574
|
+
#
|
575
|
+
# Update envelope.
|
576
|
+
#
|
577
|
+
# @param [Hash] access Access credentials
|
578
|
+
# @option access [String] :client_id
|
579
|
+
# @option access [String] :private_key
|
580
|
+
# @return [Array]
|
581
|
+
#
|
582
|
+
def update_envelope!(template, access = {})
|
583
|
+
json = Api::Request.new do |request|
|
584
|
+
request[:access] = access
|
585
|
+
request[:method] = :POST
|
586
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/templates/#{template}"
|
587
|
+
end.execute!
|
588
|
+
|
589
|
+
json[:envelope]
|
590
|
+
|
591
|
+
end
|
592
|
+
|
593
|
+
#
|
594
|
+
# Modify signature envelope field location.
|
595
|
+
#
|
596
|
+
# @example Modify field location in envelope
|
597
|
+
# envelope = GroupDocs::Signature::Envelope.get!("g94h5g84hj9g4gf23i40j")
|
598
|
+
# document = envelope.documents!.first
|
599
|
+
# recipient = envelope.recipients!.first
|
600
|
+
# field = envelope.fields!(document, recipient).first
|
601
|
+
# location = field.locations.first
|
602
|
+
# envelope.modify_field_location! location, field, document, recipient
|
603
|
+
#
|
604
|
+
# @param [GroupDocs::Signature::Field::Location] location
|
605
|
+
# @param [GroupDocs::Signature::Field] field
|
606
|
+
# @param [GroupDocs::Document] document
|
607
|
+
# @param [GroupDocs::Signature::Recipient] recipient
|
608
|
+
# @param [Integer] order Location order
|
609
|
+
# @param [Hash] access Access credentials
|
610
|
+
# @option access [String] :client_id
|
611
|
+
# @option access [String] :private_key
|
612
|
+
# @raise [ArgumentError] if location is not GroupDocs::Signature::Field::Location
|
613
|
+
# @raise [ArgumentError] if field is not GroupDocs::Signature::Field
|
614
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document
|
615
|
+
# @raise [ArgumentError] if recipient is not GroupDocs::Signature::Recipient
|
616
|
+
#
|
617
|
+
def modify_field_location!(location, field, document, recipient, order, access = {})
|
618
|
+
location.is_a?(GroupDocs::Signature::Field::Location) or raise ArgumentError,
|
619
|
+
"Location should be GroupDocs::Signature::Field::Location object, received: #{location.inspect}"
|
620
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
621
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
622
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
623
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
624
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
625
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
626
|
+
|
627
|
+
api = Api::Request.new do |request|
|
628
|
+
request[:access] = access
|
629
|
+
request[:method] = :PUT
|
630
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/fields/#{field.id}/locations/#{location.id}"
|
631
|
+
end
|
632
|
+
api.add_params(:order => order)
|
633
|
+
api.execute!
|
634
|
+
end
|
635
|
+
|
636
|
+
#
|
637
|
+
# Changed in release 1.5.8
|
638
|
+
#
|
639
|
+
# Get signature envelope.
|
640
|
+
#
|
641
|
+
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
642
|
+
# @param [Hash] access Access credentials
|
643
|
+
# @option access [String] :client_id
|
644
|
+
# @option access [String] :private_key
|
645
|
+
# @return [Array]
|
646
|
+
#
|
647
|
+
def public_get!(recipient, access = {})
|
648
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
649
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
650
|
+
|
651
|
+
json = Api::Request.new do |request|
|
652
|
+
request[:access] = access
|
653
|
+
request[:method] = :GET
|
654
|
+
request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}"
|
655
|
+
end.execute!
|
656
|
+
|
657
|
+
Signature::Envelope.new(json[:envelope])
|
658
|
+
end
|
659
|
+
|
660
|
+
#
|
661
|
+
# Changed in release 1.5.8
|
662
|
+
#
|
663
|
+
# Public downloads signed documents to given path.
|
664
|
+
#
|
665
|
+
# If there is only one file in envelope, it's saved as PDF.
|
666
|
+
# If there are two or more files in envelope, it's saved as ZIP.
|
667
|
+
#
|
668
|
+
# @param [String] path Directory to download file to
|
669
|
+
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
670
|
+
# @param [Hash] access Access credentials
|
671
|
+
# @option access [String] :client_id
|
672
|
+
# @option access [String] :private_key
|
673
|
+
# @return [Array]
|
674
|
+
#
|
675
|
+
def public_signed_documents!(path, recipient, access = {})
|
676
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
677
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
678
|
+
json = Api::Request.new do |request|
|
679
|
+
request[:access] = access
|
680
|
+
request[:method] = :DOWNLOAD
|
681
|
+
request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}/documents/get"
|
682
|
+
end.execute!
|
683
|
+
filepath = "#{path}/#{name}."
|
684
|
+
if documents!.size == 1
|
685
|
+
filepath << 'pdf'
|
686
|
+
else
|
687
|
+
filepath << 'zip'
|
688
|
+
end
|
689
|
+
|
690
|
+
Object::File.open(filepath, 'wb') do |file|
|
691
|
+
file.write(json)
|
692
|
+
end
|
693
|
+
|
694
|
+
filepath
|
695
|
+
end
|
696
|
+
|
697
|
+
|
698
|
+
#
|
699
|
+
# Changed in release 1.5.8
|
700
|
+
#
|
701
|
+
#
|
702
|
+
# Get signed envelope field data.
|
703
|
+
#
|
704
|
+
# @param [GroupDocs::Signature::Recipient] recipient Recipient GUID
|
705
|
+
# @param [GroupDocs::Signature::Field] field Field GUID
|
706
|
+
# @param [Hash] access Access credentials
|
707
|
+
# @option access [String] :client_id
|
708
|
+
# @option access [String] :private_key
|
709
|
+
# @return [Array]
|
710
|
+
#
|
711
|
+
def date!(recipient, field, access = {})
|
712
|
+
field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError,
|
713
|
+
"Field should be GroupDocs::Signature::Field object, received: #{field.inspect}"
|
714
|
+
recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError,
|
715
|
+
"Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}"
|
716
|
+
|
717
|
+
Api::Request.new do |request|
|
718
|
+
request[:access] = access
|
719
|
+
request[:method] = :GET
|
720
|
+
request[:path] = "/signature/public/envelopes/#{id}/fields/recipient/#{recipient.id}/field/#{field.id}"
|
721
|
+
end.execute!
|
722
|
+
end
|
723
|
+
|
724
|
+
|
725
|
+
#
|
726
|
+
# added in release 1.6.0
|
727
|
+
#
|
728
|
+
#
|
729
|
+
# Resend envelope email notification.
|
730
|
+
#
|
731
|
+
# @param [Hash] access Access credentials
|
732
|
+
# @option access [String] :client_id
|
733
|
+
# @option access [String] :private_key
|
734
|
+
#
|
735
|
+
def resend!(access = {})
|
736
|
+
Api::Request.new do |request|
|
737
|
+
request[:access] = access
|
738
|
+
request[:method] = :PUT
|
739
|
+
request[:path] = "/signature/{{client_id}}/envelopes/#{id}/resend-notification"
|
740
|
+
end.execute!
|
741
|
+
end
|
742
|
+
|
743
|
+
|
744
|
+
|
745
|
+
|
746
|
+
end # Signature::Envelope
|
747
|
+
end # GroupDocs
|