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,39 +1,39 @@
|
|
1
|
-
module GroupDocs
|
2
|
-
class DataSource::Field < Api::Entity
|
3
|
-
|
4
|
-
# @attr [String] name
|
5
|
-
attr_accessor :name
|
6
|
-
# @attr [Integer] type
|
7
|
-
attr_accessor :type
|
8
|
-
# @attr [Array<String>] values
|
9
|
-
attr_accessor :values
|
10
|
-
|
11
|
-
# added in release 1.7.0
|
12
|
-
# @attr [String] contentType
|
13
|
-
attr_accessor :contentType
|
14
|
-
# @attr [List<GroupDocs::DataSource::Field>] nested_fields
|
15
|
-
attr_accessor :nested_fields
|
16
|
-
# @attr [String] regionName
|
17
|
-
attr_accessor :regionName
|
18
|
-
# @attr [String] dimension
|
19
|
-
attr_accessor :dimension
|
20
|
-
#
|
21
|
-
# Updates type with machine-readable format.
|
22
|
-
#
|
23
|
-
# @param [Symbol] type
|
24
|
-
#
|
25
|
-
def type=(type)
|
26
|
-
@type = type.is_a?(Symbol) ? type.to_s.capitalize : type
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Returns type in human-readable format.
|
31
|
-
#
|
32
|
-
# @return [Symbol]
|
33
|
-
#
|
34
|
-
def type
|
35
|
-
@type.downcase.to_sym
|
36
|
-
end
|
37
|
-
|
38
|
-
end # DataSource::Field
|
39
|
-
end # GroupDocs
|
1
|
+
module GroupDocs
|
2
|
+
class DataSource::Field < Api::Entity
|
3
|
+
|
4
|
+
# @attr [String] name
|
5
|
+
attr_accessor :name
|
6
|
+
# @attr [Integer] type
|
7
|
+
attr_accessor :type
|
8
|
+
# @attr [Array<String>] values
|
9
|
+
attr_accessor :values
|
10
|
+
|
11
|
+
# added in release 1.7.0
|
12
|
+
# @attr [String] contentType
|
13
|
+
attr_accessor :contentType
|
14
|
+
# @attr [List<GroupDocs::DataSource::Field>] nested_fields
|
15
|
+
attr_accessor :nested_fields
|
16
|
+
# @attr [String] regionName
|
17
|
+
attr_accessor :regionName
|
18
|
+
# @attr [String] dimension
|
19
|
+
attr_accessor :dimension
|
20
|
+
#
|
21
|
+
# Updates type with machine-readable format.
|
22
|
+
#
|
23
|
+
# @param [Symbol] type
|
24
|
+
#
|
25
|
+
def type=(type)
|
26
|
+
@type = type.is_a?(Symbol) ? type.to_s.capitalize : type
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Returns type in human-readable format.
|
31
|
+
#
|
32
|
+
# @return [Symbol]
|
33
|
+
#
|
34
|
+
def type
|
35
|
+
@type.downcase.to_sym
|
36
|
+
end
|
37
|
+
|
38
|
+
end # DataSource::Field
|
39
|
+
end # GroupDocs
|
data/lib/groupdocs/document.rb
CHANGED
@@ -1,1550 +1,1550 @@
|
|
1
|
-
module GroupDocs
|
2
|
-
class Document < Api::Entity
|
3
|
-
|
4
|
-
require 'groupdocs/document/annotation'
|
5
|
-
require 'groupdocs/document/change'
|
6
|
-
require 'groupdocs/document/field'
|
7
|
-
require 'groupdocs/document/metadata'
|
8
|
-
require 'groupdocs/document/rectangle'
|
9
|
-
require 'groupdocs/document/view'
|
10
|
-
require 'groupdocs/document/editor'
|
11
|
-
require 'groupdocs/document/style'
|
12
|
-
require 'groupdocs/document/page'
|
13
|
-
|
14
|
-
|
15
|
-
ACCESS_MODES = {
|
16
|
-
:private => 0,
|
17
|
-
:restricted => 1,
|
18
|
-
:public => 2,
|
19
|
-
:inherited => 254,
|
20
|
-
:denied => 255,
|
21
|
-
}
|
22
|
-
|
23
|
-
include Api::Helpers::AccessMode
|
24
|
-
include Api::Helpers::AccessRights
|
25
|
-
include Api::Helpers::Status
|
26
|
-
extend Api::Helpers::MIME
|
27
|
-
|
28
|
-
#
|
29
|
-
# Returns an array of views for all documents.
|
30
|
-
#
|
31
|
-
# @param [Hash] options
|
32
|
-
# @option options [Integer] :page_index Page to start with
|
33
|
-
# @option options [Integer] :page_size Total number of entries
|
34
|
-
# @param [Hash] access Access credentials
|
35
|
-
# @option access [String] :client_id
|
36
|
-
# @option access [String] :private_key
|
37
|
-
# @return [Array<GroupDocs::Document::View>]
|
38
|
-
#
|
39
|
-
def self.views!(options = {}, access = {})
|
40
|
-
api = Api::Request.new do |request|
|
41
|
-
request[:access] = access
|
42
|
-
request[:method] = :GET
|
43
|
-
request[:path] = '/doc/{{client_id}}/views'
|
44
|
-
end
|
45
|
-
api.add_params(options)
|
46
|
-
json = api.execute!
|
47
|
-
|
48
|
-
json[:views].map do |view|
|
49
|
-
Document::View.new(view)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
#
|
54
|
-
# Returns an array of all templates (documents in "Templates" directory).
|
55
|
-
#
|
56
|
-
# @param [Hash] options Options
|
57
|
-
# @option options [String] :orderBy Order by column
|
58
|
-
# @option options [Boolean] :isAscending Order by ascending or descending
|
59
|
-
# @param [Hash] access Access credentials
|
60
|
-
# @option access [String] :client_id
|
61
|
-
# @option access [String] :private_key
|
62
|
-
# @return [Array<GroupDocs::Document>]
|
63
|
-
#
|
64
|
-
def self.templates!(options = {}, access = {})
|
65
|
-
api = Api::Request.new do |request|
|
66
|
-
request[:access] = access
|
67
|
-
request[:method] = :GET
|
68
|
-
request[:path] = '/merge/{{client_id}}/templates'
|
69
|
-
end
|
70
|
-
api.add_params(options)
|
71
|
-
json = api.execute!
|
72
|
-
json[:templates].map do |template|
|
73
|
-
template.merge!(:file => Storage::File.new(template))
|
74
|
-
Document.new(template)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Signs given documents with signatures.
|
80
|
-
#
|
81
|
-
# @example
|
82
|
-
# # prepare documents
|
83
|
-
# file_one = GroupDocs::Storage::File.new(name: 'document_one.doc', local_path: '~/Documents/document_one.doc')
|
84
|
-
# file_two = GroupDocs::Storage::File.new(name: 'document_one.pdf', local_path: '~/Documents/document_one.pdf')
|
85
|
-
# document_one = file_one.to_document
|
86
|
-
# document_two = file_two.to_document
|
87
|
-
# # prepare signatures
|
88
|
-
# signature_one = GroupDocs::Signature.new(name: 'John Smith', image_path: '~/Documents/signature_one.png')
|
89
|
-
# signature_two = GroupDocs::Signature.new(name: 'Sara Smith', image_path: '~/Documents/signature_two.png')
|
90
|
-
# signature_one.position = { top: 0.1, left: 0.07, width: 50, height: 50 }
|
91
|
-
# signature_one.email = "test1@mail.com"
|
92
|
-
# signature_two.position = { top: 0.2, left: 0.2, width: 100, height: 100 }
|
93
|
-
# signature_one.email = "test1@mail.com"
|
94
|
-
# # sign documents and download results
|
95
|
-
# signed_documents = GroupDocs::Document.sign_documents!([document_one, document_two], [signature_one, signature_two])
|
96
|
-
# signed_documents.each do |document|
|
97
|
-
# document.file.download! '~/Documents'
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# @param [Array<GroupDocs::Document>] documents Each document file should have "#name" and "#local_path"
|
101
|
-
# @param [Array<GroupDocs::Signature>] signatures Each signature should have "#name", "#image_path" and "#position"
|
102
|
-
#
|
103
|
-
def self.sign_documents!(documents, signatures, options = {}, access = {})
|
104
|
-
documents.each do |document|
|
105
|
-
document.is_a?(Document) or raise ArgumentError, "Each document should be GroupDocs::Document object, received: #{document.inspect}"
|
106
|
-
document.file.name or raise ArgumentError, "Each document file should have name, received: #{document.file.name.inspect}"
|
107
|
-
document.file.local_path or raise ArgumentError, "Each document file should have local_path, received: #{document.file.local_path.inspect}"
|
108
|
-
end
|
109
|
-
signatures.each do |signature|
|
110
|
-
signature.is_a?(Signature) or raise ArgumentError, "Each signature should be GroupDocs::Signature object, received: #{signature.inspect}"
|
111
|
-
signature.name or raise ArgumentError, "Each signature should have name, received: #{signature.name.inspect}"
|
112
|
-
signature.image_path or raise ArgumentError, "Each signature should have image_path, received: #{signature.image_path.inspect}"
|
113
|
-
signature.position or raise ArgumentError, "Each signature should have position, received: #{signature.position.inspect}"
|
114
|
-
end
|
115
|
-
|
116
|
-
documents_to_sign = []
|
117
|
-
documents.map(&:file).each do |file|
|
118
|
-
document = { :name => file.name }
|
119
|
-
contents = File.open(file.local_path, 'rb').read
|
120
|
-
contents = Base64.strict_encode64(contents)
|
121
|
-
document.merge!(:data => "data:#{mime_type(file.local_path)};base64,#{contents}")
|
122
|
-
|
123
|
-
documents_to_sign << document
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
signers = []
|
128
|
-
signatures.each do |signature|
|
129
|
-
contents = File.open(signature.image_path, 'rb').read
|
130
|
-
contents = Base64.strict_encode64(contents)
|
131
|
-
signer = { :name => signature.name, :data => "data:#{mime_type(signature.image_path)};base64,#{contents}" }
|
132
|
-
signer.merge!(signature.position)
|
133
|
-
# place signature on is not implemented yet
|
134
|
-
signer.merge!(:placeSignatureOn => nil)
|
135
|
-
signer.merge!(:email => signature.email)
|
136
|
-
|
137
|
-
signers << signer
|
138
|
-
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
json = Api::Request.new do |request|
|
143
|
-
request[:access] = access
|
144
|
-
request[:method] = :POST
|
145
|
-
request[:path] = '/signature/{{client_id}}/sign'
|
146
|
-
request[:request_body] = { :documents => documents_to_sign, :signers => signers }
|
147
|
-
end.execute!
|
148
|
-
json[:jobId]
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
#
|
153
|
-
# Get sign documents status
|
154
|
-
#
|
155
|
-
# @param [String] job_guid
|
156
|
-
# @param [Hash] access Access credentials
|
157
|
-
# @option access [String] :client_id
|
158
|
-
# @option access [String] :private_key
|
159
|
-
#
|
160
|
-
def document_status!(job_guid, access = {})
|
161
|
-
json = Api::Request.new do |request|
|
162
|
-
request[:access] = access
|
163
|
-
request[:method] = :PUT
|
164
|
-
request[:path] = "/signature/{{client_id}}/documents/#{job_guid}"
|
165
|
-
end.execute!
|
166
|
-
|
167
|
-
json[:documents]
|
168
|
-
end
|
169
|
-
|
170
|
-
#
|
171
|
-
# Cnanged in release 2.0.0
|
172
|
-
#
|
173
|
-
# Returns a document metadata by given path.
|
174
|
-
#
|
175
|
-
# @param [String] path Full path to document
|
176
|
-
# @param [Hash] access Access credentials
|
177
|
-
# @option access [String] :client_id
|
178
|
-
# @option access [String] :private_key
|
179
|
-
# @return [Array<GroupDocs::Document::View>]
|
180
|
-
#
|
181
|
-
def self.metadata!(path, access = {})
|
182
|
-
json = Api::Request.new do |request|
|
183
|
-
request[:access] = access
|
184
|
-
request[:method] = :GET
|
185
|
-
request[:path] = "/doc/{{client_id}}/files/#{path}"
|
186
|
-
end.execute!
|
187
|
-
|
188
|
-
Document::MetaData.new do |metadata|
|
189
|
-
metadata.id = json[:id]
|
190
|
-
metadata.guid = json[:guid]
|
191
|
-
metadata.page_count = json[:page_count]
|
192
|
-
metadata.views_count = json[:views_count]
|
193
|
-
metadata.type = json[:type]
|
194
|
-
metadata.url = json[:url]
|
195
|
-
if json[:last_view]
|
196
|
-
metadata.last_view = json[:last_view]
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
# @attr [GroupDocs::Storage::File] file
|
202
|
-
attr_accessor :file
|
203
|
-
# @attr [Time] process_date
|
204
|
-
attr_accessor :process_date
|
205
|
-
# @attr [Array<GroupDocs::Storage::File>] outputs
|
206
|
-
attr_accessor :outputs
|
207
|
-
# @attr [Array<Symbol>] output_formats
|
208
|
-
attr_accessor :output_formats
|
209
|
-
# @attr [Symbol] status
|
210
|
-
attr_accessor :status
|
211
|
-
# @attr [Integer] order
|
212
|
-
attr_accessor :order
|
213
|
-
# @attr [Integer] field_count
|
214
|
-
attr_accessor :field_count
|
215
|
-
|
216
|
-
#added in release 1.6.0
|
217
|
-
# @attr [String] fieldType
|
218
|
-
attr_accessor :fieldType
|
219
|
-
# @attr [Int] dependent_questionnaires_count
|
220
|
-
attr_accessor :dependent_questionnaires_count
|
221
|
-
# @attr [Long] upload_time
|
222
|
-
attr_accessor :upload_time
|
223
|
-
|
224
|
-
|
225
|
-
#added in release 2.0.0
|
226
|
-
# @attr [String] documentDescription
|
227
|
-
attr_accessor :documentDescription
|
228
|
-
|
229
|
-
|
230
|
-
[
|
231
|
-
:news ,
|
232
|
-
:alerts ,
|
233
|
-
:support ,
|
234
|
-
:is_real_time_broadcast ,
|
235
|
-
:is_scroll_broadcast ,
|
236
|
-
:is_zoom_broadcast ,
|
237
|
-
:is_annotation_navigation_widget ,
|
238
|
-
:is_annotation_zoom_widget ,
|
239
|
-
:is_annotation_download_widget ,
|
240
|
-
:is_annotation_print_widget ,
|
241
|
-
:is_annotation_help_widget ,
|
242
|
-
:is_right_panel ,
|
243
|
-
:is_thumbnails_panel ,
|
244
|
-
:is_toolbar ,
|
245
|
-
:is_text_annotation_button ,
|
246
|
-
:is_rectangle_annotation_button ,
|
247
|
-
:is_point_annotation_button ,
|
248
|
-
:is_strikeout_annotation_button ,
|
249
|
-
:is_polyline_annotation_button ,
|
250
|
-
:is_typewriter_annotation_button ,
|
251
|
-
:is_watermark_annotation_button ,
|
252
|
-
:is_viewer_navigation_widget ,
|
253
|
-
:is_viewer_zoom_widget ,
|
254
|
-
:is_viewer_download_widget ,
|
255
|
-
:is_viewer_print_widget ,
|
256
|
-
:is_viewer_help_widget ,
|
257
|
-
].each do |option|
|
258
|
-
# @attr [Boolean] option
|
259
|
-
attr_accessor :"#{option}_enabled"
|
260
|
-
end
|
261
|
-
[
|
262
|
-
:standard_header_always ,
|
263
|
-
:annotation_document_name ,
|
264
|
-
:viewer_document_name ,
|
265
|
-
].each do |option|
|
266
|
-
# @attr [Boolean] option
|
267
|
-
attr_accessor :"is_#{option}_shown"
|
268
|
-
end
|
269
|
-
|
270
|
-
|
271
|
-
#
|
272
|
-
# Coverts passed array of attributes hash to array of GroupDocs::Storage::File.
|
273
|
-
#
|
274
|
-
# @param [Array<Hash>] outputs Array of file attributes hashes
|
275
|
-
#
|
276
|
-
def outputs=(outputs)
|
277
|
-
if outputs
|
278
|
-
@outputs = outputs.map do |output|
|
279
|
-
GroupDocs::Storage::File.new(output)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
#
|
285
|
-
# Returns output formats in human-readable format.
|
286
|
-
#
|
287
|
-
# @return [Array<Symbol>]
|
288
|
-
#
|
289
|
-
def output_formats
|
290
|
-
@output_formats.split(',').map(&:to_sym)
|
291
|
-
end
|
292
|
-
|
293
|
-
#
|
294
|
-
# Converts status to human-readable format.
|
295
|
-
#
|
296
|
-
# @return [Symbol]
|
297
|
-
#
|
298
|
-
def status
|
299
|
-
parse_status(@status)
|
300
|
-
end
|
301
|
-
|
302
|
-
#
|
303
|
-
# Converts timestamp which is return by API server to Time object.
|
304
|
-
#
|
305
|
-
# @return [Time]
|
306
|
-
#
|
307
|
-
def process_date
|
308
|
-
Time.at(@process_date / 1000)
|
309
|
-
end
|
310
|
-
|
311
|
-
# Compatibility with response JSON
|
312
|
-
alias_method :proc_date=, :process_date=
|
313
|
-
|
314
|
-
#
|
315
|
-
# Creates new GroupDocs::Document.
|
316
|
-
#
|
317
|
-
# You should avoid creating documents directly. Instead, use #to_document
|
318
|
-
# instance method of GroupDocs::Storage::File.
|
319
|
-
#
|
320
|
-
# @raise [ArgumentError] If file is not passed or is not an instance of GroupDocs::Storage::File
|
321
|
-
#
|
322
|
-
def initialize(options = {}, &blk)
|
323
|
-
super(options, &blk)
|
324
|
-
file.is_a?(GroupDocs::Storage::File) or raise ArgumentError,
|
325
|
-
"You have to pass GroupDocs::Storage::File object: #{file.inspect}."
|
326
|
-
end
|
327
|
-
|
328
|
-
#
|
329
|
-
# Returns a stream of bytes representing a particular document page image.
|
330
|
-
#
|
331
|
-
# @param [String] path Document path
|
332
|
-
# @param [String] name Name document (format - jpg)
|
333
|
-
# @example path = "#{File.dirname(__FILE__)}"
|
334
|
-
# name = "test.jpg"
|
335
|
-
# @param [Integer] page_number Document page number to get image for
|
336
|
-
# @param [Integer] dimension Image dimension "<width>x<height>"(500x600)
|
337
|
-
# @param [Hash] options
|
338
|
-
# @option options [Integer] :quality Image quality in range 1-100.
|
339
|
-
# @option options [Boolean] :use_pdf A flag indicating whether a document should be converted to PDF format before generating the image.
|
340
|
-
# @option options [Boolean] :expires The date and time in milliseconds since epoch the URL expires.
|
341
|
-
# @param [Hash] access Access credentials
|
342
|
-
# @option access [String] :client_id
|
343
|
-
# @option access [String] :private_key
|
344
|
-
# @return []
|
345
|
-
#
|
346
|
-
def page_image!(path, name, page_number, dimension, options = {}, access = {})
|
347
|
-
api = Api::Request.new do |request|
|
348
|
-
request[:access] = access
|
349
|
-
request[:method] = :DOWNLOAD
|
350
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/#{page_number}/images/#{dimension}"
|
351
|
-
end
|
352
|
-
api.add_params(options)
|
353
|
-
response = api.execute!
|
354
|
-
|
355
|
-
filepath = "#{path}/#{name}"
|
356
|
-
Object::File.open(filepath, 'wb') do |file|
|
357
|
-
file.write(response)
|
358
|
-
end
|
359
|
-
|
360
|
-
filepath
|
361
|
-
|
362
|
-
end
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
#
|
370
|
-
# Returns array of URLs to images representing document pages.
|
371
|
-
#
|
372
|
-
# @example
|
373
|
-
# file = GroupDocs::Storage::Folder.list!.last
|
374
|
-
# document = file.to_document
|
375
|
-
# document.page_images! 1024, 768, first_page: 0, page_count: 1
|
376
|
-
#
|
377
|
-
# @param [Integer] width Image width
|
378
|
-
# @param [Integer] height Image height
|
379
|
-
# @param [Hash] options
|
380
|
-
# @option options [Integer] :first_page Start page to return image for (starting with 0)
|
381
|
-
# @option options [Integer] :page_count Number of pages to return image for
|
382
|
-
# @option options [Integer] :quality
|
383
|
-
# @option options [Boolean] :use_pdf
|
384
|
-
# @option options [Boolean] :token
|
385
|
-
# @param [Hash] access Access credentials
|
386
|
-
# @option access [String] :client_id
|
387
|
-
# @option access [String] :private_key
|
388
|
-
# @return [Array<String>]
|
389
|
-
#
|
390
|
-
def page_images!(width, height, options = {}, access = {})
|
391
|
-
api = Api::Request.new do |request|
|
392
|
-
request[:access] = access
|
393
|
-
request[:method] = :GET
|
394
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/images/#{width}x#{height}/urls"
|
395
|
-
end
|
396
|
-
api.add_params(options)
|
397
|
-
json = api.execute!
|
398
|
-
|
399
|
-
json[:url]
|
400
|
-
end
|
401
|
-
|
402
|
-
|
403
|
-
#
|
404
|
-
# Returns editing metadata.
|
405
|
-
#
|
406
|
-
# @param [Hash] access Access credentials
|
407
|
-
# @option access [String] :client_id
|
408
|
-
# @option access [String] :private_key
|
409
|
-
#
|
410
|
-
def editlock!(access = {})
|
411
|
-
Api::Request.new do |request|
|
412
|
-
request[:access] = access
|
413
|
-
request[:method] = :GET
|
414
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock"
|
415
|
-
end.execute!
|
416
|
-
end
|
417
|
-
|
418
|
-
#
|
419
|
-
# Removes edit lock for a document and replaces the document with its edited copy
|
420
|
-
#
|
421
|
-
# @param [Hash] options
|
422
|
-
# @option options [String] :lockId Start page to return image for (starting with 0)
|
423
|
-
# @param [Hash] access Access credentials
|
424
|
-
# @option access [String] :client_id
|
425
|
-
# @option access [String] :private_key
|
426
|
-
# @return [Integer]
|
427
|
-
#
|
428
|
-
def editlock_clear!(options = {}, access = {})
|
429
|
-
api = Api::Request.new do |request|
|
430
|
-
request[:access] = access
|
431
|
-
request[:method] = :DELETE
|
432
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock"
|
433
|
-
end
|
434
|
-
api.add_params(options).execute!
|
435
|
-
end
|
436
|
-
|
437
|
-
#
|
438
|
-
# Returns tags assigned to the document
|
439
|
-
#
|
440
|
-
# @param [Hash] access Access credentials
|
441
|
-
# @option access [String] :client_id
|
442
|
-
# @option access [String] :private_key
|
443
|
-
# @return [Array<String>]
|
444
|
-
#
|
445
|
-
def tags!(access = {})
|
446
|
-
Api::Request.new do |request|
|
447
|
-
request[:access] = access
|
448
|
-
request[:method] = :GET
|
449
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
450
|
-
end.execute!
|
451
|
-
end
|
452
|
-
|
453
|
-
#
|
454
|
-
# Assign tags to the document.
|
455
|
-
#
|
456
|
-
# @param [Hash] access Access credentials
|
457
|
-
# @option access [String] :client_id
|
458
|
-
# @option access [String] :private_key
|
459
|
-
# @return [String]
|
460
|
-
#
|
461
|
-
def tags_set!(access = {})
|
462
|
-
Api::Request.new do |request|
|
463
|
-
request[:access] = access
|
464
|
-
request[:method] = :PUT
|
465
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
466
|
-
end.execute!
|
467
|
-
end
|
468
|
-
|
469
|
-
#
|
470
|
-
# Removes tags assigned to the document
|
471
|
-
#
|
472
|
-
# @param [Hash] access Access credentials
|
473
|
-
# @option access [String] :client_id
|
474
|
-
# @option access [String] :private_key
|
475
|
-
# @return [String]
|
476
|
-
#
|
477
|
-
def tags_clear!(access = {})
|
478
|
-
Api::Request.new do |request|
|
479
|
-
request[:access] = access
|
480
|
-
request[:method] = :DELETE
|
481
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
482
|
-
end.execute!
|
483
|
-
end
|
484
|
-
|
485
|
-
#
|
486
|
-
# Returns document content
|
487
|
-
#
|
488
|
-
# @param [String] content_type Content type
|
489
|
-
# @param [Hash] access Access credentials
|
490
|
-
# @option access [String] :client_id
|
491
|
-
# @option access [String] :private_key
|
492
|
-
# @return [String]
|
493
|
-
#
|
494
|
-
def content!(content_type, access = {})
|
495
|
-
json = Api::Request.new do |request|
|
496
|
-
request[:access] = access
|
497
|
-
request[:method] = :GET
|
498
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/content/#{content_type}"
|
499
|
-
end.execute!
|
500
|
-
|
501
|
-
json[:content]
|
502
|
-
end
|
503
|
-
|
504
|
-
#
|
505
|
-
# Returns array of URLs to images representing document pages thumbnails.
|
506
|
-
#
|
507
|
-
# @example
|
508
|
-
# file = GroupDocs::Storage::Folder.list!.last
|
509
|
-
# document = file.to_document
|
510
|
-
# document.thumbnails! first_page: 0, page_count: 1, width: 1024
|
511
|
-
#
|
512
|
-
# @param [Hash] options
|
513
|
-
# @option options [Integer] :page_number Start page to return image for (starting with 0)
|
514
|
-
# @option options [Integer] :page_count Number of pages to return image for
|
515
|
-
# @option options [Integer] :width
|
516
|
-
# @option options [Integer] :quality
|
517
|
-
# @option options [Boolean] :use_pdf
|
518
|
-
# @param [Hash] access Access credentials
|
519
|
-
# @option access [String] :client_id
|
520
|
-
# @option access [String] :private_key
|
521
|
-
# @return [Array<String>]
|
522
|
-
#
|
523
|
-
def thumbnails!(options = {}, access = {})
|
524
|
-
api = Api::Request.new do |request|
|
525
|
-
request[:access] = access
|
526
|
-
request[:method] = :POST
|
527
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/thumbnails"
|
528
|
-
end
|
529
|
-
api.add_params(options)
|
530
|
-
json = api.execute!
|
531
|
-
|
532
|
-
json[:image_urls]
|
533
|
-
end
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
#
|
538
|
-
# Returns access mode of document.
|
539
|
-
#
|
540
|
-
# @param [Hash] access Access credentials
|
541
|
-
# @option access [String] :client_id
|
542
|
-
# @option access [String] :private_key
|
543
|
-
# @return [Symbol] One of :private, :restricted or :public access modes
|
544
|
-
#
|
545
|
-
def access_mode!(access = {})
|
546
|
-
json = Api::Request.new do |request|
|
547
|
-
request[:access] = access
|
548
|
-
request[:method] = :GET
|
549
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/accessinfo"
|
550
|
-
end.execute!
|
551
|
-
|
552
|
-
parse_access_mode(json[:access])
|
553
|
-
end
|
554
|
-
|
555
|
-
#
|
556
|
-
# Sets access mode of document.
|
557
|
-
#
|
558
|
-
# @param [Symbol] mode One of :private, :restricted or :public access modes
|
559
|
-
# @param [Hash] access Access credentials
|
560
|
-
# @option access [String] :client_id
|
561
|
-
# @option access [String] :private_key
|
562
|
-
# @return [Symbol] Set access mode
|
563
|
-
#
|
564
|
-
def access_mode_set!(mode, access = {})
|
565
|
-
api = Api::Request.new do |request|
|
566
|
-
request[:access] = access
|
567
|
-
request[:method] = :PUT
|
568
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo"
|
569
|
-
end
|
570
|
-
api.add_params(:mode => ACCESS_MODES[mode])
|
571
|
-
json = api.execute!
|
572
|
-
|
573
|
-
parse_access_mode(json[:access])
|
574
|
-
end
|
575
|
-
# note that aliased version cannot accept access credentials hash
|
576
|
-
alias_method :access_mode=, :access_mode_set!
|
577
|
-
|
578
|
-
#
|
579
|
-
# Returns array of file formats document can be converted to.
|
580
|
-
#
|
581
|
-
# @param [Hash] access Access credentials
|
582
|
-
# @option access [String] :client_id
|
583
|
-
# @option access [String] :private_key
|
584
|
-
# @return [Array<Symbol>]
|
585
|
-
#
|
586
|
-
def formats!(access = {})
|
587
|
-
json = Api::Request.new do |request|
|
588
|
-
request[:access] = access
|
589
|
-
request[:method] = :GET
|
590
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.id}/formats"
|
591
|
-
end.execute!
|
592
|
-
|
593
|
-
json[:types].map do |format|
|
594
|
-
format.downcase.to_sym
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
#
|
599
|
-
# Cnanged in release 2.0.0
|
600
|
-
#
|
601
|
-
# Returns document metadata.
|
602
|
-
#
|
603
|
-
# @param [Hash] access Access credentials
|
604
|
-
# @option access [String] :client_id
|
605
|
-
# @option access [String] :private_key
|
606
|
-
# @return [GroupDocs::Document::MetaData]
|
607
|
-
#
|
608
|
-
def metadata!(access = {})
|
609
|
-
json = Api::Request.new do |request|
|
610
|
-
request[:access] = access
|
611
|
-
request[:method] = :GET
|
612
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/metadata"
|
613
|
-
end.execute!
|
614
|
-
|
615
|
-
Document::MetaData.new do |metadata|
|
616
|
-
metadata.id = json[:id]
|
617
|
-
metadata.guid = json[:guid]
|
618
|
-
metadata.page_count = json[:page_count]
|
619
|
-
metadata.views_count = json[:views_count]
|
620
|
-
metadata.type = json[:type]
|
621
|
-
metadata.url = json[:url]
|
622
|
-
if json[:last_view]
|
623
|
-
metadata.last_view = json[:last_view]
|
624
|
-
end
|
625
|
-
end
|
626
|
-
end
|
627
|
-
|
628
|
-
#
|
629
|
-
# Returns an array of document fields.
|
630
|
-
#
|
631
|
-
# @param [Hash] access Access credentials
|
632
|
-
# @option access [String] :client_id
|
633
|
-
# @option access [String] :private_key
|
634
|
-
# @return [Array<GroupDocs::Document::Field>]
|
635
|
-
#
|
636
|
-
def fields!(access = {})
|
637
|
-
api = Api::Request.new do |request|
|
638
|
-
request[:access] = access
|
639
|
-
request[:method] = :GET
|
640
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/fields"
|
641
|
-
end
|
642
|
-
api.add_params(:include_geometry => true)
|
643
|
-
json = api.execute!
|
644
|
-
|
645
|
-
json[:fields].map do |field|
|
646
|
-
Document::Field.new(field)
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
#
|
651
|
-
# Returns an array of users a document is shared with.
|
652
|
-
#
|
653
|
-
# @param [Hash] access Access credentials
|
654
|
-
# @option access [String] :client_id
|
655
|
-
# @option access [String] :private_key
|
656
|
-
# @return [Array<GroupDocs::User>]
|
657
|
-
#
|
658
|
-
def sharers!(access = {})
|
659
|
-
json = Api::Request.new do |request|
|
660
|
-
request[:access] = access
|
661
|
-
request[:method] = :GET
|
662
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo"
|
663
|
-
end.execute!
|
664
|
-
|
665
|
-
json[:sharers].map do |user|
|
666
|
-
User.new(user)
|
667
|
-
end
|
668
|
-
end
|
669
|
-
|
670
|
-
#
|
671
|
-
# Returns an array of users a document is shared with.
|
672
|
-
# @param [String] sharers_types
|
673
|
-
# @param [Hash] options
|
674
|
-
# @option options [String] :page_index
|
675
|
-
# @option options [String] :page_size
|
676
|
-
# @option options [String] :order_by
|
677
|
-
# @option options [Boolean] :order_ask
|
678
|
-
# @param [Hash] access Access credentials
|
679
|
-
# @option access [String] :client_id
|
680
|
-
# @option access [String] :private_key
|
681
|
-
# @return [Array<GroupDocs::User>]
|
682
|
-
#
|
683
|
-
def shared_documents!(sharers_types, options = {}, access = {})
|
684
|
-
api = Api::Request.new do |request|
|
685
|
-
request[:access] = access
|
686
|
-
request[:method] = :GET
|
687
|
-
request[:path] = "/doc/{{client_id}}/shares/#{sharers_types}"
|
688
|
-
end
|
689
|
-
api.add_params(options).execute!
|
690
|
-
|
691
|
-
end
|
692
|
-
|
693
|
-
#
|
694
|
-
# Sets document sharers to given emails.
|
695
|
-
#
|
696
|
-
# If empty array or nil passed, clears sharers.
|
697
|
-
#
|
698
|
-
# @param [Array] emails List of email addresses to share with
|
699
|
-
# @param [Hash] access Access credentials
|
700
|
-
# @option access [String] :client_id
|
701
|
-
# @option access [String] :private_key
|
702
|
-
# @return [Array<GroupDocs::User>]
|
703
|
-
#
|
704
|
-
def sharers_set!(emails, access = {})
|
705
|
-
if emails.nil? || emails.empty?
|
706
|
-
sharers_clear!(access)
|
707
|
-
else
|
708
|
-
json = Api::Request.new do |request|
|
709
|
-
request[:access] = access
|
710
|
-
request[:method] = :PUT
|
711
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers"
|
712
|
-
request[:request_body] = emails
|
713
|
-
end.execute!
|
714
|
-
|
715
|
-
json[:shared_users].map do |user|
|
716
|
-
User.new(user)
|
717
|
-
end
|
718
|
-
end
|
719
|
-
end
|
720
|
-
|
721
|
-
#
|
722
|
-
# Sets document password.
|
723
|
-
#
|
724
|
-
# @param [String] password New password for document
|
725
|
-
# @param [Hash] access Access credentials
|
726
|
-
# @option access [String] :client_id
|
727
|
-
# @option access [String] :private_key
|
728
|
-
# @return [Array<GroupDocs::User>]
|
729
|
-
#
|
730
|
-
def password_set!(password, access = {})
|
731
|
-
Api::Request.new do |request|
|
732
|
-
request[:access] = access
|
733
|
-
request[:method] = :PUT
|
734
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/password"
|
735
|
-
request[:request_body] = password
|
736
|
-
end.execute!
|
737
|
-
|
738
|
-
end
|
739
|
-
|
740
|
-
#
|
741
|
-
# Sets document user status.
|
742
|
-
#
|
743
|
-
# @param [String] status (Pending = 0, Accepted = 1, Declined = 2)
|
744
|
-
# @param [Hash] access Access credentials
|
745
|
-
# @option access [String] :client_id
|
746
|
-
# @option access [String] :private_key
|
747
|
-
# @return [String]
|
748
|
-
#
|
749
|
-
def user_status_set!(status, access = {})
|
750
|
-
Api::Request.new do |request|
|
751
|
-
request[:access] = access
|
752
|
-
request[:method] = :PUT
|
753
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/sharer"
|
754
|
-
request[:request_body] = status
|
755
|
-
end.execute!
|
756
|
-
|
757
|
-
end
|
758
|
-
|
759
|
-
#
|
760
|
-
# Clears sharers list.
|
761
|
-
#
|
762
|
-
# @param [Hash] access Access credentials
|
763
|
-
# @option access [String] :client_id
|
764
|
-
# @option access [String] :private_key
|
765
|
-
# @return nil
|
766
|
-
#
|
767
|
-
def sharers_clear!(access = {})
|
768
|
-
Api::Request.new do |request|
|
769
|
-
request[:access] = access
|
770
|
-
request[:method] = :DELETE
|
771
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers"
|
772
|
-
end.execute![:shared_users]
|
773
|
-
|
774
|
-
end
|
775
|
-
|
776
|
-
#
|
777
|
-
# Converts document to given format.
|
778
|
-
#
|
779
|
-
# @example
|
780
|
-
# document = GroupDocs::Storage::Folder.list!.first.to_document
|
781
|
-
# job = document.convert!(:docx)
|
782
|
-
# sleep(5) # wait for server to finish converting
|
783
|
-
# original_document = job.documents![:inputs].first
|
784
|
-
# converted_file = original_file.outputs.first
|
785
|
-
# converted_file.download!(File.dirname(__FILE__))
|
786
|
-
#
|
787
|
-
# @param [Symbol] format
|
788
|
-
# @param [Hash] options
|
789
|
-
# @option options [Boolean] :email_results
|
790
|
-
# @option options [String] :new_description
|
791
|
-
# @option options [String] :print_script
|
792
|
-
# @option options [String] :callback
|
793
|
-
# @param [Hash] access Access credentials
|
794
|
-
# @option access [String] :client_id
|
795
|
-
# @option access [String] :private_key
|
796
|
-
# @return [GroupDocs::Job] Created job
|
797
|
-
#
|
798
|
-
def convert!(format, options = {}, access = {})
|
799
|
-
options.merge!(:new_type => format)
|
800
|
-
|
801
|
-
api = Api::Request.new do |request|
|
802
|
-
request[:access] = access
|
803
|
-
request[:method] = :POST
|
804
|
-
request[:path] = "/async/{{client_id}}/files/#{file.guid}"
|
805
|
-
end
|
806
|
-
api.add_params(options)
|
807
|
-
json = api.execute!
|
808
|
-
|
809
|
-
Job.new(:id => json[:job_id])
|
810
|
-
end
|
811
|
-
|
812
|
-
#
|
813
|
-
# Creates new job to merge datasource into document.
|
814
|
-
#
|
815
|
-
# @param [GroupDocs::DataSource] datasource
|
816
|
-
# @param [Hash] options
|
817
|
-
# @option options [Boolean] :new_type New file format type
|
818
|
-
# @option options [Boolean] :email_results Set to true if converted document should be emailed
|
819
|
-
# @param [Hash] access Access credentials
|
820
|
-
# @option access [String] :client_id
|
821
|
-
# @option access [String] :private_key
|
822
|
-
# @return [GroupDocs::Job]
|
823
|
-
#
|
824
|
-
# @raise [ArgumentError] if datasource is not GroupDocs::DataSource object
|
825
|
-
#
|
826
|
-
def datasource!(datasource, options = {}, access = {})
|
827
|
-
datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
|
828
|
-
"Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}"
|
829
|
-
|
830
|
-
api = Api::Request.new do |request|
|
831
|
-
request[:access] = access
|
832
|
-
request[:method] = :POST
|
833
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources/#{datasource.id}"
|
834
|
-
end
|
835
|
-
api.add_params(options)
|
836
|
-
json = api.execute!
|
837
|
-
|
838
|
-
Job.new(:id => json[:job_id])
|
839
|
-
end
|
840
|
-
|
841
|
-
#
|
842
|
-
# Creates new job to merge datasource fields into document.
|
843
|
-
#
|
844
|
-
# @param [GroupDocs::DataSource] datasource
|
845
|
-
# @param [Hash] options
|
846
|
-
# @option options [Boolean] :new_type New file format type
|
847
|
-
# @option options [Boolean] :email_results Set to true if converted document should be emailed
|
848
|
-
# @option options [Boolean] :assembly_name
|
849
|
-
# @param [Array] datasourceFields (:name [String], :value [String], :contentType [String], :type [String], :nested_fields [<Array> datasourceFields])
|
850
|
-
# @param [Hash] access Access credentials
|
851
|
-
# @option access [String] :client_id
|
852
|
-
# @option access [String] :private_key
|
853
|
-
# @return [GroupDocs::Job]
|
854
|
-
#
|
855
|
-
# @raise [ArgumentError] if datasource is not GroupDocs::DataSource object
|
856
|
-
#
|
857
|
-
def datasource_fields!(datasource, options = {}, access = {})
|
858
|
-
datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
|
859
|
-
"Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}"
|
860
|
-
|
861
|
-
api = Api::Request.new do |request|
|
862
|
-
request[:access] = access
|
863
|
-
request[:method] = :POST
|
864
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources"
|
865
|
-
request[:request_body] = datasource.fields
|
866
|
-
end
|
867
|
-
api.add_params(options)
|
868
|
-
json = api.execute!
|
869
|
-
|
870
|
-
Job.new(:id => json[:job_id])
|
871
|
-
end
|
872
|
-
|
873
|
-
|
874
|
-
#
|
875
|
-
# Returns an array of questionnaires.
|
876
|
-
#
|
877
|
-
# @param [Hash] access Access credentials
|
878
|
-
# @option access [String] :client_id
|
879
|
-
# @option access [String] :private_key
|
880
|
-
# @return [Array<GroupDocs::Questionnaire>]
|
881
|
-
#
|
882
|
-
def questionnaires!(access = {})
|
883
|
-
json = Api::Request.new do |request|
|
884
|
-
request[:access] = access
|
885
|
-
request[:method] = :GET
|
886
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires"
|
887
|
-
end.execute!
|
888
|
-
|
889
|
-
json[:questionnaires].map do |questionnaire|
|
890
|
-
Questionnaire.new(questionnaire)
|
891
|
-
end
|
892
|
-
end
|
893
|
-
|
894
|
-
#
|
895
|
-
# Adds questionnaire to document.
|
896
|
-
#
|
897
|
-
# @param [GroupDocs::Questionnaire] questionnaire
|
898
|
-
# @param [Hash] access Access credentials
|
899
|
-
# @option access [String] :client_id
|
900
|
-
# @option access [String] :private_key
|
901
|
-
#
|
902
|
-
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
903
|
-
#
|
904
|
-
def add_questionnaire!(questionnaire, access = {})
|
905
|
-
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
906
|
-
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
907
|
-
|
908
|
-
Api::Request.new do |request|
|
909
|
-
request[:access] = access
|
910
|
-
request[:method] = :PUT
|
911
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}"
|
912
|
-
end.execute!
|
913
|
-
end
|
914
|
-
|
915
|
-
#
|
916
|
-
# Creates questionnaire and adds it to document.
|
917
|
-
#
|
918
|
-
# @param [GroupDocs::Questionnaire] questionnaire
|
919
|
-
# @param [Hash] access Access credentials
|
920
|
-
# @option access [String] :client_id
|
921
|
-
# @option access [String] :private_key
|
922
|
-
# @return [GroupDocs::Questionnaire]
|
923
|
-
#
|
924
|
-
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
925
|
-
#
|
926
|
-
def create_questionnaire!(questionnaire, access = {})
|
927
|
-
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
928
|
-
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
929
|
-
|
930
|
-
json = Api::Request.new do |request|
|
931
|
-
request[:access] = access
|
932
|
-
request[:method] = :POST
|
933
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires"
|
934
|
-
request[:request_body] = questionnaire.to_hash
|
935
|
-
end.execute!
|
936
|
-
|
937
|
-
questionnaire.id = json[:questionnaire_id]
|
938
|
-
questionnaire
|
939
|
-
end
|
940
|
-
|
941
|
-
#
|
942
|
-
# Detaches questionnaire from document.
|
943
|
-
#
|
944
|
-
# @param [GroupDocs::Questionnaire] questionnaire
|
945
|
-
# @param [Hash] access Access credentials
|
946
|
-
# @option access [String] :client_id
|
947
|
-
# @option access [String] :private_key
|
948
|
-
#
|
949
|
-
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
950
|
-
#
|
951
|
-
def remove_questionnaire!(questionnaire, access = {})
|
952
|
-
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
953
|
-
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
954
|
-
|
955
|
-
Api::Request.new do |request|
|
956
|
-
request[:access] = access
|
957
|
-
request[:method] = :DELETE
|
958
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}"
|
959
|
-
end.execute!
|
960
|
-
end
|
961
|
-
|
962
|
-
#
|
963
|
-
# Returns an array of annotations.
|
964
|
-
#
|
965
|
-
# @param [Hash] access Access credentials
|
966
|
-
# @option access [String] :client_id
|
967
|
-
# @option access [String] :private_key
|
968
|
-
# @return [Array<GroupDocs::Document::Annotation>]
|
969
|
-
#
|
970
|
-
def annotations!(access = {})
|
971
|
-
json = Api::Request.new do |request|
|
972
|
-
request[:access] = access
|
973
|
-
request[:method] = :GET
|
974
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/annotations"
|
975
|
-
end.execute!
|
976
|
-
|
977
|
-
if json[:annotations]
|
978
|
-
json[:annotations].map do |annotation|
|
979
|
-
annotation.merge!(:document => self)
|
980
|
-
Document::Annotation.new(annotation)
|
981
|
-
end
|
982
|
-
else
|
983
|
-
[]
|
984
|
-
end
|
985
|
-
end
|
986
|
-
|
987
|
-
#
|
988
|
-
# Changed in release 1.5.8
|
989
|
-
# Returns document details.
|
990
|
-
#
|
991
|
-
# @param [Hash] access Access credentials
|
992
|
-
# @option access [String] :client_id
|
993
|
-
# @option access [String] :private_key
|
994
|
-
# @return [Hash]
|
995
|
-
#
|
996
|
-
def details!(access = {})
|
997
|
-
api = Api::Request.new do |request|
|
998
|
-
request[:access] = access
|
999
|
-
request[:method] = :GET
|
1000
|
-
request[:path] = "/comparison/{{client_id}}document"
|
1001
|
-
end
|
1002
|
-
api.add_params(:guid => file.guid)
|
1003
|
-
api.execute!
|
1004
|
-
end
|
1005
|
-
|
1006
|
-
#
|
1007
|
-
# Changed in release 1.5.8
|
1008
|
-
# Schedules a job for comparing document with given.
|
1009
|
-
#
|
1010
|
-
# @param [GroupDocs::Document] document
|
1011
|
-
# @param [Hash] access Access credentials
|
1012
|
-
# @option access [String] :client_id
|
1013
|
-
# @option access [String] :private_key
|
1014
|
-
# @return [GroupDocs::Job]
|
1015
|
-
#
|
1016
|
-
# @raise [ArgumentError] if document is not GroupDocs::Document object
|
1017
|
-
#
|
1018
|
-
def compare!(document, callback, access = {})
|
1019
|
-
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
1020
|
-
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
1021
|
-
|
1022
|
-
api = Api::Request.new do |request|
|
1023
|
-
request[:access] = access
|
1024
|
-
request[:method] = :GET
|
1025
|
-
request[:path] = "/comparison/{{client_id}}/compare"
|
1026
|
-
end
|
1027
|
-
api.add_params(:source => file.guid, :target => document.file.guid, :callback => callback)
|
1028
|
-
json = api.execute!
|
1029
|
-
|
1030
|
-
Job.new(:id => json[:job_id])
|
1031
|
-
end
|
1032
|
-
|
1033
|
-
#
|
1034
|
-
# Updated in release 2.1.0
|
1035
|
-
#
|
1036
|
-
# Schedules a job for comparing document with given.
|
1037
|
-
#
|
1038
|
-
# @param [Array[GroupDocs::Document::Change]] changes Comparison changes to update (accept or reject)
|
1039
|
-
# @option id [Float] :id
|
1040
|
-
# @option type [String] :type
|
1041
|
-
# @option action [String] :action
|
1042
|
-
# @option Page [Array] :page
|
1043
|
-
# @option box [Array] :box
|
1044
|
-
# @option text [String] :text
|
1045
|
-
# @param [Hash] access Access credentials
|
1046
|
-
# @option access [String] :client_id
|
1047
|
-
# @option access [String] :private_key
|
1048
|
-
# @return [GroupDocs::Change]
|
1049
|
-
#
|
1050
|
-
def update_changes!(changes, access = {})
|
1051
|
-
if changes.is_a?(Array)
|
1052
|
-
changes.each do |e|
|
1053
|
-
e.is_a?(GroupDocs::Document::Change) or raise ArgumentError,
|
1054
|
-
"Change should be GroupDocs::Document::Change object, received: #{e.inspect}"
|
1055
|
-
end
|
1056
|
-
else
|
1057
|
-
raise ArgumentError, "Changes should be Array , received: #{changes.inspect}"
|
1058
|
-
end
|
1059
|
-
api = Api::Request.new do |request|
|
1060
|
-
request[:access] = access
|
1061
|
-
request[:method] = :PUT
|
1062
|
-
request[:path] = "/comparison/public/#{file.guid}/changes"
|
1063
|
-
request[:request_body] = changes
|
1064
|
-
end
|
1065
|
-
api.execute!
|
1066
|
-
end
|
1067
|
-
|
1068
|
-
#
|
1069
|
-
# @Changed in release 1.5.9
|
1070
|
-
# Returns an array of changes in document.
|
1071
|
-
#
|
1072
|
-
# @example
|
1073
|
-
# document_one = GroupDocs::Storage::Folder.list![0].to_document
|
1074
|
-
# document_two = GroupDocs::Storage::Folder.list![1].to_document
|
1075
|
-
# job = document_one.compare!(document_two)
|
1076
|
-
# sleep(5) # wait for server to finish comparing
|
1077
|
-
# result = job.documents![:outputs].first
|
1078
|
-
# result.changes!
|
1079
|
-
#
|
1080
|
-
# @param [Hash] access Access credentials
|
1081
|
-
# @option access [String] :client_id
|
1082
|
-
# @option access [String] :private_key
|
1083
|
-
#
|
1084
|
-
def changes!(access = {})
|
1085
|
-
api = Api::Request.new do |request|
|
1086
|
-
request[:access] = access
|
1087
|
-
request[:method] = :GET
|
1088
|
-
request[:path] = "/comparison/public/#{file.guid}/changes"
|
1089
|
-
end
|
1090
|
-
json = api.execute!
|
1091
|
-
|
1092
|
-
json[:changes].map do |change|
|
1093
|
-
Document::Change.new(change)
|
1094
|
-
end
|
1095
|
-
end
|
1096
|
-
|
1097
|
-
#
|
1098
|
-
# Changed in release 1.5.8
|
1099
|
-
# Download comparison result file.
|
1100
|
-
#
|
1101
|
-
# @example
|
1102
|
-
# document_one = GroupDocs::Storage::Folder.list![0].to_document
|
1103
|
-
# document_two = GroupDocs::Storage::Folder.list![1].to_document
|
1104
|
-
# job = document_one.compare!(document_two)
|
1105
|
-
# sleep(5) # wait for server to finish comparing
|
1106
|
-
# result = job.documents![:outputs].first
|
1107
|
-
# result.download!("#{File.dirname(__FILE__)}", {:format => 'pdf'})
|
1108
|
-
#
|
1109
|
-
# @param [Hash] options
|
1110
|
-
# @option format [String] :format Comparison result file GUID #
|
1111
|
-
# @param [Hash] access Access credentials
|
1112
|
-
# @option access [String] :client_id
|
1113
|
-
# @option access [String] :private_key
|
1114
|
-
#
|
1115
|
-
#
|
1116
|
-
def download!( path, options = {}, access = {})
|
1117
|
-
api = Api::Request.new do |request|
|
1118
|
-
request[:access] = access
|
1119
|
-
request[:method] = :DOWNLOAD
|
1120
|
-
request[:path] = "/comparison/public/#{file.guid}/download"
|
1121
|
-
end
|
1122
|
-
api.add_params(options)
|
1123
|
-
response = api.execute!
|
1124
|
-
|
1125
|
-
if file.name.split('.').last != options[:format]
|
1126
|
-
file_name = file.name.delete!(file.name.split('.').last) + options[:format]
|
1127
|
-
else
|
1128
|
-
file_name = file.name
|
1129
|
-
end
|
1130
|
-
filepath = "#{path}/#{file_name}"
|
1131
|
-
Object::File.open(filepath, 'wb') do |file|
|
1132
|
-
file.write(response)
|
1133
|
-
end
|
1134
|
-
|
1135
|
-
end
|
1136
|
-
|
1137
|
-
#
|
1138
|
-
# Returns document annotations collaborators.
|
1139
|
-
#
|
1140
|
-
# @param [Hash] access Access credentials
|
1141
|
-
# @option access [String] :client_id
|
1142
|
-
# @option access [String] :private_key
|
1143
|
-
# @return [Array<GroupDocs::User>]
|
1144
|
-
#
|
1145
|
-
def collaborators!(access = {})
|
1146
|
-
json = Api::Request.new do |request|
|
1147
|
-
request[:access] = access
|
1148
|
-
request[:method] = :GET
|
1149
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
|
1150
|
-
end.execute!
|
1151
|
-
|
1152
|
-
json[:collaborators].map do |collaborator|
|
1153
|
-
User.new(collaborator)
|
1154
|
-
end
|
1155
|
-
end
|
1156
|
-
|
1157
|
-
#
|
1158
|
-
# Sets document annotations collaborators to given emails.
|
1159
|
-
#
|
1160
|
-
# @param [Array<String>] emails List of collaborators' email addresses
|
1161
|
-
# @param [Integer] version Annotation version
|
1162
|
-
# @param [Hash] access Access credentials
|
1163
|
-
# @option access [String] :client_id
|
1164
|
-
# @option access [String] :private_key
|
1165
|
-
# @return [Array<GroupDocs::User>]
|
1166
|
-
#
|
1167
|
-
def set_collaborators!(emails, version = 1, access = {})
|
1168
|
-
json = Api::Request.new do |request|
|
1169
|
-
request[:access] = access
|
1170
|
-
request[:method] = :PUT
|
1171
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/version/#{version}/collaborators"
|
1172
|
-
request[:request_body] = emails
|
1173
|
-
end.execute!
|
1174
|
-
|
1175
|
-
json[:collaborators].map do |collaborator|
|
1176
|
-
User.new(collaborator)
|
1177
|
-
end
|
1178
|
-
end
|
1179
|
-
|
1180
|
-
#
|
1181
|
-
# Adds document annotations collaborator.
|
1182
|
-
#
|
1183
|
-
# @param [GroupDocs::User] collaborator
|
1184
|
-
# @param [Hash] access Access credentials
|
1185
|
-
# @option access [String] :client_id
|
1186
|
-
# @option access [String] :private_key
|
1187
|
-
#
|
1188
|
-
def add_collaborator!(collaborator, access = {})
|
1189
|
-
collaborator.is_a?(GroupDocs::User) or raise ArgumentError,
|
1190
|
-
"Collaborator should be GroupDocs::User object, received: #{collaborator.inspect}"
|
1191
|
-
|
1192
|
-
Api::Request.new do |request|
|
1193
|
-
request[:access] = access
|
1194
|
-
request[:method] = :POST
|
1195
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
|
1196
|
-
request[:request_body] = collaborator.to_hash
|
1197
|
-
end.execute!
|
1198
|
-
end
|
1199
|
-
|
1200
|
-
|
1201
|
-
#
|
1202
|
-
# Delete document reviewer
|
1203
|
-
#
|
1204
|
-
# @param [String] reviewerId Reviewer Id
|
1205
|
-
# @param [Hash] access Access credentials
|
1206
|
-
# @option access [String] :client_id
|
1207
|
-
# @option access [String] :private_key
|
1208
|
-
#
|
1209
|
-
def remove_collaborators!(reviewerId, access = {})
|
1210
|
-
Api::Request.new do |request|
|
1211
|
-
request[:access] = access
|
1212
|
-
request[:method] = :DELETE
|
1213
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators/#{reviewerId}"
|
1214
|
-
end.execute!
|
1215
|
-
|
1216
|
-
end
|
1217
|
-
|
1218
|
-
#
|
1219
|
-
# Sets reviewers for document.
|
1220
|
-
#
|
1221
|
-
# @example Change reviewer rights
|
1222
|
-
# reviewers = document.collaborators!
|
1223
|
-
# reviewers.each do |reviewer|
|
1224
|
-
# reviewer.access_rights = %w(view)
|
1225
|
-
# end
|
1226
|
-
# document.set_reviewers! reviewers
|
1227
|
-
#
|
1228
|
-
# @param [Array<GroupDocs::User>] reviewers
|
1229
|
-
# @param [Hash] access Access credentials
|
1230
|
-
# @option access [String] :client_id
|
1231
|
-
# @option access [String] :private_key
|
1232
|
-
#
|
1233
|
-
def set_reviewers!(reviewers, access = {})
|
1234
|
-
Api::Request.new do |request|
|
1235
|
-
request[:access] = access
|
1236
|
-
request[:method] = :PUT
|
1237
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/reviewerRights"
|
1238
|
-
request[:request_body] = reviewers.map(&:to_hash)
|
1239
|
-
end.execute!
|
1240
|
-
end
|
1241
|
-
|
1242
|
-
#
|
1243
|
-
# Returns an array of access rights for shared link.
|
1244
|
-
#
|
1245
|
-
# @param [Hash] access Access credentials
|
1246
|
-
# @option access [String] :client_id
|
1247
|
-
# @option access [String] :private_key
|
1248
|
-
# @return [Array<Symbol>]
|
1249
|
-
#
|
1250
|
-
def shared_link_access_rights!(access = {})
|
1251
|
-
json = Api::Request.new do |request|
|
1252
|
-
request[:access] = access
|
1253
|
-
request[:method] = :GET
|
1254
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
|
1255
|
-
end.execute!
|
1256
|
-
|
1257
|
-
if json[:accessRights]
|
1258
|
-
convert_byte_to_access_rights json[:accessRights]
|
1259
|
-
else
|
1260
|
-
[]
|
1261
|
-
end
|
1262
|
-
end
|
1263
|
-
|
1264
|
-
#
|
1265
|
-
# Sets access rights for shared link.
|
1266
|
-
#
|
1267
|
-
# @param [Array<Symbol>] rights
|
1268
|
-
# @param [Hash] access Access credentials
|
1269
|
-
# @option access [String] :client_id
|
1270
|
-
# @option access [String] :private_key
|
1271
|
-
# @return [Array<Symbol>]
|
1272
|
-
#
|
1273
|
-
def set_shared_link_access_rights!(rights, access = {})
|
1274
|
-
Api::Request.new do |request|
|
1275
|
-
request[:access] = access
|
1276
|
-
request[:method] = :PUT
|
1277
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
|
1278
|
-
request[:request_body] = convert_access_rights_to_byte(rights)
|
1279
|
-
|
1280
|
-
end.execute!
|
1281
|
-
end
|
1282
|
-
|
1283
|
-
#
|
1284
|
-
# Sets session callback URL.
|
1285
|
-
#
|
1286
|
-
# @param [String] url Callback URL
|
1287
|
-
# @param [Hash] access Access credentials
|
1288
|
-
# @option access [String] :client_id
|
1289
|
-
# @option access [String] :private_key
|
1290
|
-
#
|
1291
|
-
def set_session_callback!(url, access = {})
|
1292
|
-
Api::Request.new do |request|
|
1293
|
-
request[:access] = access
|
1294
|
-
request[:method] = :PUT
|
1295
|
-
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sessionCallbackUrl"
|
1296
|
-
request[:request_body] = url
|
1297
|
-
end.execute!
|
1298
|
-
end
|
1299
|
-
|
1300
|
-
#
|
1301
|
-
# Pass all unknown methods to file.
|
1302
|
-
#
|
1303
|
-
|
1304
|
-
|
1305
|
-
def method_missing(method, *args, &blk)
|
1306
|
-
file.respond_to?(method) ? file.send(method, *args, &blk) : super
|
1307
|
-
end
|
1308
|
-
|
1309
|
-
def respond_to?(method)
|
1310
|
-
super or file.respond_to?(method)
|
1311
|
-
end
|
1312
|
-
|
1313
|
-
|
1314
|
-
#
|
1315
|
-
# added in release 1.5.8
|
1316
|
-
#
|
1317
|
-
# Returns document hyperlinks
|
1318
|
-
#
|
1319
|
-
# @param [Hash] access Access credentials
|
1320
|
-
# @option access [String] :client_id
|
1321
|
-
# @option access [String] :private_key
|
1322
|
-
#
|
1323
|
-
def hyperlinks!(access = {})
|
1324
|
-
json = Api::Request.new do |request|
|
1325
|
-
request[:access] = access
|
1326
|
-
request[:method] = :GET
|
1327
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/hyperlinks"
|
1328
|
-
end.execute!
|
1329
|
-
|
1330
|
-
json[:links]
|
1331
|
-
end
|
1332
|
-
|
1333
|
-
#
|
1334
|
-
# Changed in release 1.5.8
|
1335
|
-
#
|
1336
|
-
#
|
1337
|
-
# Public Sign document
|
1338
|
-
#
|
1339
|
-
# @param [String] document Document GUID
|
1340
|
-
# @param [Hash] settings Settings of the signing document
|
1341
|
-
# @param settings [String] waterMarkText
|
1342
|
-
# @param settings [String] waterMarkImage
|
1343
|
-
# @param settings [String] name (required)
|
1344
|
-
# @param settings [Double] top (required)
|
1345
|
-
# @param settings [Double] left (required)
|
1346
|
-
# @param settings [Double] width (required)
|
1347
|
-
# @param settings [Double] height (required)
|
1348
|
-
# @param settings [String] placeSignatureOn (required)
|
1349
|
-
# @param settings [String] data
|
1350
|
-
# @param [Hash] access Access credentials
|
1351
|
-
# @option access [String] :client_id
|
1352
|
-
# @option access [String] :private_key
|
1353
|
-
# @return [Array]
|
1354
|
-
#
|
1355
|
-
def public_sign_document!(options = {}, access = {})
|
1356
|
-
json = Api::Request.new do |request|
|
1357
|
-
request[:access] = access
|
1358
|
-
request[:method] = :POST
|
1359
|
-
request[:path] = "/signature/public/documents/#{file.guid}/sign"
|
1360
|
-
request[:request_body] = options
|
1361
|
-
end.execute!
|
1362
|
-
|
1363
|
-
json[:jobId]
|
1364
|
-
end
|
1365
|
-
|
1366
|
-
#
|
1367
|
-
# Changed in release 1.5.8
|
1368
|
-
#
|
1369
|
-
#
|
1370
|
-
# Get document fields
|
1371
|
-
#
|
1372
|
-
# @param [String] document Document GUID
|
1373
|
-
# @param [Hash] settings Settings of the signing document
|
1374
|
-
# @param [Hash] access Access credentials
|
1375
|
-
# @option access [String] :client_id
|
1376
|
-
# @option access [String] :private_key
|
1377
|
-
# @return [Array]
|
1378
|
-
#
|
1379
|
-
def self.public_fields!(access = {})
|
1380
|
-
Api::Request.new do |request|
|
1381
|
-
request[:access] = access
|
1382
|
-
request[:method] = :GET
|
1383
|
-
request[:path] = "/signature/public/documents/#{file.guid}/fields"
|
1384
|
-
end.execute!
|
1385
|
-
end
|
1386
|
-
|
1387
|
-
# changed in release 2.1.0
|
1388
|
-
#
|
1389
|
-
# Get template fields.
|
1390
|
-
#
|
1391
|
-
# @param [Hash] access Access credentials
|
1392
|
-
# @option access [String] :client_id
|
1393
|
-
# @option access [String] :private_key
|
1394
|
-
#
|
1395
|
-
def editor_fields!(access = {})
|
1396
|
-
Api::Request.new do |request|
|
1397
|
-
request[:access] = access
|
1398
|
-
request[:method] = :GET
|
1399
|
-
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editor_fields"
|
1400
|
-
end.execute!
|
1401
|
-
end
|
1402
|
-
|
1403
|
-
# added in release 1.7.0
|
1404
|
-
#
|
1405
|
-
# Create questionnaire template from file.
|
1406
|
-
#
|
1407
|
-
# @example
|
1408
|
-
#
|
1409
|
-
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1410
|
-
# field = GroupDocs::Document::TemplateEditorFields.new
|
1411
|
-
# field.name = 'test'
|
1412
|
-
# field.fieldtype = 'TextBox'
|
1413
|
-
# field.page = 1
|
1414
|
-
# file.questionnaire_template!([field] )
|
1415
|
-
#
|
1416
|
-
#
|
1417
|
-
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1418
|
-
# @param [Hash] access Access credentials
|
1419
|
-
# @option access [String] :client_id
|
1420
|
-
# @option access [String] :private_key
|
1421
|
-
#
|
1422
|
-
def questionnaire_template!(fields, access = {})
|
1423
|
-
|
1424
|
-
fields.each do |field|
|
1425
|
-
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1426
|
-
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1427
|
-
end
|
1428
|
-
|
1429
|
-
json = Api::Request.new do |request|
|
1430
|
-
request[:access] = access
|
1431
|
-
request[:method] = :POST
|
1432
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates"
|
1433
|
-
request[:request_body] = fields
|
1434
|
-
end.execute!
|
1435
|
-
json[:templateFields].map do |field|
|
1436
|
-
Document::Field.new(field)
|
1437
|
-
end
|
1438
|
-
end
|
1439
|
-
|
1440
|
-
# added in release 1.8.0
|
1441
|
-
#
|
1442
|
-
# Add template editor fields to the specific document
|
1443
|
-
#
|
1444
|
-
# @example
|
1445
|
-
#
|
1446
|
-
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1447
|
-
# field = GroupDocs::Document::TemplateEditorFields.new
|
1448
|
-
# field.name = 'test'
|
1449
|
-
# field.fieldtype = 'TextBox'
|
1450
|
-
# field.page = 1
|
1451
|
-
# file.add_questionnaire_template!([field] )
|
1452
|
-
#
|
1453
|
-
#
|
1454
|
-
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1455
|
-
# @param [Hash] access Access credentials
|
1456
|
-
# @option access [String] :client_id
|
1457
|
-
# @option access [String] :private_key
|
1458
|
-
#
|
1459
|
-
def add_questionnaire_template!(fields, access = {})
|
1460
|
-
|
1461
|
-
fields.each do |field|
|
1462
|
-
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1463
|
-
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1464
|
-
end
|
1465
|
-
|
1466
|
-
json = Api::Request.new do |request|
|
1467
|
-
request[:access] = access
|
1468
|
-
request[:method] = :POST
|
1469
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/add"
|
1470
|
-
request[:request_body] = fields
|
1471
|
-
end.execute!
|
1472
|
-
json[:templateFields].map do |field|
|
1473
|
-
Document::Field.new(field)
|
1474
|
-
end
|
1475
|
-
end
|
1476
|
-
|
1477
|
-
|
1478
|
-
# added in release 1.8.0
|
1479
|
-
#
|
1480
|
-
# Update template's fields
|
1481
|
-
#
|
1482
|
-
# @example
|
1483
|
-
#
|
1484
|
-
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1485
|
-
# field = GroupDocs::Document::TemplateEditorFields.new
|
1486
|
-
# field.name = 'test'
|
1487
|
-
# field.fieldtype = 'TextBox'
|
1488
|
-
# field.page = 1
|
1489
|
-
# file.update_questionnaire_template!([field] )
|
1490
|
-
#
|
1491
|
-
#
|
1492
|
-
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1493
|
-
# @param [Hash] access Access credentials
|
1494
|
-
# @option access [String] :client_id
|
1495
|
-
# @option access [String] :private_key
|
1496
|
-
#
|
1497
|
-
def update_questionnaire_template!(fields, access = {})
|
1498
|
-
|
1499
|
-
fields.each do |field|
|
1500
|
-
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1501
|
-
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1502
|
-
end
|
1503
|
-
|
1504
|
-
json = Api::Request.new do |request|
|
1505
|
-
request[:access] = access
|
1506
|
-
request[:method] = :PUT
|
1507
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/update"
|
1508
|
-
request[:request_body] = fields
|
1509
|
-
end.execute!
|
1510
|
-
json[:templateFields].map do |field|
|
1511
|
-
Document::Field.new(field)
|
1512
|
-
end
|
1513
|
-
end
|
1514
|
-
|
1515
|
-
# added in release 1.8.0
|
1516
|
-
#
|
1517
|
-
# Delete template's fields
|
1518
|
-
#
|
1519
|
-
# @example
|
1520
|
-
#
|
1521
|
-
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1522
|
-
# field = file.editor_fields!
|
1523
|
-
# file.delete_questionnaire_template!([field] )
|
1524
|
-
#
|
1525
|
-
#
|
1526
|
-
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1527
|
-
# @param [Hash] access Access credentials
|
1528
|
-
# @option access [String] :client_id
|
1529
|
-
# @option access [String] :private_key
|
1530
|
-
#
|
1531
|
-
def delete_questionnaire_template!(fields, access = {})
|
1532
|
-
|
1533
|
-
fields.each do |field|
|
1534
|
-
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1535
|
-
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1536
|
-
end
|
1537
|
-
|
1538
|
-
json = Api::Request.new do |request|
|
1539
|
-
request[:access] = access
|
1540
|
-
request[:method] = :DELETE
|
1541
|
-
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/delete"
|
1542
|
-
request[:request_body] = fields
|
1543
|
-
end.execute!
|
1544
|
-
json[:templateFields].map do |field|
|
1545
|
-
Document::Field.new(field)
|
1546
|
-
end
|
1547
|
-
end
|
1548
|
-
|
1549
|
-
end # Document
|
1550
|
-
end # GroupDocs
|
1
|
+
module GroupDocs
|
2
|
+
class Document < Api::Entity
|
3
|
+
|
4
|
+
require 'groupdocs/document/annotation'
|
5
|
+
require 'groupdocs/document/change'
|
6
|
+
require 'groupdocs/document/field'
|
7
|
+
require 'groupdocs/document/metadata'
|
8
|
+
require 'groupdocs/document/rectangle'
|
9
|
+
require 'groupdocs/document/view'
|
10
|
+
require 'groupdocs/document/editor'
|
11
|
+
require 'groupdocs/document/style'
|
12
|
+
require 'groupdocs/document/page'
|
13
|
+
|
14
|
+
|
15
|
+
ACCESS_MODES = {
|
16
|
+
:private => 0,
|
17
|
+
:restricted => 1,
|
18
|
+
:public => 2,
|
19
|
+
:inherited => 254,
|
20
|
+
:denied => 255,
|
21
|
+
}
|
22
|
+
|
23
|
+
include Api::Helpers::AccessMode
|
24
|
+
include Api::Helpers::AccessRights
|
25
|
+
include Api::Helpers::Status
|
26
|
+
extend Api::Helpers::MIME
|
27
|
+
|
28
|
+
#
|
29
|
+
# Returns an array of views for all documents.
|
30
|
+
#
|
31
|
+
# @param [Hash] options
|
32
|
+
# @option options [Integer] :page_index Page to start with
|
33
|
+
# @option options [Integer] :page_size Total number of entries
|
34
|
+
# @param [Hash] access Access credentials
|
35
|
+
# @option access [String] :client_id
|
36
|
+
# @option access [String] :private_key
|
37
|
+
# @return [Array<GroupDocs::Document::View>]
|
38
|
+
#
|
39
|
+
def self.views!(options = {}, access = {})
|
40
|
+
api = Api::Request.new do |request|
|
41
|
+
request[:access] = access
|
42
|
+
request[:method] = :GET
|
43
|
+
request[:path] = '/doc/{{client_id}}/views'
|
44
|
+
end
|
45
|
+
api.add_params(options)
|
46
|
+
json = api.execute!
|
47
|
+
|
48
|
+
json[:views].map do |view|
|
49
|
+
Document::View.new(view)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Returns an array of all templates (documents in "Templates" directory).
|
55
|
+
#
|
56
|
+
# @param [Hash] options Options
|
57
|
+
# @option options [String] :orderBy Order by column
|
58
|
+
# @option options [Boolean] :isAscending Order by ascending or descending
|
59
|
+
# @param [Hash] access Access credentials
|
60
|
+
# @option access [String] :client_id
|
61
|
+
# @option access [String] :private_key
|
62
|
+
# @return [Array<GroupDocs::Document>]
|
63
|
+
#
|
64
|
+
def self.templates!(options = {}, access = {})
|
65
|
+
api = Api::Request.new do |request|
|
66
|
+
request[:access] = access
|
67
|
+
request[:method] = :GET
|
68
|
+
request[:path] = '/merge/{{client_id}}/templates'
|
69
|
+
end
|
70
|
+
api.add_params(options)
|
71
|
+
json = api.execute!
|
72
|
+
json[:templates].map do |template|
|
73
|
+
template.merge!(:file => Storage::File.new(template))
|
74
|
+
Document.new(template)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Signs given documents with signatures.
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# # prepare documents
|
83
|
+
# file_one = GroupDocs::Storage::File.new(name: 'document_one.doc', local_path: '~/Documents/document_one.doc')
|
84
|
+
# file_two = GroupDocs::Storage::File.new(name: 'document_one.pdf', local_path: '~/Documents/document_one.pdf')
|
85
|
+
# document_one = file_one.to_document
|
86
|
+
# document_two = file_two.to_document
|
87
|
+
# # prepare signatures
|
88
|
+
# signature_one = GroupDocs::Signature.new(name: 'John Smith', image_path: '~/Documents/signature_one.png')
|
89
|
+
# signature_two = GroupDocs::Signature.new(name: 'Sara Smith', image_path: '~/Documents/signature_two.png')
|
90
|
+
# signature_one.position = { top: 0.1, left: 0.07, width: 50, height: 50 }
|
91
|
+
# signature_one.email = "test1@mail.com"
|
92
|
+
# signature_two.position = { top: 0.2, left: 0.2, width: 100, height: 100 }
|
93
|
+
# signature_one.email = "test1@mail.com"
|
94
|
+
# # sign documents and download results
|
95
|
+
# signed_documents = GroupDocs::Document.sign_documents!([document_one, document_two], [signature_one, signature_two])
|
96
|
+
# signed_documents.each do |document|
|
97
|
+
# document.file.download! '~/Documents'
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# @param [Array<GroupDocs::Document>] documents Each document file should have "#name" and "#local_path"
|
101
|
+
# @param [Array<GroupDocs::Signature>] signatures Each signature should have "#name", "#image_path" and "#position"
|
102
|
+
#
|
103
|
+
def self.sign_documents!(documents, signatures, options = {}, access = {})
|
104
|
+
documents.each do |document|
|
105
|
+
document.is_a?(Document) or raise ArgumentError, "Each document should be GroupDocs::Document object, received: #{document.inspect}"
|
106
|
+
document.file.name or raise ArgumentError, "Each document file should have name, received: #{document.file.name.inspect}"
|
107
|
+
document.file.local_path or raise ArgumentError, "Each document file should have local_path, received: #{document.file.local_path.inspect}"
|
108
|
+
end
|
109
|
+
signatures.each do |signature|
|
110
|
+
signature.is_a?(Signature) or raise ArgumentError, "Each signature should be GroupDocs::Signature object, received: #{signature.inspect}"
|
111
|
+
signature.name or raise ArgumentError, "Each signature should have name, received: #{signature.name.inspect}"
|
112
|
+
signature.image_path or raise ArgumentError, "Each signature should have image_path, received: #{signature.image_path.inspect}"
|
113
|
+
signature.position or raise ArgumentError, "Each signature should have position, received: #{signature.position.inspect}"
|
114
|
+
end
|
115
|
+
|
116
|
+
documents_to_sign = []
|
117
|
+
documents.map(&:file).each do |file|
|
118
|
+
document = { :name => file.name }
|
119
|
+
contents = File.open(file.local_path, 'rb').read
|
120
|
+
contents = Base64.strict_encode64(contents)
|
121
|
+
document.merge!(:data => "data:#{mime_type(file.local_path)};base64,#{contents}")
|
122
|
+
|
123
|
+
documents_to_sign << document
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
signers = []
|
128
|
+
signatures.each do |signature|
|
129
|
+
contents = File.open(signature.image_path, 'rb').read
|
130
|
+
contents = Base64.strict_encode64(contents)
|
131
|
+
signer = { :name => signature.name, :data => "data:#{mime_type(signature.image_path)};base64,#{contents}" }
|
132
|
+
signer.merge!(signature.position)
|
133
|
+
# place signature on is not implemented yet
|
134
|
+
signer.merge!(:placeSignatureOn => nil)
|
135
|
+
signer.merge!(:email => signature.email)
|
136
|
+
|
137
|
+
signers << signer
|
138
|
+
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
json = Api::Request.new do |request|
|
143
|
+
request[:access] = access
|
144
|
+
request[:method] = :POST
|
145
|
+
request[:path] = '/signature/{{client_id}}/sign'
|
146
|
+
request[:request_body] = { :documents => documents_to_sign, :signers => signers }
|
147
|
+
end.execute!
|
148
|
+
json[:jobId]
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
#
|
153
|
+
# Get sign documents status
|
154
|
+
#
|
155
|
+
# @param [String] job_guid
|
156
|
+
# @param [Hash] access Access credentials
|
157
|
+
# @option access [String] :client_id
|
158
|
+
# @option access [String] :private_key
|
159
|
+
#
|
160
|
+
def document_status!(job_guid, access = {})
|
161
|
+
json = Api::Request.new do |request|
|
162
|
+
request[:access] = access
|
163
|
+
request[:method] = :PUT
|
164
|
+
request[:path] = "/signature/{{client_id}}/documents/#{job_guid}"
|
165
|
+
end.execute!
|
166
|
+
|
167
|
+
json[:documents]
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# Cnanged in release 2.0.0
|
172
|
+
#
|
173
|
+
# Returns a document metadata by given path.
|
174
|
+
#
|
175
|
+
# @param [String] path Full path to document
|
176
|
+
# @param [Hash] access Access credentials
|
177
|
+
# @option access [String] :client_id
|
178
|
+
# @option access [String] :private_key
|
179
|
+
# @return [Array<GroupDocs::Document::View>]
|
180
|
+
#
|
181
|
+
def self.metadata!(path, access = {})
|
182
|
+
json = Api::Request.new do |request|
|
183
|
+
request[:access] = access
|
184
|
+
request[:method] = :GET
|
185
|
+
request[:path] = "/doc/{{client_id}}/files/#{path}"
|
186
|
+
end.execute!
|
187
|
+
|
188
|
+
Document::MetaData.new do |metadata|
|
189
|
+
metadata.id = json[:id]
|
190
|
+
metadata.guid = json[:guid]
|
191
|
+
metadata.page_count = json[:page_count]
|
192
|
+
metadata.views_count = json[:views_count]
|
193
|
+
metadata.type = json[:type]
|
194
|
+
metadata.url = json[:url]
|
195
|
+
if json[:last_view]
|
196
|
+
metadata.last_view = json[:last_view]
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# @attr [GroupDocs::Storage::File] file
|
202
|
+
attr_accessor :file
|
203
|
+
# @attr [Time] process_date
|
204
|
+
attr_accessor :process_date
|
205
|
+
# @attr [Array<GroupDocs::Storage::File>] outputs
|
206
|
+
attr_accessor :outputs
|
207
|
+
# @attr [Array<Symbol>] output_formats
|
208
|
+
attr_accessor :output_formats
|
209
|
+
# @attr [Symbol] status
|
210
|
+
attr_accessor :status
|
211
|
+
# @attr [Integer] order
|
212
|
+
attr_accessor :order
|
213
|
+
# @attr [Integer] field_count
|
214
|
+
attr_accessor :field_count
|
215
|
+
|
216
|
+
#added in release 1.6.0
|
217
|
+
# @attr [String] fieldType
|
218
|
+
attr_accessor :fieldType
|
219
|
+
# @attr [Int] dependent_questionnaires_count
|
220
|
+
attr_accessor :dependent_questionnaires_count
|
221
|
+
# @attr [Long] upload_time
|
222
|
+
attr_accessor :upload_time
|
223
|
+
|
224
|
+
|
225
|
+
#added in release 2.0.0
|
226
|
+
# @attr [String] documentDescription
|
227
|
+
attr_accessor :documentDescription
|
228
|
+
|
229
|
+
|
230
|
+
[
|
231
|
+
:news ,
|
232
|
+
:alerts ,
|
233
|
+
:support ,
|
234
|
+
:is_real_time_broadcast ,
|
235
|
+
:is_scroll_broadcast ,
|
236
|
+
:is_zoom_broadcast ,
|
237
|
+
:is_annotation_navigation_widget ,
|
238
|
+
:is_annotation_zoom_widget ,
|
239
|
+
:is_annotation_download_widget ,
|
240
|
+
:is_annotation_print_widget ,
|
241
|
+
:is_annotation_help_widget ,
|
242
|
+
:is_right_panel ,
|
243
|
+
:is_thumbnails_panel ,
|
244
|
+
:is_toolbar ,
|
245
|
+
:is_text_annotation_button ,
|
246
|
+
:is_rectangle_annotation_button ,
|
247
|
+
:is_point_annotation_button ,
|
248
|
+
:is_strikeout_annotation_button ,
|
249
|
+
:is_polyline_annotation_button ,
|
250
|
+
:is_typewriter_annotation_button ,
|
251
|
+
:is_watermark_annotation_button ,
|
252
|
+
:is_viewer_navigation_widget ,
|
253
|
+
:is_viewer_zoom_widget ,
|
254
|
+
:is_viewer_download_widget ,
|
255
|
+
:is_viewer_print_widget ,
|
256
|
+
:is_viewer_help_widget ,
|
257
|
+
].each do |option|
|
258
|
+
# @attr [Boolean] option
|
259
|
+
attr_accessor :"#{option}_enabled"
|
260
|
+
end
|
261
|
+
[
|
262
|
+
:standard_header_always ,
|
263
|
+
:annotation_document_name ,
|
264
|
+
:viewer_document_name ,
|
265
|
+
].each do |option|
|
266
|
+
# @attr [Boolean] option
|
267
|
+
attr_accessor :"is_#{option}_shown"
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
#
|
272
|
+
# Coverts passed array of attributes hash to array of GroupDocs::Storage::File.
|
273
|
+
#
|
274
|
+
# @param [Array<Hash>] outputs Array of file attributes hashes
|
275
|
+
#
|
276
|
+
def outputs=(outputs)
|
277
|
+
if outputs
|
278
|
+
@outputs = outputs.map do |output|
|
279
|
+
GroupDocs::Storage::File.new(output)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
#
|
285
|
+
# Returns output formats in human-readable format.
|
286
|
+
#
|
287
|
+
# @return [Array<Symbol>]
|
288
|
+
#
|
289
|
+
def output_formats
|
290
|
+
@output_formats.split(',').map(&:to_sym)
|
291
|
+
end
|
292
|
+
|
293
|
+
#
|
294
|
+
# Converts status to human-readable format.
|
295
|
+
#
|
296
|
+
# @return [Symbol]
|
297
|
+
#
|
298
|
+
def status
|
299
|
+
parse_status(@status)
|
300
|
+
end
|
301
|
+
|
302
|
+
#
|
303
|
+
# Converts timestamp which is return by API server to Time object.
|
304
|
+
#
|
305
|
+
# @return [Time]
|
306
|
+
#
|
307
|
+
def process_date
|
308
|
+
Time.at(@process_date / 1000)
|
309
|
+
end
|
310
|
+
|
311
|
+
# Compatibility with response JSON
|
312
|
+
alias_method :proc_date=, :process_date=
|
313
|
+
|
314
|
+
#
|
315
|
+
# Creates new GroupDocs::Document.
|
316
|
+
#
|
317
|
+
# You should avoid creating documents directly. Instead, use #to_document
|
318
|
+
# instance method of GroupDocs::Storage::File.
|
319
|
+
#
|
320
|
+
# @raise [ArgumentError] If file is not passed or is not an instance of GroupDocs::Storage::File
|
321
|
+
#
|
322
|
+
def initialize(options = {}, &blk)
|
323
|
+
super(options, &blk)
|
324
|
+
file.is_a?(GroupDocs::Storage::File) or raise ArgumentError,
|
325
|
+
"You have to pass GroupDocs::Storage::File object: #{file.inspect}."
|
326
|
+
end
|
327
|
+
|
328
|
+
#
|
329
|
+
# Returns a stream of bytes representing a particular document page image.
|
330
|
+
#
|
331
|
+
# @param [String] path Document path
|
332
|
+
# @param [String] name Name document (format - jpg)
|
333
|
+
# @example path = "#{File.dirname(__FILE__)}"
|
334
|
+
# name = "test.jpg"
|
335
|
+
# @param [Integer] page_number Document page number to get image for
|
336
|
+
# @param [Integer] dimension Image dimension "<width>x<height>"(500x600)
|
337
|
+
# @param [Hash] options
|
338
|
+
# @option options [Integer] :quality Image quality in range 1-100.
|
339
|
+
# @option options [Boolean] :use_pdf A flag indicating whether a document should be converted to PDF format before generating the image.
|
340
|
+
# @option options [Boolean] :expires The date and time in milliseconds since epoch the URL expires.
|
341
|
+
# @param [Hash] access Access credentials
|
342
|
+
# @option access [String] :client_id
|
343
|
+
# @option access [String] :private_key
|
344
|
+
# @return []
|
345
|
+
#
|
346
|
+
def page_image!(path, name, page_number, dimension, options = {}, access = {})
|
347
|
+
api = Api::Request.new do |request|
|
348
|
+
request[:access] = access
|
349
|
+
request[:method] = :DOWNLOAD
|
350
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/#{page_number}/images/#{dimension}"
|
351
|
+
end
|
352
|
+
api.add_params(options)
|
353
|
+
response = api.execute!
|
354
|
+
|
355
|
+
filepath = "#{path}/#{name}"
|
356
|
+
Object::File.open(filepath, 'wb') do |file|
|
357
|
+
file.write(response)
|
358
|
+
end
|
359
|
+
|
360
|
+
filepath
|
361
|
+
|
362
|
+
end
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
#
|
370
|
+
# Returns array of URLs to images representing document pages.
|
371
|
+
#
|
372
|
+
# @example
|
373
|
+
# file = GroupDocs::Storage::Folder.list!.last
|
374
|
+
# document = file.to_document
|
375
|
+
# document.page_images! 1024, 768, first_page: 0, page_count: 1
|
376
|
+
#
|
377
|
+
# @param [Integer] width Image width
|
378
|
+
# @param [Integer] height Image height
|
379
|
+
# @param [Hash] options
|
380
|
+
# @option options [Integer] :first_page Start page to return image for (starting with 0)
|
381
|
+
# @option options [Integer] :page_count Number of pages to return image for
|
382
|
+
# @option options [Integer] :quality
|
383
|
+
# @option options [Boolean] :use_pdf
|
384
|
+
# @option options [Boolean] :token
|
385
|
+
# @param [Hash] access Access credentials
|
386
|
+
# @option access [String] :client_id
|
387
|
+
# @option access [String] :private_key
|
388
|
+
# @return [Array<String>]
|
389
|
+
#
|
390
|
+
def page_images!(width, height, options = {}, access = {})
|
391
|
+
api = Api::Request.new do |request|
|
392
|
+
request[:access] = access
|
393
|
+
request[:method] = :GET
|
394
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/images/#{width}x#{height}/urls"
|
395
|
+
end
|
396
|
+
api.add_params(options)
|
397
|
+
json = api.execute!
|
398
|
+
|
399
|
+
json[:url]
|
400
|
+
end
|
401
|
+
|
402
|
+
|
403
|
+
#
|
404
|
+
# Returns editing metadata.
|
405
|
+
#
|
406
|
+
# @param [Hash] access Access credentials
|
407
|
+
# @option access [String] :client_id
|
408
|
+
# @option access [String] :private_key
|
409
|
+
#
|
410
|
+
def editlock!(access = {})
|
411
|
+
Api::Request.new do |request|
|
412
|
+
request[:access] = access
|
413
|
+
request[:method] = :GET
|
414
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock"
|
415
|
+
end.execute!
|
416
|
+
end
|
417
|
+
|
418
|
+
#
|
419
|
+
# Removes edit lock for a document and replaces the document with its edited copy
|
420
|
+
#
|
421
|
+
# @param [Hash] options
|
422
|
+
# @option options [String] :lockId Start page to return image for (starting with 0)
|
423
|
+
# @param [Hash] access Access credentials
|
424
|
+
# @option access [String] :client_id
|
425
|
+
# @option access [String] :private_key
|
426
|
+
# @return [Integer]
|
427
|
+
#
|
428
|
+
def editlock_clear!(options = {}, access = {})
|
429
|
+
api = Api::Request.new do |request|
|
430
|
+
request[:access] = access
|
431
|
+
request[:method] = :DELETE
|
432
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock"
|
433
|
+
end
|
434
|
+
api.add_params(options).execute!
|
435
|
+
end
|
436
|
+
|
437
|
+
#
|
438
|
+
# Returns tags assigned to the document
|
439
|
+
#
|
440
|
+
# @param [Hash] access Access credentials
|
441
|
+
# @option access [String] :client_id
|
442
|
+
# @option access [String] :private_key
|
443
|
+
# @return [Array<String>]
|
444
|
+
#
|
445
|
+
def tags!(access = {})
|
446
|
+
Api::Request.new do |request|
|
447
|
+
request[:access] = access
|
448
|
+
request[:method] = :GET
|
449
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
450
|
+
end.execute!
|
451
|
+
end
|
452
|
+
|
453
|
+
#
|
454
|
+
# Assign tags to the document.
|
455
|
+
#
|
456
|
+
# @param [Hash] access Access credentials
|
457
|
+
# @option access [String] :client_id
|
458
|
+
# @option access [String] :private_key
|
459
|
+
# @return [String]
|
460
|
+
#
|
461
|
+
def tags_set!(access = {})
|
462
|
+
Api::Request.new do |request|
|
463
|
+
request[:access] = access
|
464
|
+
request[:method] = :PUT
|
465
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
466
|
+
end.execute!
|
467
|
+
end
|
468
|
+
|
469
|
+
#
|
470
|
+
# Removes tags assigned to the document
|
471
|
+
#
|
472
|
+
# @param [Hash] access Access credentials
|
473
|
+
# @option access [String] :client_id
|
474
|
+
# @option access [String] :private_key
|
475
|
+
# @return [String]
|
476
|
+
#
|
477
|
+
def tags_clear!(access = {})
|
478
|
+
Api::Request.new do |request|
|
479
|
+
request[:access] = access
|
480
|
+
request[:method] = :DELETE
|
481
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags"
|
482
|
+
end.execute!
|
483
|
+
end
|
484
|
+
|
485
|
+
#
|
486
|
+
# Returns document content
|
487
|
+
#
|
488
|
+
# @param [String] content_type Content type
|
489
|
+
# @param [Hash] access Access credentials
|
490
|
+
# @option access [String] :client_id
|
491
|
+
# @option access [String] :private_key
|
492
|
+
# @return [String]
|
493
|
+
#
|
494
|
+
def content!(content_type, access = {})
|
495
|
+
json = Api::Request.new do |request|
|
496
|
+
request[:access] = access
|
497
|
+
request[:method] = :GET
|
498
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/content/#{content_type}"
|
499
|
+
end.execute!
|
500
|
+
|
501
|
+
json[:content]
|
502
|
+
end
|
503
|
+
|
504
|
+
#
|
505
|
+
# Returns array of URLs to images representing document pages thumbnails.
|
506
|
+
#
|
507
|
+
# @example
|
508
|
+
# file = GroupDocs::Storage::Folder.list!.last
|
509
|
+
# document = file.to_document
|
510
|
+
# document.thumbnails! first_page: 0, page_count: 1, width: 1024
|
511
|
+
#
|
512
|
+
# @param [Hash] options
|
513
|
+
# @option options [Integer] :page_number Start page to return image for (starting with 0)
|
514
|
+
# @option options [Integer] :page_count Number of pages to return image for
|
515
|
+
# @option options [Integer] :width
|
516
|
+
# @option options [Integer] :quality
|
517
|
+
# @option options [Boolean] :use_pdf
|
518
|
+
# @param [Hash] access Access credentials
|
519
|
+
# @option access [String] :client_id
|
520
|
+
# @option access [String] :private_key
|
521
|
+
# @return [Array<String>]
|
522
|
+
#
|
523
|
+
def thumbnails!(options = {}, access = {})
|
524
|
+
api = Api::Request.new do |request|
|
525
|
+
request[:access] = access
|
526
|
+
request[:method] = :POST
|
527
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/thumbnails"
|
528
|
+
end
|
529
|
+
api.add_params(options)
|
530
|
+
json = api.execute!
|
531
|
+
|
532
|
+
json[:image_urls]
|
533
|
+
end
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
#
|
538
|
+
# Returns access mode of document.
|
539
|
+
#
|
540
|
+
# @param [Hash] access Access credentials
|
541
|
+
# @option access [String] :client_id
|
542
|
+
# @option access [String] :private_key
|
543
|
+
# @return [Symbol] One of :private, :restricted or :public access modes
|
544
|
+
#
|
545
|
+
def access_mode!(access = {})
|
546
|
+
json = Api::Request.new do |request|
|
547
|
+
request[:access] = access
|
548
|
+
request[:method] = :GET
|
549
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/accessinfo"
|
550
|
+
end.execute!
|
551
|
+
|
552
|
+
parse_access_mode(json[:access])
|
553
|
+
end
|
554
|
+
|
555
|
+
#
|
556
|
+
# Sets access mode of document.
|
557
|
+
#
|
558
|
+
# @param [Symbol] mode One of :private, :restricted or :public access modes
|
559
|
+
# @param [Hash] access Access credentials
|
560
|
+
# @option access [String] :client_id
|
561
|
+
# @option access [String] :private_key
|
562
|
+
# @return [Symbol] Set access mode
|
563
|
+
#
|
564
|
+
def access_mode_set!(mode, access = {})
|
565
|
+
api = Api::Request.new do |request|
|
566
|
+
request[:access] = access
|
567
|
+
request[:method] = :PUT
|
568
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo"
|
569
|
+
end
|
570
|
+
api.add_params(:mode => ACCESS_MODES[mode])
|
571
|
+
json = api.execute!
|
572
|
+
|
573
|
+
parse_access_mode(json[:access])
|
574
|
+
end
|
575
|
+
# note that aliased version cannot accept access credentials hash
|
576
|
+
alias_method :access_mode=, :access_mode_set!
|
577
|
+
|
578
|
+
#
|
579
|
+
# Returns array of file formats document can be converted to.
|
580
|
+
#
|
581
|
+
# @param [Hash] access Access credentials
|
582
|
+
# @option access [String] :client_id
|
583
|
+
# @option access [String] :private_key
|
584
|
+
# @return [Array<Symbol>]
|
585
|
+
#
|
586
|
+
def formats!(access = {})
|
587
|
+
json = Api::Request.new do |request|
|
588
|
+
request[:access] = access
|
589
|
+
request[:method] = :GET
|
590
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.id}/formats"
|
591
|
+
end.execute!
|
592
|
+
|
593
|
+
json[:types].map do |format|
|
594
|
+
format.downcase.to_sym
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
#
|
599
|
+
# Cnanged in release 2.0.0
|
600
|
+
#
|
601
|
+
# Returns document metadata.
|
602
|
+
#
|
603
|
+
# @param [Hash] access Access credentials
|
604
|
+
# @option access [String] :client_id
|
605
|
+
# @option access [String] :private_key
|
606
|
+
# @return [GroupDocs::Document::MetaData]
|
607
|
+
#
|
608
|
+
def metadata!(access = {})
|
609
|
+
json = Api::Request.new do |request|
|
610
|
+
request[:access] = access
|
611
|
+
request[:method] = :GET
|
612
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/metadata"
|
613
|
+
end.execute!
|
614
|
+
|
615
|
+
Document::MetaData.new do |metadata|
|
616
|
+
metadata.id = json[:id]
|
617
|
+
metadata.guid = json[:guid]
|
618
|
+
metadata.page_count = json[:page_count]
|
619
|
+
metadata.views_count = json[:views_count]
|
620
|
+
metadata.type = json[:type]
|
621
|
+
metadata.url = json[:url]
|
622
|
+
if json[:last_view]
|
623
|
+
metadata.last_view = json[:last_view]
|
624
|
+
end
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
#
|
629
|
+
# Returns an array of document fields.
|
630
|
+
#
|
631
|
+
# @param [Hash] access Access credentials
|
632
|
+
# @option access [String] :client_id
|
633
|
+
# @option access [String] :private_key
|
634
|
+
# @return [Array<GroupDocs::Document::Field>]
|
635
|
+
#
|
636
|
+
def fields!(access = {})
|
637
|
+
api = Api::Request.new do |request|
|
638
|
+
request[:access] = access
|
639
|
+
request[:method] = :GET
|
640
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/fields"
|
641
|
+
end
|
642
|
+
api.add_params(:include_geometry => true)
|
643
|
+
json = api.execute!
|
644
|
+
|
645
|
+
json[:fields].map do |field|
|
646
|
+
Document::Field.new(field)
|
647
|
+
end
|
648
|
+
end
|
649
|
+
|
650
|
+
#
|
651
|
+
# Returns an array of users a document is shared with.
|
652
|
+
#
|
653
|
+
# @param [Hash] access Access credentials
|
654
|
+
# @option access [String] :client_id
|
655
|
+
# @option access [String] :private_key
|
656
|
+
# @return [Array<GroupDocs::User>]
|
657
|
+
#
|
658
|
+
def sharers!(access = {})
|
659
|
+
json = Api::Request.new do |request|
|
660
|
+
request[:access] = access
|
661
|
+
request[:method] = :GET
|
662
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo"
|
663
|
+
end.execute!
|
664
|
+
|
665
|
+
json[:sharers].map do |user|
|
666
|
+
User.new(user)
|
667
|
+
end
|
668
|
+
end
|
669
|
+
|
670
|
+
#
|
671
|
+
# Returns an array of users a document is shared with.
|
672
|
+
# @param [String] sharers_types
|
673
|
+
# @param [Hash] options
|
674
|
+
# @option options [String] :page_index
|
675
|
+
# @option options [String] :page_size
|
676
|
+
# @option options [String] :order_by
|
677
|
+
# @option options [Boolean] :order_ask
|
678
|
+
# @param [Hash] access Access credentials
|
679
|
+
# @option access [String] :client_id
|
680
|
+
# @option access [String] :private_key
|
681
|
+
# @return [Array<GroupDocs::User>]
|
682
|
+
#
|
683
|
+
def shared_documents!(sharers_types, options = {}, access = {})
|
684
|
+
api = Api::Request.new do |request|
|
685
|
+
request[:access] = access
|
686
|
+
request[:method] = :GET
|
687
|
+
request[:path] = "/doc/{{client_id}}/shares/#{sharers_types}"
|
688
|
+
end
|
689
|
+
api.add_params(options).execute!
|
690
|
+
|
691
|
+
end
|
692
|
+
|
693
|
+
#
|
694
|
+
# Sets document sharers to given emails.
|
695
|
+
#
|
696
|
+
# If empty array or nil passed, clears sharers.
|
697
|
+
#
|
698
|
+
# @param [Array] emails List of email addresses to share with
|
699
|
+
# @param [Hash] access Access credentials
|
700
|
+
# @option access [String] :client_id
|
701
|
+
# @option access [String] :private_key
|
702
|
+
# @return [Array<GroupDocs::User>]
|
703
|
+
#
|
704
|
+
def sharers_set!(emails, access = {})
|
705
|
+
if emails.nil? || emails.empty?
|
706
|
+
sharers_clear!(access)
|
707
|
+
else
|
708
|
+
json = Api::Request.new do |request|
|
709
|
+
request[:access] = access
|
710
|
+
request[:method] = :PUT
|
711
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers"
|
712
|
+
request[:request_body] = emails
|
713
|
+
end.execute!
|
714
|
+
|
715
|
+
json[:shared_users].map do |user|
|
716
|
+
User.new(user)
|
717
|
+
end
|
718
|
+
end
|
719
|
+
end
|
720
|
+
|
721
|
+
#
|
722
|
+
# Sets document password.
|
723
|
+
#
|
724
|
+
# @param [String] password New password for document
|
725
|
+
# @param [Hash] access Access credentials
|
726
|
+
# @option access [String] :client_id
|
727
|
+
# @option access [String] :private_key
|
728
|
+
# @return [Array<GroupDocs::User>]
|
729
|
+
#
|
730
|
+
def password_set!(password, access = {})
|
731
|
+
Api::Request.new do |request|
|
732
|
+
request[:access] = access
|
733
|
+
request[:method] = :PUT
|
734
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/password"
|
735
|
+
request[:request_body] = password
|
736
|
+
end.execute!
|
737
|
+
|
738
|
+
end
|
739
|
+
|
740
|
+
#
|
741
|
+
# Sets document user status.
|
742
|
+
#
|
743
|
+
# @param [String] status (Pending = 0, Accepted = 1, Declined = 2)
|
744
|
+
# @param [Hash] access Access credentials
|
745
|
+
# @option access [String] :client_id
|
746
|
+
# @option access [String] :private_key
|
747
|
+
# @return [String]
|
748
|
+
#
|
749
|
+
def user_status_set!(status, access = {})
|
750
|
+
Api::Request.new do |request|
|
751
|
+
request[:access] = access
|
752
|
+
request[:method] = :PUT
|
753
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/sharer"
|
754
|
+
request[:request_body] = status
|
755
|
+
end.execute!
|
756
|
+
|
757
|
+
end
|
758
|
+
|
759
|
+
#
|
760
|
+
# Clears sharers list.
|
761
|
+
#
|
762
|
+
# @param [Hash] access Access credentials
|
763
|
+
# @option access [String] :client_id
|
764
|
+
# @option access [String] :private_key
|
765
|
+
# @return nil
|
766
|
+
#
|
767
|
+
def sharers_clear!(access = {})
|
768
|
+
Api::Request.new do |request|
|
769
|
+
request[:access] = access
|
770
|
+
request[:method] = :DELETE
|
771
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers"
|
772
|
+
end.execute![:shared_users]
|
773
|
+
|
774
|
+
end
|
775
|
+
|
776
|
+
#
|
777
|
+
# Converts document to given format.
|
778
|
+
#
|
779
|
+
# @example
|
780
|
+
# document = GroupDocs::Storage::Folder.list!.first.to_document
|
781
|
+
# job = document.convert!(:docx)
|
782
|
+
# sleep(5) # wait for server to finish converting
|
783
|
+
# original_document = job.documents![:inputs].first
|
784
|
+
# converted_file = original_file.outputs.first
|
785
|
+
# converted_file.download!(File.dirname(__FILE__))
|
786
|
+
#
|
787
|
+
# @param [Symbol] format
|
788
|
+
# @param [Hash] options
|
789
|
+
# @option options [Boolean] :email_results
|
790
|
+
# @option options [String] :new_description
|
791
|
+
# @option options [String] :print_script
|
792
|
+
# @option options [String] :callback
|
793
|
+
# @param [Hash] access Access credentials
|
794
|
+
# @option access [String] :client_id
|
795
|
+
# @option access [String] :private_key
|
796
|
+
# @return [GroupDocs::Job] Created job
|
797
|
+
#
|
798
|
+
def convert!(format, options = {}, access = {})
|
799
|
+
options.merge!(:new_type => format)
|
800
|
+
|
801
|
+
api = Api::Request.new do |request|
|
802
|
+
request[:access] = access
|
803
|
+
request[:method] = :POST
|
804
|
+
request[:path] = "/async/{{client_id}}/files/#{file.guid}"
|
805
|
+
end
|
806
|
+
api.add_params(options)
|
807
|
+
json = api.execute!
|
808
|
+
|
809
|
+
Job.new(:id => json[:job_id])
|
810
|
+
end
|
811
|
+
|
812
|
+
#
|
813
|
+
# Creates new job to merge datasource into document.
|
814
|
+
#
|
815
|
+
# @param [GroupDocs::DataSource] datasource
|
816
|
+
# @param [Hash] options
|
817
|
+
# @option options [Boolean] :new_type New file format type
|
818
|
+
# @option options [Boolean] :email_results Set to true if converted document should be emailed
|
819
|
+
# @param [Hash] access Access credentials
|
820
|
+
# @option access [String] :client_id
|
821
|
+
# @option access [String] :private_key
|
822
|
+
# @return [GroupDocs::Job]
|
823
|
+
#
|
824
|
+
# @raise [ArgumentError] if datasource is not GroupDocs::DataSource object
|
825
|
+
#
|
826
|
+
def datasource!(datasource, options = {}, access = {})
|
827
|
+
datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
|
828
|
+
"Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}"
|
829
|
+
|
830
|
+
api = Api::Request.new do |request|
|
831
|
+
request[:access] = access
|
832
|
+
request[:method] = :POST
|
833
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources/#{datasource.id}"
|
834
|
+
end
|
835
|
+
api.add_params(options)
|
836
|
+
json = api.execute!
|
837
|
+
|
838
|
+
Job.new(:id => json[:job_id])
|
839
|
+
end
|
840
|
+
|
841
|
+
#
|
842
|
+
# Creates new job to merge datasource fields into document.
|
843
|
+
#
|
844
|
+
# @param [GroupDocs::DataSource] datasource
|
845
|
+
# @param [Hash] options
|
846
|
+
# @option options [Boolean] :new_type New file format type
|
847
|
+
# @option options [Boolean] :email_results Set to true if converted document should be emailed
|
848
|
+
# @option options [Boolean] :assembly_name
|
849
|
+
# @param [Array] datasourceFields (:name [String], :value [String], :contentType [String], :type [String], :nested_fields [<Array> datasourceFields])
|
850
|
+
# @param [Hash] access Access credentials
|
851
|
+
# @option access [String] :client_id
|
852
|
+
# @option access [String] :private_key
|
853
|
+
# @return [GroupDocs::Job]
|
854
|
+
#
|
855
|
+
# @raise [ArgumentError] if datasource is not GroupDocs::DataSource object
|
856
|
+
#
|
857
|
+
def datasource_fields!(datasource, options = {}, access = {})
|
858
|
+
datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
|
859
|
+
"Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}"
|
860
|
+
|
861
|
+
api = Api::Request.new do |request|
|
862
|
+
request[:access] = access
|
863
|
+
request[:method] = :POST
|
864
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources"
|
865
|
+
request[:request_body] = datasource.fields
|
866
|
+
end
|
867
|
+
api.add_params(options)
|
868
|
+
json = api.execute!
|
869
|
+
|
870
|
+
Job.new(:id => json[:job_id])
|
871
|
+
end
|
872
|
+
|
873
|
+
|
874
|
+
#
|
875
|
+
# Returns an array of questionnaires.
|
876
|
+
#
|
877
|
+
# @param [Hash] access Access credentials
|
878
|
+
# @option access [String] :client_id
|
879
|
+
# @option access [String] :private_key
|
880
|
+
# @return [Array<GroupDocs::Questionnaire>]
|
881
|
+
#
|
882
|
+
def questionnaires!(access = {})
|
883
|
+
json = Api::Request.new do |request|
|
884
|
+
request[:access] = access
|
885
|
+
request[:method] = :GET
|
886
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires"
|
887
|
+
end.execute!
|
888
|
+
|
889
|
+
json[:questionnaires].map do |questionnaire|
|
890
|
+
Questionnaire.new(questionnaire)
|
891
|
+
end
|
892
|
+
end
|
893
|
+
|
894
|
+
#
|
895
|
+
# Adds questionnaire to document.
|
896
|
+
#
|
897
|
+
# @param [GroupDocs::Questionnaire] questionnaire
|
898
|
+
# @param [Hash] access Access credentials
|
899
|
+
# @option access [String] :client_id
|
900
|
+
# @option access [String] :private_key
|
901
|
+
#
|
902
|
+
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
903
|
+
#
|
904
|
+
def add_questionnaire!(questionnaire, access = {})
|
905
|
+
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
906
|
+
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
907
|
+
|
908
|
+
Api::Request.new do |request|
|
909
|
+
request[:access] = access
|
910
|
+
request[:method] = :PUT
|
911
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}"
|
912
|
+
end.execute!
|
913
|
+
end
|
914
|
+
|
915
|
+
#
|
916
|
+
# Creates questionnaire and adds it to document.
|
917
|
+
#
|
918
|
+
# @param [GroupDocs::Questionnaire] questionnaire
|
919
|
+
# @param [Hash] access Access credentials
|
920
|
+
# @option access [String] :client_id
|
921
|
+
# @option access [String] :private_key
|
922
|
+
# @return [GroupDocs::Questionnaire]
|
923
|
+
#
|
924
|
+
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
925
|
+
#
|
926
|
+
def create_questionnaire!(questionnaire, access = {})
|
927
|
+
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
928
|
+
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
929
|
+
|
930
|
+
json = Api::Request.new do |request|
|
931
|
+
request[:access] = access
|
932
|
+
request[:method] = :POST
|
933
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires"
|
934
|
+
request[:request_body] = questionnaire.to_hash
|
935
|
+
end.execute!
|
936
|
+
|
937
|
+
questionnaire.id = json[:questionnaire_id]
|
938
|
+
questionnaire
|
939
|
+
end
|
940
|
+
|
941
|
+
#
|
942
|
+
# Detaches questionnaire from document.
|
943
|
+
#
|
944
|
+
# @param [GroupDocs::Questionnaire] questionnaire
|
945
|
+
# @param [Hash] access Access credentials
|
946
|
+
# @option access [String] :client_id
|
947
|
+
# @option access [String] :private_key
|
948
|
+
#
|
949
|
+
# @raise [ArgumentError] if questionnaire is not GroupDocs::Questionnaire object
|
950
|
+
#
|
951
|
+
def remove_questionnaire!(questionnaire, access = {})
|
952
|
+
questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError,
|
953
|
+
"Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}"
|
954
|
+
|
955
|
+
Api::Request.new do |request|
|
956
|
+
request[:access] = access
|
957
|
+
request[:method] = :DELETE
|
958
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}"
|
959
|
+
end.execute!
|
960
|
+
end
|
961
|
+
|
962
|
+
#
|
963
|
+
# Returns an array of annotations.
|
964
|
+
#
|
965
|
+
# @param [Hash] access Access credentials
|
966
|
+
# @option access [String] :client_id
|
967
|
+
# @option access [String] :private_key
|
968
|
+
# @return [Array<GroupDocs::Document::Annotation>]
|
969
|
+
#
|
970
|
+
def annotations!(access = {})
|
971
|
+
json = Api::Request.new do |request|
|
972
|
+
request[:access] = access
|
973
|
+
request[:method] = :GET
|
974
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/annotations"
|
975
|
+
end.execute!
|
976
|
+
|
977
|
+
if json[:annotations]
|
978
|
+
json[:annotations].map do |annotation|
|
979
|
+
annotation.merge!(:document => self)
|
980
|
+
Document::Annotation.new(annotation)
|
981
|
+
end
|
982
|
+
else
|
983
|
+
[]
|
984
|
+
end
|
985
|
+
end
|
986
|
+
|
987
|
+
#
|
988
|
+
# Changed in release 1.5.8
|
989
|
+
# Returns document details.
|
990
|
+
#
|
991
|
+
# @param [Hash] access Access credentials
|
992
|
+
# @option access [String] :client_id
|
993
|
+
# @option access [String] :private_key
|
994
|
+
# @return [Hash]
|
995
|
+
#
|
996
|
+
def details!(access = {})
|
997
|
+
api = Api::Request.new do |request|
|
998
|
+
request[:access] = access
|
999
|
+
request[:method] = :GET
|
1000
|
+
request[:path] = "/comparison/{{client_id}}document"
|
1001
|
+
end
|
1002
|
+
api.add_params(:guid => file.guid)
|
1003
|
+
api.execute!
|
1004
|
+
end
|
1005
|
+
|
1006
|
+
#
|
1007
|
+
# Changed in release 1.5.8
|
1008
|
+
# Schedules a job for comparing document with given.
|
1009
|
+
#
|
1010
|
+
# @param [GroupDocs::Document] document
|
1011
|
+
# @param [Hash] access Access credentials
|
1012
|
+
# @option access [String] :client_id
|
1013
|
+
# @option access [String] :private_key
|
1014
|
+
# @return [GroupDocs::Job]
|
1015
|
+
#
|
1016
|
+
# @raise [ArgumentError] if document is not GroupDocs::Document object
|
1017
|
+
#
|
1018
|
+
def compare!(document, callback, access = {})
|
1019
|
+
document.is_a?(GroupDocs::Document) or raise ArgumentError,
|
1020
|
+
"Document should be GroupDocs::Document object, received: #{document.inspect}"
|
1021
|
+
|
1022
|
+
api = Api::Request.new do |request|
|
1023
|
+
request[:access] = access
|
1024
|
+
request[:method] = :GET
|
1025
|
+
request[:path] = "/comparison/{{client_id}}/compare"
|
1026
|
+
end
|
1027
|
+
api.add_params(:source => file.guid, :target => document.file.guid, :callback => callback)
|
1028
|
+
json = api.execute!
|
1029
|
+
|
1030
|
+
Job.new(:id => json[:job_id])
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
#
|
1034
|
+
# Updated in release 2.1.0
|
1035
|
+
#
|
1036
|
+
# Schedules a job for comparing document with given.
|
1037
|
+
#
|
1038
|
+
# @param [Array[GroupDocs::Document::Change]] changes Comparison changes to update (accept or reject)
|
1039
|
+
# @option id [Float] :id
|
1040
|
+
# @option type [String] :type
|
1041
|
+
# @option action [String] :action
|
1042
|
+
# @option Page [Array] :page
|
1043
|
+
# @option box [Array] :box
|
1044
|
+
# @option text [String] :text
|
1045
|
+
# @param [Hash] access Access credentials
|
1046
|
+
# @option access [String] :client_id
|
1047
|
+
# @option access [String] :private_key
|
1048
|
+
# @return [GroupDocs::Change]
|
1049
|
+
#
|
1050
|
+
def update_changes!(changes, access = {})
|
1051
|
+
if changes.is_a?(Array)
|
1052
|
+
changes.each do |e|
|
1053
|
+
e.is_a?(GroupDocs::Document::Change) or raise ArgumentError,
|
1054
|
+
"Change should be GroupDocs::Document::Change object, received: #{e.inspect}"
|
1055
|
+
end
|
1056
|
+
else
|
1057
|
+
raise ArgumentError, "Changes should be Array , received: #{changes.inspect}"
|
1058
|
+
end
|
1059
|
+
api = Api::Request.new do |request|
|
1060
|
+
request[:access] = access
|
1061
|
+
request[:method] = :PUT
|
1062
|
+
request[:path] = "/comparison/public/#{file.guid}/changes"
|
1063
|
+
request[:request_body] = changes
|
1064
|
+
end
|
1065
|
+
api.execute!
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
#
|
1069
|
+
# @Changed in release 1.5.9
|
1070
|
+
# Returns an array of changes in document.
|
1071
|
+
#
|
1072
|
+
# @example
|
1073
|
+
# document_one = GroupDocs::Storage::Folder.list![0].to_document
|
1074
|
+
# document_two = GroupDocs::Storage::Folder.list![1].to_document
|
1075
|
+
# job = document_one.compare!(document_two)
|
1076
|
+
# sleep(5) # wait for server to finish comparing
|
1077
|
+
# result = job.documents![:outputs].first
|
1078
|
+
# result.changes!
|
1079
|
+
#
|
1080
|
+
# @param [Hash] access Access credentials
|
1081
|
+
# @option access [String] :client_id
|
1082
|
+
# @option access [String] :private_key
|
1083
|
+
#
|
1084
|
+
def changes!(access = {})
|
1085
|
+
api = Api::Request.new do |request|
|
1086
|
+
request[:access] = access
|
1087
|
+
request[:method] = :GET
|
1088
|
+
request[:path] = "/comparison/public/#{file.guid}/changes"
|
1089
|
+
end
|
1090
|
+
json = api.execute!
|
1091
|
+
|
1092
|
+
json[:changes].map do |change|
|
1093
|
+
Document::Change.new(change)
|
1094
|
+
end
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
#
|
1098
|
+
# Changed in release 1.5.8
|
1099
|
+
# Download comparison result file.
|
1100
|
+
#
|
1101
|
+
# @example
|
1102
|
+
# document_one = GroupDocs::Storage::Folder.list![0].to_document
|
1103
|
+
# document_two = GroupDocs::Storage::Folder.list![1].to_document
|
1104
|
+
# job = document_one.compare!(document_two)
|
1105
|
+
# sleep(5) # wait for server to finish comparing
|
1106
|
+
# result = job.documents![:outputs].first
|
1107
|
+
# result.download!("#{File.dirname(__FILE__)}", {:format => 'pdf'})
|
1108
|
+
#
|
1109
|
+
# @param [Hash] options
|
1110
|
+
# @option format [String] :format Comparison result file GUID #
|
1111
|
+
# @param [Hash] access Access credentials
|
1112
|
+
# @option access [String] :client_id
|
1113
|
+
# @option access [String] :private_key
|
1114
|
+
#
|
1115
|
+
#
|
1116
|
+
def download!( path, options = {}, access = {})
|
1117
|
+
api = Api::Request.new do |request|
|
1118
|
+
request[:access] = access
|
1119
|
+
request[:method] = :DOWNLOAD
|
1120
|
+
request[:path] = "/comparison/public/#{file.guid}/download"
|
1121
|
+
end
|
1122
|
+
api.add_params(options)
|
1123
|
+
response = api.execute!
|
1124
|
+
|
1125
|
+
if file.name.split('.').last != options[:format]
|
1126
|
+
file_name = file.name.delete!(file.name.split('.').last) + options[:format]
|
1127
|
+
else
|
1128
|
+
file_name = file.name
|
1129
|
+
end
|
1130
|
+
filepath = "#{path}/#{file_name}"
|
1131
|
+
Object::File.open(filepath, 'wb') do |file|
|
1132
|
+
file.write(response)
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
#
|
1138
|
+
# Returns document annotations collaborators.
|
1139
|
+
#
|
1140
|
+
# @param [Hash] access Access credentials
|
1141
|
+
# @option access [String] :client_id
|
1142
|
+
# @option access [String] :private_key
|
1143
|
+
# @return [Array<GroupDocs::User>]
|
1144
|
+
#
|
1145
|
+
def collaborators!(access = {})
|
1146
|
+
json = Api::Request.new do |request|
|
1147
|
+
request[:access] = access
|
1148
|
+
request[:method] = :GET
|
1149
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
|
1150
|
+
end.execute!
|
1151
|
+
|
1152
|
+
json[:collaborators].map do |collaborator|
|
1153
|
+
User.new(collaborator)
|
1154
|
+
end
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
#
|
1158
|
+
# Sets document annotations collaborators to given emails.
|
1159
|
+
#
|
1160
|
+
# @param [Array<String>] emails List of collaborators' email addresses
|
1161
|
+
# @param [Integer] version Annotation version
|
1162
|
+
# @param [Hash] access Access credentials
|
1163
|
+
# @option access [String] :client_id
|
1164
|
+
# @option access [String] :private_key
|
1165
|
+
# @return [Array<GroupDocs::User>]
|
1166
|
+
#
|
1167
|
+
def set_collaborators!(emails, version = 1, access = {})
|
1168
|
+
json = Api::Request.new do |request|
|
1169
|
+
request[:access] = access
|
1170
|
+
request[:method] = :PUT
|
1171
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/version/#{version}/collaborators"
|
1172
|
+
request[:request_body] = emails
|
1173
|
+
end.execute!
|
1174
|
+
|
1175
|
+
json[:collaborators].map do |collaborator|
|
1176
|
+
User.new(collaborator)
|
1177
|
+
end
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
#
|
1181
|
+
# Adds document annotations collaborator.
|
1182
|
+
#
|
1183
|
+
# @param [GroupDocs::User] collaborator
|
1184
|
+
# @param [Hash] access Access credentials
|
1185
|
+
# @option access [String] :client_id
|
1186
|
+
# @option access [String] :private_key
|
1187
|
+
#
|
1188
|
+
def add_collaborator!(collaborator, access = {})
|
1189
|
+
collaborator.is_a?(GroupDocs::User) or raise ArgumentError,
|
1190
|
+
"Collaborator should be GroupDocs::User object, received: #{collaborator.inspect}"
|
1191
|
+
|
1192
|
+
Api::Request.new do |request|
|
1193
|
+
request[:access] = access
|
1194
|
+
request[:method] = :POST
|
1195
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
|
1196
|
+
request[:request_body] = collaborator.to_hash
|
1197
|
+
end.execute!
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
|
1201
|
+
#
|
1202
|
+
# Delete document reviewer
|
1203
|
+
#
|
1204
|
+
# @param [String] reviewerId Reviewer Id
|
1205
|
+
# @param [Hash] access Access credentials
|
1206
|
+
# @option access [String] :client_id
|
1207
|
+
# @option access [String] :private_key
|
1208
|
+
#
|
1209
|
+
def remove_collaborators!(reviewerId, access = {})
|
1210
|
+
Api::Request.new do |request|
|
1211
|
+
request[:access] = access
|
1212
|
+
request[:method] = :DELETE
|
1213
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators/#{reviewerId}"
|
1214
|
+
end.execute!
|
1215
|
+
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
#
|
1219
|
+
# Sets reviewers for document.
|
1220
|
+
#
|
1221
|
+
# @example Change reviewer rights
|
1222
|
+
# reviewers = document.collaborators!
|
1223
|
+
# reviewers.each do |reviewer|
|
1224
|
+
# reviewer.access_rights = %w(view)
|
1225
|
+
# end
|
1226
|
+
# document.set_reviewers! reviewers
|
1227
|
+
#
|
1228
|
+
# @param [Array<GroupDocs::User>] reviewers
|
1229
|
+
# @param [Hash] access Access credentials
|
1230
|
+
# @option access [String] :client_id
|
1231
|
+
# @option access [String] :private_key
|
1232
|
+
#
|
1233
|
+
def set_reviewers!(reviewers, access = {})
|
1234
|
+
Api::Request.new do |request|
|
1235
|
+
request[:access] = access
|
1236
|
+
request[:method] = :PUT
|
1237
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/reviewerRights"
|
1238
|
+
request[:request_body] = reviewers.map(&:to_hash)
|
1239
|
+
end.execute!
|
1240
|
+
end
|
1241
|
+
|
1242
|
+
#
|
1243
|
+
# Returns an array of access rights for shared link.
|
1244
|
+
#
|
1245
|
+
# @param [Hash] access Access credentials
|
1246
|
+
# @option access [String] :client_id
|
1247
|
+
# @option access [String] :private_key
|
1248
|
+
# @return [Array<Symbol>]
|
1249
|
+
#
|
1250
|
+
def shared_link_access_rights!(access = {})
|
1251
|
+
json = Api::Request.new do |request|
|
1252
|
+
request[:access] = access
|
1253
|
+
request[:method] = :GET
|
1254
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
|
1255
|
+
end.execute!
|
1256
|
+
|
1257
|
+
if json[:accessRights]
|
1258
|
+
convert_byte_to_access_rights json[:accessRights]
|
1259
|
+
else
|
1260
|
+
[]
|
1261
|
+
end
|
1262
|
+
end
|
1263
|
+
|
1264
|
+
#
|
1265
|
+
# Sets access rights for shared link.
|
1266
|
+
#
|
1267
|
+
# @param [Array<Symbol>] rights
|
1268
|
+
# @param [Hash] access Access credentials
|
1269
|
+
# @option access [String] :client_id
|
1270
|
+
# @option access [String] :private_key
|
1271
|
+
# @return [Array<Symbol>]
|
1272
|
+
#
|
1273
|
+
def set_shared_link_access_rights!(rights, access = {})
|
1274
|
+
Api::Request.new do |request|
|
1275
|
+
request[:access] = access
|
1276
|
+
request[:method] = :PUT
|
1277
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
|
1278
|
+
request[:request_body] = convert_access_rights_to_byte(rights)
|
1279
|
+
|
1280
|
+
end.execute!
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
#
|
1284
|
+
# Sets session callback URL.
|
1285
|
+
#
|
1286
|
+
# @param [String] url Callback URL
|
1287
|
+
# @param [Hash] access Access credentials
|
1288
|
+
# @option access [String] :client_id
|
1289
|
+
# @option access [String] :private_key
|
1290
|
+
#
|
1291
|
+
def set_session_callback!(url, access = {})
|
1292
|
+
Api::Request.new do |request|
|
1293
|
+
request[:access] = access
|
1294
|
+
request[:method] = :PUT
|
1295
|
+
request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sessionCallbackUrl"
|
1296
|
+
request[:request_body] = url
|
1297
|
+
end.execute!
|
1298
|
+
end
|
1299
|
+
|
1300
|
+
#
|
1301
|
+
# Pass all unknown methods to file.
|
1302
|
+
#
|
1303
|
+
|
1304
|
+
|
1305
|
+
def method_missing(method, *args, &blk)
|
1306
|
+
file.respond_to?(method) ? file.send(method, *args, &blk) : super
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
def respond_to?(method)
|
1310
|
+
super or file.respond_to?(method)
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
|
1314
|
+
#
|
1315
|
+
# added in release 1.5.8
|
1316
|
+
#
|
1317
|
+
# Returns document hyperlinks
|
1318
|
+
#
|
1319
|
+
# @param [Hash] access Access credentials
|
1320
|
+
# @option access [String] :client_id
|
1321
|
+
# @option access [String] :private_key
|
1322
|
+
#
|
1323
|
+
def hyperlinks!(access = {})
|
1324
|
+
json = Api::Request.new do |request|
|
1325
|
+
request[:access] = access
|
1326
|
+
request[:method] = :GET
|
1327
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/hyperlinks"
|
1328
|
+
end.execute!
|
1329
|
+
|
1330
|
+
json[:links]
|
1331
|
+
end
|
1332
|
+
|
1333
|
+
#
|
1334
|
+
# Changed in release 1.5.8
|
1335
|
+
#
|
1336
|
+
#
|
1337
|
+
# Public Sign document
|
1338
|
+
#
|
1339
|
+
# @param [String] document Document GUID
|
1340
|
+
# @param [Hash] settings Settings of the signing document
|
1341
|
+
# @param settings [String] waterMarkText
|
1342
|
+
# @param settings [String] waterMarkImage
|
1343
|
+
# @param settings [String] name (required)
|
1344
|
+
# @param settings [Double] top (required)
|
1345
|
+
# @param settings [Double] left (required)
|
1346
|
+
# @param settings [Double] width (required)
|
1347
|
+
# @param settings [Double] height (required)
|
1348
|
+
# @param settings [String] placeSignatureOn (required)
|
1349
|
+
# @param settings [String] data
|
1350
|
+
# @param [Hash] access Access credentials
|
1351
|
+
# @option access [String] :client_id
|
1352
|
+
# @option access [String] :private_key
|
1353
|
+
# @return [Array]
|
1354
|
+
#
|
1355
|
+
def public_sign_document!(options = {}, access = {})
|
1356
|
+
json = Api::Request.new do |request|
|
1357
|
+
request[:access] = access
|
1358
|
+
request[:method] = :POST
|
1359
|
+
request[:path] = "/signature/public/documents/#{file.guid}/sign"
|
1360
|
+
request[:request_body] = options
|
1361
|
+
end.execute!
|
1362
|
+
|
1363
|
+
json[:jobId]
|
1364
|
+
end
|
1365
|
+
|
1366
|
+
#
|
1367
|
+
# Changed in release 1.5.8
|
1368
|
+
#
|
1369
|
+
#
|
1370
|
+
# Get document fields
|
1371
|
+
#
|
1372
|
+
# @param [String] document Document GUID
|
1373
|
+
# @param [Hash] settings Settings of the signing document
|
1374
|
+
# @param [Hash] access Access credentials
|
1375
|
+
# @option access [String] :client_id
|
1376
|
+
# @option access [String] :private_key
|
1377
|
+
# @return [Array]
|
1378
|
+
#
|
1379
|
+
def self.public_fields!(access = {})
|
1380
|
+
Api::Request.new do |request|
|
1381
|
+
request[:access] = access
|
1382
|
+
request[:method] = :GET
|
1383
|
+
request[:path] = "/signature/public/documents/#{file.guid}/fields"
|
1384
|
+
end.execute!
|
1385
|
+
end
|
1386
|
+
|
1387
|
+
# changed in release 2.1.0
|
1388
|
+
#
|
1389
|
+
# Get template fields.
|
1390
|
+
#
|
1391
|
+
# @param [Hash] access Access credentials
|
1392
|
+
# @option access [String] :client_id
|
1393
|
+
# @option access [String] :private_key
|
1394
|
+
#
|
1395
|
+
def editor_fields!(access = {})
|
1396
|
+
Api::Request.new do |request|
|
1397
|
+
request[:access] = access
|
1398
|
+
request[:method] = :GET
|
1399
|
+
request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editor_fields"
|
1400
|
+
end.execute!
|
1401
|
+
end
|
1402
|
+
|
1403
|
+
# added in release 1.7.0
|
1404
|
+
#
|
1405
|
+
# Create questionnaire template from file.
|
1406
|
+
#
|
1407
|
+
# @example
|
1408
|
+
#
|
1409
|
+
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1410
|
+
# field = GroupDocs::Document::TemplateEditorFields.new
|
1411
|
+
# field.name = 'test'
|
1412
|
+
# field.fieldtype = 'TextBox'
|
1413
|
+
# field.page = 1
|
1414
|
+
# file.questionnaire_template!([field] )
|
1415
|
+
#
|
1416
|
+
#
|
1417
|
+
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1418
|
+
# @param [Hash] access Access credentials
|
1419
|
+
# @option access [String] :client_id
|
1420
|
+
# @option access [String] :private_key
|
1421
|
+
#
|
1422
|
+
def questionnaire_template!(fields, access = {})
|
1423
|
+
|
1424
|
+
fields.each do |field|
|
1425
|
+
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1426
|
+
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
json = Api::Request.new do |request|
|
1430
|
+
request[:access] = access
|
1431
|
+
request[:method] = :POST
|
1432
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates"
|
1433
|
+
request[:request_body] = fields
|
1434
|
+
end.execute!
|
1435
|
+
json[:templateFields].map do |field|
|
1436
|
+
Document::Field.new(field)
|
1437
|
+
end
|
1438
|
+
end
|
1439
|
+
|
1440
|
+
# added in release 1.8.0
|
1441
|
+
#
|
1442
|
+
# Add template editor fields to the specific document
|
1443
|
+
#
|
1444
|
+
# @example
|
1445
|
+
#
|
1446
|
+
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1447
|
+
# field = GroupDocs::Document::TemplateEditorFields.new
|
1448
|
+
# field.name = 'test'
|
1449
|
+
# field.fieldtype = 'TextBox'
|
1450
|
+
# field.page = 1
|
1451
|
+
# file.add_questionnaire_template!([field] )
|
1452
|
+
#
|
1453
|
+
#
|
1454
|
+
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1455
|
+
# @param [Hash] access Access credentials
|
1456
|
+
# @option access [String] :client_id
|
1457
|
+
# @option access [String] :private_key
|
1458
|
+
#
|
1459
|
+
def add_questionnaire_template!(fields, access = {})
|
1460
|
+
|
1461
|
+
fields.each do |field|
|
1462
|
+
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1463
|
+
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
json = Api::Request.new do |request|
|
1467
|
+
request[:access] = access
|
1468
|
+
request[:method] = :POST
|
1469
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/add"
|
1470
|
+
request[:request_body] = fields
|
1471
|
+
end.execute!
|
1472
|
+
json[:templateFields].map do |field|
|
1473
|
+
Document::Field.new(field)
|
1474
|
+
end
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
|
1478
|
+
# added in release 1.8.0
|
1479
|
+
#
|
1480
|
+
# Update template's fields
|
1481
|
+
#
|
1482
|
+
# @example
|
1483
|
+
#
|
1484
|
+
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1485
|
+
# field = GroupDocs::Document::TemplateEditorFields.new
|
1486
|
+
# field.name = 'test'
|
1487
|
+
# field.fieldtype = 'TextBox'
|
1488
|
+
# field.page = 1
|
1489
|
+
# file.update_questionnaire_template!([field] )
|
1490
|
+
#
|
1491
|
+
#
|
1492
|
+
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1493
|
+
# @param [Hash] access Access credentials
|
1494
|
+
# @option access [String] :client_id
|
1495
|
+
# @option access [String] :private_key
|
1496
|
+
#
|
1497
|
+
def update_questionnaire_template!(fields, access = {})
|
1498
|
+
|
1499
|
+
fields.each do |field|
|
1500
|
+
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1501
|
+
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
json = Api::Request.new do |request|
|
1505
|
+
request[:access] = access
|
1506
|
+
request[:method] = :PUT
|
1507
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/update"
|
1508
|
+
request[:request_body] = fields
|
1509
|
+
end.execute!
|
1510
|
+
json[:templateFields].map do |field|
|
1511
|
+
Document::Field.new(field)
|
1512
|
+
end
|
1513
|
+
end
|
1514
|
+
|
1515
|
+
# added in release 1.8.0
|
1516
|
+
#
|
1517
|
+
# Delete template's fields
|
1518
|
+
#
|
1519
|
+
# @example
|
1520
|
+
#
|
1521
|
+
# file = GroupDocs::Storage::File.new({:guid => '3be4e06494caed131d912c75e17d5f22592e3044032e0f81b35f13a8c9fefb49'}).to_document
|
1522
|
+
# field = file.editor_fields!
|
1523
|
+
# file.delete_questionnaire_template!([field] )
|
1524
|
+
#
|
1525
|
+
#
|
1526
|
+
# @param List[GroupDocs::Document::TemplateEditorFields] fields
|
1527
|
+
# @param [Hash] access Access credentials
|
1528
|
+
# @option access [String] :client_id
|
1529
|
+
# @option access [String] :private_key
|
1530
|
+
#
|
1531
|
+
def delete_questionnaire_template!(fields, access = {})
|
1532
|
+
|
1533
|
+
fields.each do |field|
|
1534
|
+
field.is_a?(GroupDocs::Document::TemplateEditorFields) or raise ArgumentError,
|
1535
|
+
"Fields should be List GroupDocs::Document::TemplateEditorFields objects, received: #{fields.inspect}"
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
json = Api::Request.new do |request|
|
1539
|
+
request[:access] = access
|
1540
|
+
request[:method] = :DELETE
|
1541
|
+
request[:path] = "/merge/{{client_id}}/files/#{file.guid}/templates/delete"
|
1542
|
+
request[:request_body] = fields
|
1543
|
+
end.execute!
|
1544
|
+
json[:templateFields].map do |field|
|
1545
|
+
Document::Field.new(field)
|
1546
|
+
end
|
1547
|
+
end
|
1548
|
+
|
1549
|
+
end # Document
|
1550
|
+
end # GroupDocs
|