groupdocs 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +9 -9
  3. data/CHANGELOG.md +482 -477
  4. data/Gemfile +3 -3
  5. data/LICENSE.txt +21 -21
  6. data/README.md +94 -94
  7. data/Rakefile +9 -9
  8. data/examples/README.md +12 -12
  9. data/examples/api-samples/Gemfile +5 -5
  10. data/examples/api-samples/Gemfile.lock +49 -49
  11. data/examples/api-samples/README.md +23 -23
  12. data/examples/api-samples/public/css/style.css +229 -229
  13. data/examples/api-samples/public/docs/annotation-sample.html +167 -167
  14. data/examples/api-samples/public/docs/docco.css +500 -500
  15. data/examples/api-samples/public/docs/envelope-sample.html +374 -374
  16. data/examples/api-samples/public/docs/sample01.html +181 -181
  17. data/examples/api-samples/public/docs/sample02.html +199 -199
  18. data/examples/api-samples/public/docs/sample03.html +318 -318
  19. data/examples/api-samples/public/docs/sample04.html +217 -217
  20. data/examples/api-samples/public/docs/sample05.html +296 -296
  21. data/examples/api-samples/public/docs/sample06.html +347 -347
  22. data/examples/api-samples/public/docs/sample07.html +209 -209
  23. data/examples/api-samples/public/docs/sample08.html +277 -277
  24. data/examples/api-samples/public/docs/sample09.html +314 -314
  25. data/examples/api-samples/public/docs/sample10.html +270 -270
  26. data/examples/api-samples/public/docs/sample11.html +462 -462
  27. data/examples/api-samples/public/docs/sample12.html +199 -199
  28. data/examples/api-samples/public/docs/sample13.html +201 -201
  29. data/examples/api-samples/public/docs/sample14.html +204 -204
  30. data/examples/api-samples/public/docs/sample15.html +182 -182
  31. data/examples/api-samples/public/docs/sample16.html +234 -234
  32. data/examples/api-samples/public/docs/sample17.html +309 -309
  33. data/examples/api-samples/public/docs/sample18.html +721 -721
  34. data/examples/api-samples/public/docs/sample19.html +631 -631
  35. data/examples/api-samples/public/docs/sample20.html +230 -230
  36. data/examples/api-samples/public/docs/sample21.html +790 -790
  37. data/examples/api-samples/public/docs/sample22.html +408 -408
  38. data/examples/api-samples/public/docs/sample25.html +550 -550
  39. data/examples/api-samples/public/templates/base-simple_source.html +191 -191
  40. data/examples/api-samples/public/templates/testdocument.html +100 -100
  41. data/examples/api-samples/public/templates/welcome.htm +137 -137
  42. data/examples/api-samples/samples/annotation-sample.rb +56 -56
  43. data/examples/api-samples/samples/envelope-sample.rb +133 -133
  44. data/examples/api-samples/samples/sample01.rb +44 -44
  45. data/examples/api-samples/samples/sample02.rb +50 -50
  46. data/examples/api-samples/samples/sample03.rb +79 -79
  47. data/examples/api-samples/samples/sample04.rb +54 -54
  48. data/examples/api-samples/samples/sample05.rb +83 -83
  49. data/examples/api-samples/samples/sample06.rb +86 -86
  50. data/examples/api-samples/samples/sample07.rb +59 -59
  51. data/examples/api-samples/samples/sample08.rb +76 -76
  52. data/examples/api-samples/samples/sample09.rb +85 -85
  53. data/examples/api-samples/samples/sample10.rb +70 -70
  54. data/examples/api-samples/samples/sample11.rb +132 -132
  55. data/examples/api-samples/samples/sample12.rb +48 -48
  56. data/examples/api-samples/samples/sample13.rb +49 -49
  57. data/examples/api-samples/samples/sample14.rb +54 -54
  58. data/examples/api-samples/samples/sample15.rb +43 -43
  59. data/examples/api-samples/samples/sample16.rb +57 -57
  60. data/examples/api-samples/samples/sample17.rb +70 -70
  61. data/examples/api-samples/samples/sample18.rb +190 -190
  62. data/examples/api-samples/samples/sample19.rb +188 -188
  63. data/examples/api-samples/samples/sample20.rb +68 -68
  64. data/examples/api-samples/samples/sample21.rb +212 -212
  65. data/examples/api-samples/samples/sample22.rb +109 -109
  66. data/examples/api-samples/samples/sample25.rb +127 -127
  67. data/examples/api-samples/views/_others_samples.haml +233 -233
  68. data/examples/api-samples/views/annotation_sample.haml +63 -63
  69. data/examples/api-samples/views/envelope_sample.haml +72 -72
  70. data/examples/api-samples/views/index.haml +235 -235
  71. data/examples/api-samples/views/layout.haml +3 -3
  72. data/examples/api-samples/views/sample01.haml +63 -63
  73. data/examples/api-samples/views/sample02.haml +52 -52
  74. data/examples/api-samples/views/sample03.haml +87 -87
  75. data/examples/api-samples/views/sample04.haml +55 -55
  76. data/examples/api-samples/views/sample05.haml +86 -86
  77. data/examples/api-samples/views/sample06.haml +58 -58
  78. data/examples/api-samples/views/sample07.haml +52 -52
  79. data/examples/api-samples/views/sample08.haml +100 -100
  80. data/examples/api-samples/views/sample09.haml +95 -95
  81. data/examples/api-samples/views/sample10.haml +93 -93
  82. data/examples/api-samples/views/sample11.haml +140 -140
  83. data/examples/api-samples/views/sample12.haml +68 -68
  84. data/examples/api-samples/views/sample13.haml +64 -64
  85. data/examples/api-samples/views/sample14.haml +60 -60
  86. data/examples/api-samples/views/sample15.haml +51 -51
  87. data/examples/api-samples/views/sample16.haml +50 -50
  88. data/examples/api-samples/views/sample17.haml +54 -54
  89. data/examples/api-samples/views/sample18.haml +143 -143
  90. data/examples/api-samples/views/sample19.haml +92 -92
  91. data/examples/api-samples/views/sample20.haml +54 -54
  92. data/examples/api-samples/views/sample21.haml +123 -123
  93. data/examples/api-samples/views/sample22.haml +106 -106
  94. data/examples/api-samples/views/sample25.haml +101 -101
  95. data/examples/api-samples/views/sample31.haml +2 -2
  96. data/examples/api-samples/web.rb +20 -20
  97. data/examples/viewer/Gemfile +5 -5
  98. data/examples/viewer/app.rb +52 -52
  99. data/groupdocs.gemspec +31 -31
  100. data/lib/groupdocs.rb +62 -62
  101. data/lib/groupdocs/api.rb +6 -6
  102. data/lib/groupdocs/api/entity.rb +112 -112
  103. data/lib/groupdocs/api/helpers.rb +11 -11
  104. data/lib/groupdocs/api/helpers/access_mode_helper.rb +27 -27
  105. data/lib/groupdocs/api/helpers/access_rights_helper.rb +55 -55
  106. data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -30
  107. data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -49
  108. data/lib/groupdocs/api/helpers/credentials_helper.rb +35 -35
  109. data/lib/groupdocs/api/helpers/mime_helper.rb +21 -21
  110. data/lib/groupdocs/api/helpers/path_helper.rb +28 -28
  111. data/lib/groupdocs/api/helpers/rest_helper.rb +99 -99
  112. data/lib/groupdocs/api/helpers/signature_public_helper.rb +22 -22
  113. data/lib/groupdocs/api/helpers/status_helper.rb +27 -27
  114. data/lib/groupdocs/api/helpers/url_helper.rb +101 -101
  115. data/lib/groupdocs/api/request.rb +91 -91
  116. data/lib/groupdocs/datasource.rb +249 -249
  117. data/lib/groupdocs/datasource/field.rb +39 -39
  118. data/lib/groupdocs/document.rb +1550 -1550
  119. data/lib/groupdocs/document/annotation.rb +421 -421
  120. data/lib/groupdocs/document/annotation/reply.rb +173 -173
  121. data/lib/groupdocs/document/annotation/reviewer.rb +66 -66
  122. data/lib/groupdocs/document/change.rb +56 -56
  123. data/lib/groupdocs/document/field.rb +53 -53
  124. data/lib/groupdocs/document/metadata.rb +32 -32
  125. data/lib/groupdocs/document/rectangle.rb +18 -18
  126. data/lib/groupdocs/document/view.rb +36 -36
  127. data/lib/groupdocs/errors.rb +8 -8
  128. data/lib/groupdocs/job.rb +468 -468
  129. data/lib/groupdocs/questionnaire.rb +530 -530
  130. data/lib/groupdocs/questionnaire/collector.rb +335 -335
  131. data/lib/groupdocs/questionnaire/execution.rb +181 -181
  132. data/lib/groupdocs/questionnaire/page.rb +43 -43
  133. data/lib/groupdocs/questionnaire/question.rb +108 -108
  134. data/lib/groupdocs/questionnaire/question/answer.rb +15 -15
  135. data/lib/groupdocs/signature.rb +380 -380
  136. data/lib/groupdocs/signature/contact.rb +181 -181
  137. data/lib/groupdocs/signature/envelope.rb +747 -747
  138. data/lib/groupdocs/signature/envelope/log.rb +20 -20
  139. data/lib/groupdocs/signature/field.rb +286 -286
  140. data/lib/groupdocs/signature/field/location.rb +71 -71
  141. data/lib/groupdocs/signature/form.rb +804 -804
  142. data/lib/groupdocs/signature/list.rb +92 -92
  143. data/lib/groupdocs/signature/recipient.rb +79 -79
  144. data/lib/groupdocs/signature/role.rb +54 -54
  145. data/lib/groupdocs/signature/shared.rb +6 -6
  146. data/lib/groupdocs/signature/shared/document_methods.rb +158 -158
  147. data/lib/groupdocs/signature/shared/entity_fields.rb +76 -76
  148. data/lib/groupdocs/signature/shared/entity_methods.rb +144 -144
  149. data/lib/groupdocs/signature/shared/field_methods.rb +354 -354
  150. data/lib/groupdocs/signature/shared/recipient_methods.rb +75 -75
  151. data/lib/groupdocs/signature/shared/resource_methods.rb +65 -65
  152. data/lib/groupdocs/signature/template.rb +124 -124
  153. data/lib/groupdocs/storage.rb +44 -44
  154. data/lib/groupdocs/storage/file.rb +432 -432
  155. data/lib/groupdocs/storage/folder.rb +288 -288
  156. data/lib/groupdocs/storage/package.rb +48 -48
  157. data/lib/groupdocs/storage/provider.rb +32 -32
  158. data/lib/groupdocs/subscription.rb +323 -323
  159. data/lib/groupdocs/subscription/limit.rb +20 -20
  160. data/lib/groupdocs/user.rb +955 -930
  161. data/lib/groupdocs/version.rb +3 -3
  162. data/spec/groupdocs/api/entity_spec.rb +55 -55
  163. data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +21 -21
  164. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -43
  165. data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -16
  166. data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -23
  167. data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +48 -48
  168. data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -16
  169. data/spec/groupdocs/api/helpers/path_helper_spec.rb +15 -15
  170. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +161 -161
  171. data/spec/groupdocs/api/helpers/signature_public_helper_spec.rb +21 -21
  172. data/spec/groupdocs/api/helpers/status_helper_spec.rb +22 -22
  173. data/spec/groupdocs/api/helpers/url_helper_spec.rb +112 -112
  174. data/spec/groupdocs/api/request_spec.rb +112 -112
  175. data/spec/groupdocs/datasource/field_spec.rb +29 -29
  176. data/spec/groupdocs/datasource_spec.rb +145 -145
  177. data/spec/groupdocs/document/annotation/reply_spec.rb +154 -154
  178. data/spec/groupdocs/document/annotation/reviewer_spec.rb +51 -51
  179. data/spec/groupdocs/document/annotation_spec.rb +234 -234
  180. data/spec/groupdocs/document/change_spec.rb +39 -39
  181. data/spec/groupdocs/document/field_spec.rb +28 -28
  182. data/spec/groupdocs/document/metadata_spec.rb +21 -21
  183. data/spec/groupdocs/document/rectangle_spec.rb +14 -14
  184. data/spec/groupdocs/document/view_spec.rb +33 -33
  185. data/spec/groupdocs/document_spec.rb +859 -859
  186. data/spec/groupdocs/errors_spec.rb +7 -7
  187. data/spec/groupdocs/job_spec.rb +323 -323
  188. data/spec/groupdocs/questionnaire/collector_spec.rb +197 -197
  189. data/spec/groupdocs/questionnaire/execution_spec.rb +162 -162
  190. data/spec/groupdocs/questionnaire/page_spec.rb +47 -47
  191. data/spec/groupdocs/questionnaire/question/answer_spec.rb +9 -9
  192. data/spec/groupdocs/questionnaire/question_spec.rb +75 -75
  193. data/spec/groupdocs/questionnaire_spec.rb +295 -295
  194. data/spec/groupdocs/signature/contact_spec.rb +142 -142
  195. data/spec/groupdocs/signature/envelope/log_spec.rb +15 -15
  196. data/spec/groupdocs/signature/envelope_spec.rb +384 -384
  197. data/spec/groupdocs/signature/field/location_spec.rb +40 -40
  198. data/spec/groupdocs/signature/field_spec.rb +235 -235
  199. data/spec/groupdocs/signature/form_spec.rb +205 -205
  200. data/spec/groupdocs/signature/list_spec.rb +87 -87
  201. data/spec/groupdocs/signature/recipient_spec.rb +26 -26
  202. data/spec/groupdocs/signature/role_spec.rb +47 -47
  203. data/spec/groupdocs/signature/template_spec.rb +80 -80
  204. data/spec/groupdocs/signature_spec.rb +194 -194
  205. data/spec/groupdocs/storage/file_spec.rb +303 -303
  206. data/spec/groupdocs/storage/folder_spec.rb +270 -270
  207. data/spec/groupdocs/storage/package_spec.rb +38 -38
  208. data/spec/groupdocs/storage/provider_spec.rb +21 -21
  209. data/spec/groupdocs/storage_spec.rb +27 -27
  210. data/spec/groupdocs/subscription/limit_spec.rb +16 -16
  211. data/spec/groupdocs/subscription_spec.rb +74 -74
  212. data/spec/groupdocs/user_spec.rb +257 -257
  213. data/spec/groupdocs_spec.rb +63 -63
  214. data/spec/spec_helper.rb +73 -73
  215. data/spec/support/json/annotation_access_set.json +11 -11
  216. data/spec/support/json/annotation_collaborators_get.json +16 -16
  217. data/spec/support/json/annotation_collaborators_set.json +16 -16
  218. data/spec/support/json/annotation_create.json +12 -12
  219. data/spec/support/json/annotation_list.json +32 -32
  220. data/spec/support/json/annotation_marker_move.json +10 -10
  221. data/spec/support/json/annotation_move.json +8 -8
  222. data/spec/support/json/annotation_remove.json +9 -9
  223. data/spec/support/json/annotation_replies_create.json +9 -9
  224. data/spec/support/json/annotation_replies_get.json +25 -25
  225. data/spec/support/json/annotation_reviewers_get.json +18 -18
  226. data/spec/support/json/comparison_changes.json +46 -46
  227. data/spec/support/json/comparison_compare.json +8 -8
  228. data/spec/support/json/comparison_document.json +10 -10
  229. data/spec/support/json/contact_add.json +12 -12
  230. data/spec/support/json/contacts_get.json +19 -19
  231. data/spec/support/json/contacts_import.json +8 -8
  232. data/spec/support/json/datasource_add.json +8 -8
  233. data/spec/support/json/datasource_get.json +22 -22
  234. data/spec/support/json/datasource_remove.json +8 -8
  235. data/spec/support/json/datasource_update.json +8 -8
  236. data/spec/support/json/delete_account.json +9 -9
  237. data/spec/support/json/document_access_info_get.json +14 -14
  238. data/spec/support/json/document_convert.json +8 -8
  239. data/spec/support/json/document_datasource.json +10 -10
  240. data/spec/support/json/document_fields.json +34 -34
  241. data/spec/support/json/document_formats.json +8 -8
  242. data/spec/support/json/document_metadata.json +15 -15
  243. data/spec/support/json/document_page_images_get.json +20 -20
  244. data/spec/support/json/document_questionnaire_create.json +9 -9
  245. data/spec/support/json/document_questionnaires.json +23 -23
  246. data/spec/support/json/document_sharers_remove.json +8 -8
  247. data/spec/support/json/document_sharers_set.json +16 -16
  248. data/spec/support/json/document_thumbnails.json +24 -24
  249. data/spec/support/json/document_views.json +32 -32
  250. data/spec/support/json/envelope_get.json +46 -46
  251. data/spec/support/json/envelope_logs.json +16 -16
  252. data/spec/support/json/envelope_recipient_add.json +26 -26
  253. data/spec/support/json/envelopes_all.json +48 -48
  254. data/spec/support/json/envelopes_resources.json +31 -31
  255. data/spec/support/json/file_compress.json +8 -8
  256. data/spec/support/json/file_copy.json +14 -14
  257. data/spec/support/json/file_delete.json +5 -5
  258. data/spec/support/json/file_move.json +14 -14
  259. data/spec/support/json/file_upload.json +8 -8
  260. data/spec/support/json/folder_create.json +8 -8
  261. data/spec/support/json/folder_delete.json +5 -5
  262. data/spec/support/json/folder_list.json +22 -22
  263. data/spec/support/json/folder_move.json +8 -8
  264. data/spec/support/json/folder_sharers_get.json +16 -16
  265. data/spec/support/json/folder_sharers_remove.json +8 -8
  266. data/spec/support/json/folder_sharers_set.json +16 -16
  267. data/spec/support/json/form_get.json +21 -21
  268. data/spec/support/json/forms_all.json +23 -23
  269. data/spec/support/json/job_add_url.json +8 -8
  270. data/spec/support/json/job_create.json +8 -8
  271. data/spec/support/json/job_documents.json +40 -40
  272. data/spec/support/json/job_file_add.json +8 -8
  273. data/spec/support/json/job_get.json +30 -30
  274. data/spec/support/json/job_update.json +7 -7
  275. data/spec/support/json/jobs_get.json +58 -58
  276. data/spec/support/json/list_add.json +12 -12
  277. data/spec/support/json/lists_get.json +19 -19
  278. data/spec/support/json/package_create.json +7 -7
  279. data/spec/support/json/questionnaire_collector.json +17 -17
  280. data/spec/support/json/questionnaire_collectors.json +38 -38
  281. data/spec/support/json/questionnaire_collectors_add.json +10 -10
  282. data/spec/support/json/questionnaire_create.json +10 -10
  283. data/spec/support/json/questionnaire_datasources.json +26 -26
  284. data/spec/support/json/questionnaire_execution_add.json +9 -9
  285. data/spec/support/json/questionnaire_execution_status_set.json +8 -8
  286. data/spec/support/json/questionnaire_execution_update.json +8 -8
  287. data/spec/support/json/questionnaire_executions.json +28 -28
  288. data/spec/support/json/questionnaire_get.json +17 -17
  289. data/spec/support/json/questionnaire_remove.json +8 -8
  290. data/spec/support/json/questionnaire_update.json +8 -8
  291. data/spec/support/json/questionnaires_get.json +40 -40
  292. data/spec/support/json/sign_documents.json +16 -16
  293. data/spec/support/json/signature_create.json +12 -12
  294. data/spec/support/json/signature_field_add.json +25 -25
  295. data/spec/support/json/signature_fields_get.json +27 -27
  296. data/spec/support/json/signature_roles_get.json +17 -17
  297. data/spec/support/json/signatures_get.json +19 -19
  298. data/spec/support/json/storage_info.json +10 -10
  299. data/spec/support/json/subscription_plan_get.json +9 -9
  300. data/spec/support/json/subscription_plans_get.json +17 -17
  301. data/spec/support/json/template_get.json +35 -35
  302. data/spec/support/json/template_get_documents.json +15 -15
  303. data/spec/support/json/template_get_recipients.json +20 -20
  304. data/spec/support/json/templates_all.json +37 -37
  305. data/spec/support/json/templates_get.json +21 -21
  306. data/spec/support/json/update_account.json +10 -10
  307. data/spec/support/json/user_area.json +67 -67
  308. data/spec/support/json/user_embed_key.json +38 -38
  309. data/spec/support/json/user_get_embed_key.json +67 -67
  310. data/spec/support/json/user_login.json +67 -67
  311. data/spec/support/json/user_profile_get.json +24 -24
  312. data/spec/support/json/user_providers.json +31 -31
  313. data/spec/support/json/user_roles.json +25 -25
  314. data/spec/support/json/user_users_get.json +27 -27
  315. data/spec/support/shared_examples/api/entity.rb +39 -39
  316. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +11 -11
  317. data/spec/support/shared_examples/api/helpers/status_helper.rb +11 -11
  318. data/spec/support/shared_examples/signature/shared/document_methods.rb +68 -68
  319. data/spec/support/shared_examples/signature/shared/entity_fields.rb +56 -56
  320. data/spec/support/shared_examples/signature/shared/entity_methods.rb +116 -116
  321. data/spec/support/shared_examples/signature/shared/field_methods.rb +220 -220
  322. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +46 -46
  323. data/spec/support/shared_examples/signature/shared/resource_methods.rb +46 -46
  324. metadata +35 -55
@@ -1,56 +1,56 @@
1
- module GroupDocs
2
- class Document::Change < Api::Entity
3
-
4
- # @attr [Integer] id
5
- attr_accessor :id
6
- # @attr [Symbol] type
7
- attr_accessor :type
8
- # @attr [GroupDocs::Document::Rectangle] box
9
- attr_accessor :box
10
- # @attr [String] text
11
- attr_accessor :text
12
- # @attr [GroupDocs::Document::Page] page
13
- attr_accessor :page
14
-
15
-
16
- #Added in release 2.1.0
17
- # @attr [String] type
18
- attr_accessor :type
19
- # @attr [String] typeStr
20
- attr_accessor :typeStr
21
- # @attr [String] action
22
- attr_accessor :action
23
- # @attr [String] actionStr
24
- attr_accessor :actionStr
25
-
26
- #
27
- # Returns type as symbol.
28
- #
29
- # @return [Symbol]
30
- #
31
- def type
32
- @type.to_sym
33
- end
34
-
35
- #
36
- # Coverts passed hash to GroupDocs::Document::Rectangle object.
37
- #
38
- # @param [Hash] options
39
- # @return [GroupDocs::Document::Rectangle]
40
- #
41
- def box=(options)
42
- @box = GroupDocs::Document::Rectangle.new(options)
43
- end
44
-
45
- #
46
- # Coverts passed hash to GroupDocs::Document::Page object.
47
- #
48
- # @param [Hash] options
49
- # @return [GroupDocs::Document::Page]
50
- #
51
- def page=(options)
52
- @page = GroupDocs::Document::Page.new(options)
53
- end
54
-
55
- end # Document::Change
56
- end # GroupDocs
1
+ module GroupDocs
2
+ class Document::Change < Api::Entity
3
+
4
+ # @attr [Integer] id
5
+ attr_accessor :id
6
+ # @attr [Symbol] type
7
+ attr_accessor :type
8
+ # @attr [GroupDocs::Document::Rectangle] box
9
+ attr_accessor :box
10
+ # @attr [String] text
11
+ attr_accessor :text
12
+ # @attr [GroupDocs::Document::Page] page
13
+ attr_accessor :page
14
+
15
+
16
+ #Added in release 2.1.0
17
+ # @attr [String] type
18
+ attr_accessor :type
19
+ # @attr [String] typeStr
20
+ attr_accessor :typeStr
21
+ # @attr [String] action
22
+ attr_accessor :action
23
+ # @attr [String] actionStr
24
+ attr_accessor :actionStr
25
+
26
+ #
27
+ # Returns type as symbol.
28
+ #
29
+ # @return [Symbol]
30
+ #
31
+ def type
32
+ @type.to_sym
33
+ end
34
+
35
+ #
36
+ # Coverts passed hash to GroupDocs::Document::Rectangle object.
37
+ #
38
+ # @param [Hash] options
39
+ # @return [GroupDocs::Document::Rectangle]
40
+ #
41
+ def box=(options)
42
+ @box = GroupDocs::Document::Rectangle.new(options)
43
+ end
44
+
45
+ #
46
+ # Coverts passed hash to GroupDocs::Document::Page object.
47
+ #
48
+ # @param [Hash] options
49
+ # @return [GroupDocs::Document::Page]
50
+ #
51
+ def page=(options)
52
+ @page = GroupDocs::Document::Page.new(options)
53
+ end
54
+
55
+ end # Document::Change
56
+ end # GroupDocs
@@ -1,53 +1,53 @@
1
- module GroupDocs
2
- class Document::Field < Api::Entity
3
-
4
- # @attr [Integer] page
5
- attr_accessor :page
6
- # @attr [String] name
7
- attr_accessor :name
8
- # @attr [String] type
9
- attr_accessor :type
10
- # @attr [GroupDocs::Document::Rectangle] rect
11
- attr_accessor :rect
12
- # @attr [Int] maxlength
13
- attr_accessor :maxlength
14
- # @attr [Boolean] mandatory
15
- attr_accessor :mandatory
16
- # @attr [String] fieldtype
17
- attr_accessor :fieldtype
18
- # @attr [Array] acceptableValues
19
- attr_accessor :acceptableValues
20
-
21
- # added in release 1.7.0
22
-
23
- # @attr [Int] selectionPosition
24
- attr_accessor :selectionPosition
25
- # @attr [Int] selectionLength
26
- attr_accessor :selectionLength
27
- # @attr [Boolean] isTableStartMarker
28
- attr_accessor :isTableStartMarker
29
- # @attr [Boolean] isTableEndMarker
30
- attr_accessor :isTableEndMarker
31
- # @attr [String] regionName
32
- attr_accessor :regionName
33
-
34
-
35
-
36
-
37
- #
38
- # Coverts passed hash to GroupDocs::Document::Rectangle object.
39
- # @param [Hash] options
40
- #
41
- def rect=(rectangle)
42
- if rectangle.is_a?(Hash)
43
- rectangle = GroupDocs::Document::Rectangle.new(rectangle)
44
- end
45
-
46
- @rect = rectangle
47
- end
48
-
49
- # Human-readable accessors
50
- alias_accessor :rectangle, :rect
51
-
52
- end # Document::Field
53
- end # GroupDocs
1
+ module GroupDocs
2
+ class Document::Field < Api::Entity
3
+
4
+ # @attr [Integer] page
5
+ attr_accessor :page
6
+ # @attr [String] name
7
+ attr_accessor :name
8
+ # @attr [String] type
9
+ attr_accessor :type
10
+ # @attr [GroupDocs::Document::Rectangle] rect
11
+ attr_accessor :rect
12
+ # @attr [Int] maxlength
13
+ attr_accessor :maxlength
14
+ # @attr [Boolean] mandatory
15
+ attr_accessor :mandatory
16
+ # @attr [String] fieldtype
17
+ attr_accessor :fieldtype
18
+ # @attr [Array] acceptableValues
19
+ attr_accessor :acceptableValues
20
+
21
+ # added in release 1.7.0
22
+
23
+ # @attr [Int] selectionPosition
24
+ attr_accessor :selectionPosition
25
+ # @attr [Int] selectionLength
26
+ attr_accessor :selectionLength
27
+ # @attr [Boolean] isTableStartMarker
28
+ attr_accessor :isTableStartMarker
29
+ # @attr [Boolean] isTableEndMarker
30
+ attr_accessor :isTableEndMarker
31
+ # @attr [String] regionName
32
+ attr_accessor :regionName
33
+
34
+
35
+
36
+
37
+ #
38
+ # Coverts passed hash to GroupDocs::Document::Rectangle object.
39
+ # @param [Hash] options
40
+ #
41
+ def rect=(rectangle)
42
+ if rectangle.is_a?(Hash)
43
+ rectangle = GroupDocs::Document::Rectangle.new(rectangle)
44
+ end
45
+
46
+ @rect = rectangle
47
+ end
48
+
49
+ # Human-readable accessors
50
+ alias_accessor :rectangle, :rect
51
+
52
+ end # Document::Field
53
+ end # GroupDocs
@@ -1,32 +1,32 @@
1
- module GroupDocs
2
- class Document::MetaData < Api::Entity
3
-
4
- # @attr [Integer] id
5
- attr_accessor :id
6
- # @attr [String] guid
7
- attr_accessor :guid
8
- # @attr [Integer] page_count
9
- attr_accessor :page_count
10
- # @attr [Integer] views_count
11
- attr_accessor :views_count
12
- # @attr [Hash] last_view
13
- attr_accessor :last_view
14
-
15
- # added in release 2.0.0
16
- # @attr [String] type
17
- attr_accessor :type
18
- # @attr [String] url
19
- attr_accessor :url
20
-
21
- #
22
- # Coverts passed hash to GroupDocs::Document::View object.
23
- #
24
- # @param [Hash] options
25
- # @return [GroupDocs::Document::View]
26
- #
27
- def last_view=(options)
28
- @last_view = GroupDocs::Document::View.new(options)
29
- end
30
-
31
- end # Document::Metadata
32
- end # GroupDocs
1
+ module GroupDocs
2
+ class Document::MetaData < Api::Entity
3
+
4
+ # @attr [Integer] id
5
+ attr_accessor :id
6
+ # @attr [String] guid
7
+ attr_accessor :guid
8
+ # @attr [Integer] page_count
9
+ attr_accessor :page_count
10
+ # @attr [Integer] views_count
11
+ attr_accessor :views_count
12
+ # @attr [Hash] last_view
13
+ attr_accessor :last_view
14
+
15
+ # added in release 2.0.0
16
+ # @attr [String] type
17
+ attr_accessor :type
18
+ # @attr [String] url
19
+ attr_accessor :url
20
+
21
+ #
22
+ # Coverts passed hash to GroupDocs::Document::View object.
23
+ #
24
+ # @param [Hash] options
25
+ # @return [GroupDocs::Document::View]
26
+ #
27
+ def last_view=(options)
28
+ @last_view = GroupDocs::Document::View.new(options)
29
+ end
30
+
31
+ end # Document::Metadata
32
+ end # GroupDocs
@@ -1,18 +1,18 @@
1
- module GroupDocs
2
- class Document::Rectangle < Api::Entity
3
-
4
- # @attr [Float] x
5
- attr_accessor :x
6
- # @attr [Float] y
7
- attr_accessor :y
8
- # @attr [Float] width
9
- attr_accessor :width
10
- # @attr [Float] height
11
- attr_accessor :height
12
-
13
- # Human-readable accessors
14
- alias_accessor :w, :width
15
- alias_accessor :h, :height
16
-
17
- end # Document::Rectangle
18
- end # GroupDocs
1
+ module GroupDocs
2
+ class Document::Rectangle < Api::Entity
3
+
4
+ # @attr [Float] x
5
+ attr_accessor :x
6
+ # @attr [Float] y
7
+ attr_accessor :y
8
+ # @attr [Float] width
9
+ attr_accessor :width
10
+ # @attr [Float] height
11
+ attr_accessor :height
12
+
13
+ # Human-readable accessors
14
+ alias_accessor :w, :width
15
+ alias_accessor :h, :height
16
+
17
+ end # Document::Rectangle
18
+ end # GroupDocs
@@ -1,36 +1,36 @@
1
- module GroupDocs
2
- class Document::View < Api::Entity
3
-
4
- # @attr [GroupDocs::Document] document
5
- attr_accessor :document
6
- # @attr [String] short_url
7
- attr_accessor :short_url
8
- # @attr [Time] viewed_on
9
- attr_accessor :viewed_on
10
-
11
- #
12
- # Converts timestamp which is return by API server to Time object.
13
- #
14
- # @return [Time]
15
- #
16
- def viewed_on
17
- Time.at(@viewed_on / 1000)
18
- end
19
-
20
- #
21
- # Converts passed hash to GroupDocs::Document object.
22
- #
23
- # @param [GroupDocs::Document, Hash] object
24
- # @return [GroupDocs::Document]
25
- #
26
- def document=(object)
27
- if object.is_a?(GroupDocs::Document)
28
- @document = object
29
- else
30
- object.merge!(:file => GroupDocs::Storage::File.new(object))
31
- @document = GroupDocs::Document.new(object)
32
- end
33
- end
34
-
35
- end # Document::View
36
- end # GroupDocs
1
+ module GroupDocs
2
+ class Document::View < Api::Entity
3
+
4
+ # @attr [GroupDocs::Document] document
5
+ attr_accessor :document
6
+ # @attr [String] short_url
7
+ attr_accessor :short_url
8
+ # @attr [Time] viewed_on
9
+ attr_accessor :viewed_on
10
+
11
+ #
12
+ # Converts timestamp which is return by API server to Time object.
13
+ #
14
+ # @return [Time]
15
+ #
16
+ def viewed_on
17
+ Time.at(@viewed_on / 1000)
18
+ end
19
+
20
+ #
21
+ # Converts passed hash to GroupDocs::Document object.
22
+ #
23
+ # @param [GroupDocs::Document, Hash] object
24
+ # @return [GroupDocs::Document]
25
+ #
26
+ def document=(object)
27
+ if object.is_a?(GroupDocs::Document)
28
+ @document = object
29
+ else
30
+ object.merge!(:file => GroupDocs::Storage::File.new(object))
31
+ @document = GroupDocs::Document.new(object)
32
+ end
33
+ end
34
+
35
+ end # Document::View
36
+ end # GroupDocs
@@ -1,8 +1,8 @@
1
- module GroupDocs
2
-
3
- class NoClientIdError < StandardError ; end
4
- class NoPrivateKeyError < StandardError ; end
5
- class UnsupportedMethodError < StandardError ; end
6
- class BadResponseError < StandardError ; end
7
-
8
- end # GroupDocs
1
+ module GroupDocs
2
+
3
+ class NoClientIdError < StandardError ; end
4
+ class NoPrivateKeyError < StandardError ; end
5
+ class UnsupportedMethodError < StandardError ; end
6
+ class BadResponseError < StandardError ; end
7
+
8
+ end # GroupDocs
@@ -1,468 +1,468 @@
1
- module GroupDocs
2
- class Job < Api::Entity
3
-
4
- ACTIONS = {
5
- :none => 0,
6
- :convert => 1,
7
- :combine => 2,
8
- :compress_zip => 4,
9
- :compress_rar => 8,
10
- :trace => 16,
11
- :convert_body => 32,
12
- :bind_data => 64,
13
- :print => 128,
14
- :compare => 256,
15
- :import_annotations => 512,
16
- # add in release 1.5.8
17
- :split => 1024,
18
- :view => 2048,
19
- :index => 4096,
20
- :number_lines => 8192
21
- }
22
-
23
- extend Api::Helpers::ByteFlag
24
- include Api::Helpers::Status
25
-
26
- #
27
- # Returns array of jobs.
28
- #
29
- # @param [Hash] options Hash of options
30
- # @option options [String] :page Page Index
31
- # @option options [String] :date Data
32
- # @option options [String] :count How many items to list
33
- # @option options [String] :statusIds Comma separated status identifiers
34
- # @option options [String] :actions Actions
35
- # @option options [String] :excluded_actions Excluded actions
36
- # @option options [String] :jobName Foltred job name
37
- # @param [Hash] access Access credentials
38
- # @option access [String] :client_id
39
- # @option access [String] :private_key
40
- # @return [Array<GroupDocs::Job>]
41
- #
42
- def self.all!(options = {}, access = {})
43
- api = Api::Request.new do |request|
44
- request[:access] = access
45
- request[:method] = :GET
46
- request[:path] = '/async/{{client_id}}/jobs'
47
- end
48
- api.add_params(options)
49
- json = api.execute!
50
-
51
- json[:jobs].map do |job|
52
- Job.new(job)
53
- end
54
- end
55
-
56
- #
57
- # Returns job by its identifier.
58
- #
59
- # @param [Integer] id
60
- # @param [Hash] access Access credentials
61
- # @option access [String] :client_id
62
- # @option access [String] :private_key
63
- # @return [GroupDocs::Job]
64
- #
65
- def self.get!(id, access = {})
66
- api = Api::Request.new do |request|
67
- request[:access] = access
68
- request[:method] = :GET
69
- request[:path] = "/async/{{client_id}}/jobs/#{id}"
70
- end
71
- api.add_params(:format => 'json')
72
- json = api.execute!
73
-
74
- Job.new(json)
75
- end
76
-
77
- #
78
- # Returns job by its identifier.
79
- #
80
- # @param [Integer] id
81
- # @param [Hash] access Access credentials
82
- # @option access [String] :client_id
83
- # @option access [String] :private_key
84
- # @return [GroupDocs::Job]
85
- #
86
- def self.get_xml!(id, access = {})
87
- api = Api::Request.new do |request|
88
- request[:access] = access
89
- request[:method] = :GET
90
- request[:path] = "/async/{{client_id}}/jobs/#{id}"
91
- end
92
- api.add_params(:format => 'xml')
93
- json = api.execute!
94
-
95
- Job.new(json)
96
- end
97
-
98
-
99
- #
100
- # Returns job by its identifier.
101
- #
102
- # @param [Hash] options
103
- # @option statusIds [String] :statusIds (required)
104
- # @option actions [Integer] :actions
105
- # @option excluded_actions [String] :excluded_actions
106
- # @param [Hash] access Access credentials
107
- # @option access [String] :client_id
108
- # @option access [String] :private_key
109
- # @return [GroupDocs::Job]
110
- #
111
- def self.get_resources!(options = {} , access = {})
112
- options[:actions] = convert_actions_to_byte(options[:actions])
113
- api = Api::Request.new do |request|
114
- request[:access] = access
115
- request[:method] = :GET
116
- request[:path] = "/async/{{client_id}}/jobs/resources"
117
- end
118
- api.add_params(options)
119
- json = api.execute!
120
-
121
- json[:dates]
122
- end
123
-
124
- #
125
- # Creates new draft job.
126
- #
127
- # @param [Hash] options
128
- # @option options [Integer] :actions Array of actions to be performed. Required
129
- # @option options [Boolean] :email_results
130
- # @option options [Array] :out_formats
131
- # @option options [Boolean] :url_only
132
- # @param [Hash] access Access credentials
133
- # @option access [String] :client_id
134
- # @option access [String] :private_key
135
- # @return [GroupDocs::Job]
136
- #
137
- def self.create!(options, access = {})
138
- options[:actions] or raise ArgumentError, 'options[:actions] is required.'
139
- options[:actions] = convert_actions_to_byte(options[:actions])
140
- #options[:out_formats] = options[:out_formats].join(?;) if options[:out_formats]
141
-
142
- api = Api::Request.new do |request|
143
- request[:access] = access
144
- request[:method] = :POST
145
- request[:path] = '/async/{{client_id}}/jobs'
146
- request[:request_body] = options
147
- end
148
- json = api.execute!
149
-
150
- Job.new(:id => json[:job_id], :guid => json[:job_guid])
151
- end
152
-
153
- # @attr [Integer] id
154
- attr_accessor :id
155
- # @attr [String] guid
156
- attr_accessor :guid
157
- # @attr [String] name
158
- attr_accessor :name
159
- # @attr [Integer] priority
160
- attr_accessor :priority
161
- # @attr [Array<Symbol>] actions
162
- attr_accessor :actions
163
- # @attr [Boolean] email_results
164
- attr_accessor :email_results
165
- # @attr [Boolean] url_only
166
- attr_accessor :url_only
167
- # @attr [Array<GroupDocs::Document] documents
168
- attr_accessor :documents
169
- # @attr [Time] requested_time
170
- attr_accessor :requested_time
171
- # @attr [Symbol] status
172
- attr_accessor :status
173
-
174
- #
175
- # Coverts passed array of attributes hash to array of GroupDocs::Document.
176
- #
177
- # @param [Array<Hash>] documents Array of document attributes hashes
178
- #
179
- def documents=(documents)
180
- if documents
181
- @documents = documents[:inputs].map do |document|
182
- document.merge!(:file => GroupDocs::Storage::File.new(document))
183
- Document.new(document)
184
- end
185
- end
186
- end
187
-
188
- #
189
- # Converts status to human-readable format.
190
- #
191
- # @return [Symbol]
192
- #
193
- def status
194
- parse_status(@status)
195
- end
196
-
197
- #
198
- # Converts timestamp which is return by API server to Time object.
199
- #
200
- # @return [Time]
201
- #
202
- def requested_time
203
- Time.at(@requested_time / 1000)
204
- end
205
-
206
- #
207
- # Returns job actions in human-readable format.
208
- #
209
- # @return [Array<Symbol>]
210
- #
211
- def actions
212
- @actions.split(', ').map { |action| action.underscore.to_sym } if @actions
213
- end
214
-
215
- #
216
- # Returns an hash of input and output documents associated to job.
217
- #
218
- # @param [Hash] access Access credentials
219
- # @option access [String] :client_id
220
- # @option access [String] :private_key
221
- # @return [Hash]
222
- #
223
- def documents!(access = {})
224
- json = Api::Request.new do |request|
225
- request[:access] = access
226
- request[:method] = :GET
227
- request[:path] = "/async/{{client_id}}/jobs/#{id}/documents"
228
- end.execute!
229
-
230
- self.status = json[:job_status]
231
- documents = {
232
- :inputs => [],
233
- :outputs => [],
234
- }
235
-
236
- # add input documents
237
- if json[:inputs]
238
- json[:inputs].each do |document|
239
- document.merge!(:file => GroupDocs::Storage::File.new(document))
240
- documents[:inputs] << Document.new(document)
241
- end
242
- end
243
-
244
- # add output documents
245
- if json[:outputs]
246
- json[:outputs].each do |document|
247
- document.merge!(:file => GroupDocs::Storage::File.new(document))
248
- documents[:outputs] << Document.new(document)
249
- end
250
- end
251
-
252
- documents
253
- end
254
-
255
- #
256
- # Returns job actions in human-readable format.
257
- #
258
- # @return [Array<Symbol>]
259
- #
260
- def actions
261
- @actions.split(', ').map { |action| action.underscore.to_sym } if @actions
262
- end
263
-
264
- #
265
- # Returns an array of input and output documents associated to jobs.
266
- #
267
- # @param [Hash] options
268
- # @option page [String] Page Index
269
- # @option count [String] Page Size
270
- # @option actions [String] Actions
271
- # @option excluded_actions [String] Excluded actions
272
- # @option order_by [String] Order by
273
- # @option order_asc [String] Order ask
274
- # @param [Hash] access Access credentials
275
- # @option access [String] :client_id
276
- # @option access [String] :private_key
277
- # @return [Hash]
278
- #
279
- def self.jobs_documents!(options = {}, access = {})
280
- api = Api::Request.new do |request|
281
- request[:access] = access
282
- request[:method] = :GET
283
- request[:path] = "/async/{{client_id}}/jobs/documents"
284
- end
285
- api.add_params(options)
286
- api.execute!
287
-
288
- end
289
-
290
- #
291
- # Adds document to job.
292
- #
293
- # @param [GroupDocs::Document] document
294
- # @param [Hash] options
295
- # @option options [Array] :output_formats Array of output formats to override
296
- # @param [Hash] access Access credentials
297
- # @option access [String] :client_id
298
- # @option access [String] :private_key
299
- # @return [Integer] Document ID
300
- #
301
- # @raise [ArgumentError] If document is not a GroupDocs::Document object
302
- #
303
- def add_document!(document, options = {}, access = {})
304
- document.is_a?(GroupDocs::Document) or raise ArgumentError,
305
- "Document should be GroupDocs::Document object. Received: #{document.inspect}"
306
-
307
- api = Api::Request.new do |request|
308
- request[:access] = access
309
- request[:method] = :PUT
310
- request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.guid}"
311
- end
312
- api.add_params(options)
313
- json = api.execute!
314
-
315
- json[:document_id]
316
- end
317
-
318
- #
319
- # Deletes document with guid from job.
320
- #
321
- # @param [String] guid
322
- # @param [Hash] access Access credentials
323
- # @option access [String] :client_id
324
- # @option access [String] :private_key
325
- #
326
- def delete_document!(guid, access = {})
327
- Api::Request.new do |request|
328
- request[:access] = access
329
- request[:method] = :DELETE
330
- request[:path] = "/async/{{client_id}}/jobs/#{id}/documents/#{guid}"
331
- end.execute!
332
- end
333
-
334
- #
335
- # Adds datasource to job document.
336
- #
337
- # @param [GroupDocs::Document] document
338
- # @param [GroupDocs::DataSource] datasource
339
- # @param [Hash] access Access credentials
340
- # @option access [String] :client_id
341
- # @option access [String] :private_key
342
- #
343
- # @raise [ArgumentError] If document is not a GroupDocs::Document object
344
- # @raise [ArgumentError] If datasource is not a GroupDocs::DataSource object
345
- #
346
- def add_datasource!(document, datasource, access = {})
347
- document.is_a?(GroupDocs::Document) or raise ArgumentError,
348
- "Document should be GroupDocs::Document object. Received: #{document.inspect}"
349
- datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
350
- "Datasource should be GroupDocs::DataSource object. Received: #{datasource.inspect}"
351
-
352
- Api::Request.new do |request|
353
- request[:access] = access
354
- request[:method] = :PUT
355
- request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.id}/datasources/#{datasource.id}"
356
- end.execute!
357
- end
358
-
359
- #
360
- # Adds URL of web page or document to be converted.
361
- #
362
- # @param [String] url Absolute URL
363
- # @param [Hash] options
364
- # @option options [Array] :output_formats Array of output formats to override
365
- # @param [Hash] access Access credentials
366
- # @option access [String] :client_id
367
- # @option access [String] :private_key
368
- # @return [Integer] Document ID
369
- #
370
- def add_url!(url, options = {}, access = {})
371
- options.merge!(:absolute_url => url)
372
-
373
- api = Api::Request.new do |request|
374
- request[:access] = access
375
- request[:method] = :PUT
376
- request[:path] = "/async/{{client_id}}/jobs/#{id}/urls"
377
- end
378
- api.add_params(options)
379
- json = api.execute!
380
-
381
- json[:document_id]
382
- end
383
-
384
- #
385
- # Updates job settings and/or status.
386
- #
387
- # @param [Hash] options
388
- # @option options [Boolean] :email_results
389
- # @option options [Symbol] :status
390
- # @param [Hash] access Access credentials
391
- # @option access [String] :client_id
392
- # @option access [String] :private_key
393
- #
394
- def update!(options, access = {})
395
- options[:status] = parse_status(options[:status]) if options[:status]
396
-
397
- Api::Request.new do |request|
398
- request[:access] = access
399
- request[:method] = :PUT
400
- request[:path] = "/async/{{client_id}}/jobs/#{id}"
401
- request[:request_body] = options
402
- end.execute!
403
- end
404
-
405
- #
406
- # Deletes draft job.
407
- #
408
- # @param [Hash] access Access credentials
409
- # @option access [String] :client_id
410
- # @option access [String] :private_key
411
- #
412
- def delete!(access = {})
413
- Api::Request.new do |request|
414
- request[:access] = access
415
- request[:method] = :DELETE
416
- request[:path] = "/async/{{client_id}}/jobs/#{id}"
417
- end.execute!
418
- end
419
-
420
- private
421
-
422
- #
423
- # Converts actions array to byte flag.
424
- #
425
- # @param [Array<String, Symbol>] actions
426
- # @return [Integer]
427
- # @raise [ArgumentError] if actions is not an array
428
- # @raise [ArgumentError] if action is unknown
429
- # @api private
430
- #
431
- def self.convert_actions_to_byte(actions)
432
- actions.is_a?(Array) or raise ArgumentError, "Actions should be an array, received: #{actions.inspect}"
433
- actions = actions.map(&:to_sym)
434
-
435
- possible_actions = ACTIONS.map { |hash| hash.first }
436
- actions.each do |action|
437
- possible_actions.include?(action) or raise ArgumentError, "Unknown action: #{action.inspect}"
438
- end
439
-
440
- byte_from_array(actions, ACTIONS)
441
- end
442
-
443
- #added in release 1.7.0
444
-
445
- #
446
- # Get Possible Conversions.
447
- #
448
- # @example
449
- # GroupDocs::Job.get_conversions! "pdf"
450
- #
451
- #
452
- # @param [Hash] access Access credentials
453
- # @option access [String] :client_id
454
- # @option access [String] :private_key
455
- # @param [String] file_ext File extension to check
456
- #
457
- def self.get_conversions!(access = {}, file_ext)
458
- api = Api::Request.new do |request|
459
- request[:access] = access
460
- request[:method] = :GET
461
- request[:path] = "/async/{{client_id}}/possibleConversions/#{file_ext}"
462
- end
463
- json = api.execute!
464
- json[:possibleConversions]
465
- end
466
-
467
- end # Job
468
- end # GroupDocs
1
+ module GroupDocs
2
+ class Job < Api::Entity
3
+
4
+ ACTIONS = {
5
+ :none => 0,
6
+ :convert => 1,
7
+ :combine => 2,
8
+ :compress_zip => 4,
9
+ :compress_rar => 8,
10
+ :trace => 16,
11
+ :convert_body => 32,
12
+ :bind_data => 64,
13
+ :print => 128,
14
+ :compare => 256,
15
+ :import_annotations => 512,
16
+ # add in release 1.5.8
17
+ :split => 1024,
18
+ :view => 2048,
19
+ :index => 4096,
20
+ :number_lines => 8192
21
+ }
22
+
23
+ extend Api::Helpers::ByteFlag
24
+ include Api::Helpers::Status
25
+
26
+ #
27
+ # Returns array of jobs.
28
+ #
29
+ # @param [Hash] options Hash of options
30
+ # @option options [String] :page Page Index
31
+ # @option options [String] :date Data
32
+ # @option options [String] :count How many items to list
33
+ # @option options [String] :statusIds Comma separated status identifiers
34
+ # @option options [String] :actions Actions
35
+ # @option options [String] :excluded_actions Excluded actions
36
+ # @option options [String] :jobName Foltred job name
37
+ # @param [Hash] access Access credentials
38
+ # @option access [String] :client_id
39
+ # @option access [String] :private_key
40
+ # @return [Array<GroupDocs::Job>]
41
+ #
42
+ def self.all!(options = {}, access = {})
43
+ api = Api::Request.new do |request|
44
+ request[:access] = access
45
+ request[:method] = :GET
46
+ request[:path] = '/async/{{client_id}}/jobs'
47
+ end
48
+ api.add_params(options)
49
+ json = api.execute!
50
+
51
+ json[:jobs].map do |job|
52
+ Job.new(job)
53
+ end
54
+ end
55
+
56
+ #
57
+ # Returns job by its identifier.
58
+ #
59
+ # @param [Integer] id
60
+ # @param [Hash] access Access credentials
61
+ # @option access [String] :client_id
62
+ # @option access [String] :private_key
63
+ # @return [GroupDocs::Job]
64
+ #
65
+ def self.get!(id, access = {})
66
+ api = Api::Request.new do |request|
67
+ request[:access] = access
68
+ request[:method] = :GET
69
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
70
+ end
71
+ api.add_params(:format => 'json')
72
+ json = api.execute!
73
+
74
+ Job.new(json)
75
+ end
76
+
77
+ #
78
+ # Returns job by its identifier.
79
+ #
80
+ # @param [Integer] id
81
+ # @param [Hash] access Access credentials
82
+ # @option access [String] :client_id
83
+ # @option access [String] :private_key
84
+ # @return [GroupDocs::Job]
85
+ #
86
+ def self.get_xml!(id, access = {})
87
+ api = Api::Request.new do |request|
88
+ request[:access] = access
89
+ request[:method] = :GET
90
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
91
+ end
92
+ api.add_params(:format => 'xml')
93
+ json = api.execute!
94
+
95
+ Job.new(json)
96
+ end
97
+
98
+
99
+ #
100
+ # Returns job by its identifier.
101
+ #
102
+ # @param [Hash] options
103
+ # @option statusIds [String] :statusIds (required)
104
+ # @option actions [Integer] :actions
105
+ # @option excluded_actions [String] :excluded_actions
106
+ # @param [Hash] access Access credentials
107
+ # @option access [String] :client_id
108
+ # @option access [String] :private_key
109
+ # @return [GroupDocs::Job]
110
+ #
111
+ def self.get_resources!(options = {} , access = {})
112
+ options[:actions] = convert_actions_to_byte(options[:actions])
113
+ api = Api::Request.new do |request|
114
+ request[:access] = access
115
+ request[:method] = :GET
116
+ request[:path] = "/async/{{client_id}}/jobs/resources"
117
+ end
118
+ api.add_params(options)
119
+ json = api.execute!
120
+
121
+ json[:dates]
122
+ end
123
+
124
+ #
125
+ # Creates new draft job.
126
+ #
127
+ # @param [Hash] options
128
+ # @option options [Integer] :actions Array of actions to be performed. Required
129
+ # @option options [Boolean] :email_results
130
+ # @option options [Array] :out_formats
131
+ # @option options [Boolean] :url_only
132
+ # @param [Hash] access Access credentials
133
+ # @option access [String] :client_id
134
+ # @option access [String] :private_key
135
+ # @return [GroupDocs::Job]
136
+ #
137
+ def self.create!(options, access = {})
138
+ options[:actions] or raise ArgumentError, 'options[:actions] is required.'
139
+ options[:actions] = convert_actions_to_byte(options[:actions])
140
+ #options[:out_formats] = options[:out_formats].join(?;) if options[:out_formats]
141
+
142
+ api = Api::Request.new do |request|
143
+ request[:access] = access
144
+ request[:method] = :POST
145
+ request[:path] = '/async/{{client_id}}/jobs'
146
+ request[:request_body] = options
147
+ end
148
+ json = api.execute!
149
+
150
+ Job.new(:id => json[:job_id], :guid => json[:job_guid])
151
+ end
152
+
153
+ # @attr [Integer] id
154
+ attr_accessor :id
155
+ # @attr [String] guid
156
+ attr_accessor :guid
157
+ # @attr [String] name
158
+ attr_accessor :name
159
+ # @attr [Integer] priority
160
+ attr_accessor :priority
161
+ # @attr [Array<Symbol>] actions
162
+ attr_accessor :actions
163
+ # @attr [Boolean] email_results
164
+ attr_accessor :email_results
165
+ # @attr [Boolean] url_only
166
+ attr_accessor :url_only
167
+ # @attr [Array<GroupDocs::Document] documents
168
+ attr_accessor :documents
169
+ # @attr [Time] requested_time
170
+ attr_accessor :requested_time
171
+ # @attr [Symbol] status
172
+ attr_accessor :status
173
+
174
+ #
175
+ # Coverts passed array of attributes hash to array of GroupDocs::Document.
176
+ #
177
+ # @param [Array<Hash>] documents Array of document attributes hashes
178
+ #
179
+ def documents=(documents)
180
+ if documents
181
+ @documents = documents[:inputs].map do |document|
182
+ document.merge!(:file => GroupDocs::Storage::File.new(document))
183
+ Document.new(document)
184
+ end
185
+ end
186
+ end
187
+
188
+ #
189
+ # Converts status to human-readable format.
190
+ #
191
+ # @return [Symbol]
192
+ #
193
+ def status
194
+ parse_status(@status)
195
+ end
196
+
197
+ #
198
+ # Converts timestamp which is return by API server to Time object.
199
+ #
200
+ # @return [Time]
201
+ #
202
+ def requested_time
203
+ Time.at(@requested_time / 1000)
204
+ end
205
+
206
+ #
207
+ # Returns job actions in human-readable format.
208
+ #
209
+ # @return [Array<Symbol>]
210
+ #
211
+ def actions
212
+ @actions.split(', ').map { |action| action.underscore.to_sym } if @actions
213
+ end
214
+
215
+ #
216
+ # Returns an hash of input and output documents associated to job.
217
+ #
218
+ # @param [Hash] access Access credentials
219
+ # @option access [String] :client_id
220
+ # @option access [String] :private_key
221
+ # @return [Hash]
222
+ #
223
+ def documents!(access = {})
224
+ json = Api::Request.new do |request|
225
+ request[:access] = access
226
+ request[:method] = :GET
227
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/documents"
228
+ end.execute!
229
+
230
+ self.status = json[:job_status]
231
+ documents = {
232
+ :inputs => [],
233
+ :outputs => [],
234
+ }
235
+
236
+ # add input documents
237
+ if json[:inputs]
238
+ json[:inputs].each do |document|
239
+ document.merge!(:file => GroupDocs::Storage::File.new(document))
240
+ documents[:inputs] << Document.new(document)
241
+ end
242
+ end
243
+
244
+ # add output documents
245
+ if json[:outputs]
246
+ json[:outputs].each do |document|
247
+ document.merge!(:file => GroupDocs::Storage::File.new(document))
248
+ documents[:outputs] << Document.new(document)
249
+ end
250
+ end
251
+
252
+ documents
253
+ end
254
+
255
+ #
256
+ # Returns job actions in human-readable format.
257
+ #
258
+ # @return [Array<Symbol>]
259
+ #
260
+ def actions
261
+ @actions.split(', ').map { |action| action.underscore.to_sym } if @actions
262
+ end
263
+
264
+ #
265
+ # Returns an array of input and output documents associated to jobs.
266
+ #
267
+ # @param [Hash] options
268
+ # @option page [String] Page Index
269
+ # @option count [String] Page Size
270
+ # @option actions [String] Actions
271
+ # @option excluded_actions [String] Excluded actions
272
+ # @option order_by [String] Order by
273
+ # @option order_asc [String] Order ask
274
+ # @param [Hash] access Access credentials
275
+ # @option access [String] :client_id
276
+ # @option access [String] :private_key
277
+ # @return [Hash]
278
+ #
279
+ def self.jobs_documents!(options = {}, access = {})
280
+ api = Api::Request.new do |request|
281
+ request[:access] = access
282
+ request[:method] = :GET
283
+ request[:path] = "/async/{{client_id}}/jobs/documents"
284
+ end
285
+ api.add_params(options)
286
+ api.execute!
287
+
288
+ end
289
+
290
+ #
291
+ # Adds document to job.
292
+ #
293
+ # @param [GroupDocs::Document] document
294
+ # @param [Hash] options
295
+ # @option options [Array] :output_formats Array of output formats to override
296
+ # @param [Hash] access Access credentials
297
+ # @option access [String] :client_id
298
+ # @option access [String] :private_key
299
+ # @return [Integer] Document ID
300
+ #
301
+ # @raise [ArgumentError] If document is not a GroupDocs::Document object
302
+ #
303
+ def add_document!(document, options = {}, access = {})
304
+ document.is_a?(GroupDocs::Document) or raise ArgumentError,
305
+ "Document should be GroupDocs::Document object. Received: #{document.inspect}"
306
+
307
+ api = Api::Request.new do |request|
308
+ request[:access] = access
309
+ request[:method] = :PUT
310
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.guid}"
311
+ end
312
+ api.add_params(options)
313
+ json = api.execute!
314
+
315
+ json[:document_id]
316
+ end
317
+
318
+ #
319
+ # Deletes document with guid from job.
320
+ #
321
+ # @param [String] guid
322
+ # @param [Hash] access Access credentials
323
+ # @option access [String] :client_id
324
+ # @option access [String] :private_key
325
+ #
326
+ def delete_document!(guid, access = {})
327
+ Api::Request.new do |request|
328
+ request[:access] = access
329
+ request[:method] = :DELETE
330
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/documents/#{guid}"
331
+ end.execute!
332
+ end
333
+
334
+ #
335
+ # Adds datasource to job document.
336
+ #
337
+ # @param [GroupDocs::Document] document
338
+ # @param [GroupDocs::DataSource] datasource
339
+ # @param [Hash] access Access credentials
340
+ # @option access [String] :client_id
341
+ # @option access [String] :private_key
342
+ #
343
+ # @raise [ArgumentError] If document is not a GroupDocs::Document object
344
+ # @raise [ArgumentError] If datasource is not a GroupDocs::DataSource object
345
+ #
346
+ def add_datasource!(document, datasource, access = {})
347
+ document.is_a?(GroupDocs::Document) or raise ArgumentError,
348
+ "Document should be GroupDocs::Document object. Received: #{document.inspect}"
349
+ datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError,
350
+ "Datasource should be GroupDocs::DataSource object. Received: #{datasource.inspect}"
351
+
352
+ Api::Request.new do |request|
353
+ request[:access] = access
354
+ request[:method] = :PUT
355
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/files/#{document.file.id}/datasources/#{datasource.id}"
356
+ end.execute!
357
+ end
358
+
359
+ #
360
+ # Adds URL of web page or document to be converted.
361
+ #
362
+ # @param [String] url Absolute URL
363
+ # @param [Hash] options
364
+ # @option options [Array] :output_formats Array of output formats to override
365
+ # @param [Hash] access Access credentials
366
+ # @option access [String] :client_id
367
+ # @option access [String] :private_key
368
+ # @return [Integer] Document ID
369
+ #
370
+ def add_url!(url, options = {}, access = {})
371
+ options.merge!(:absolute_url => url)
372
+
373
+ api = Api::Request.new do |request|
374
+ request[:access] = access
375
+ request[:method] = :PUT
376
+ request[:path] = "/async/{{client_id}}/jobs/#{id}/urls"
377
+ end
378
+ api.add_params(options)
379
+ json = api.execute!
380
+
381
+ json[:document_id]
382
+ end
383
+
384
+ #
385
+ # Updates job settings and/or status.
386
+ #
387
+ # @param [Hash] options
388
+ # @option options [Boolean] :email_results
389
+ # @option options [Symbol] :status
390
+ # @param [Hash] access Access credentials
391
+ # @option access [String] :client_id
392
+ # @option access [String] :private_key
393
+ #
394
+ def update!(options, access = {})
395
+ options[:status] = parse_status(options[:status]) if options[:status]
396
+
397
+ Api::Request.new do |request|
398
+ request[:access] = access
399
+ request[:method] = :PUT
400
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
401
+ request[:request_body] = options
402
+ end.execute!
403
+ end
404
+
405
+ #
406
+ # Deletes draft job.
407
+ #
408
+ # @param [Hash] access Access credentials
409
+ # @option access [String] :client_id
410
+ # @option access [String] :private_key
411
+ #
412
+ def delete!(access = {})
413
+ Api::Request.new do |request|
414
+ request[:access] = access
415
+ request[:method] = :DELETE
416
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
417
+ end.execute!
418
+ end
419
+
420
+ private
421
+
422
+ #
423
+ # Converts actions array to byte flag.
424
+ #
425
+ # @param [Array<String, Symbol>] actions
426
+ # @return [Integer]
427
+ # @raise [ArgumentError] if actions is not an array
428
+ # @raise [ArgumentError] if action is unknown
429
+ # @api private
430
+ #
431
+ def self.convert_actions_to_byte(actions)
432
+ actions.is_a?(Array) or raise ArgumentError, "Actions should be an array, received: #{actions.inspect}"
433
+ actions = actions.map(&:to_sym)
434
+
435
+ possible_actions = ACTIONS.map { |hash| hash.first }
436
+ actions.each do |action|
437
+ possible_actions.include?(action) or raise ArgumentError, "Unknown action: #{action.inspect}"
438
+ end
439
+
440
+ byte_from_array(actions, ACTIONS)
441
+ end
442
+
443
+ #added in release 1.7.0
444
+
445
+ #
446
+ # Get Possible Conversions.
447
+ #
448
+ # @example
449
+ # GroupDocs::Job.get_conversions! "pdf"
450
+ #
451
+ #
452
+ # @param [Hash] access Access credentials
453
+ # @option access [String] :client_id
454
+ # @option access [String] :private_key
455
+ # @param [String] file_ext File extension to check
456
+ #
457
+ def self.get_conversions!(access = {}, file_ext)
458
+ api = Api::Request.new do |request|
459
+ request[:access] = access
460
+ request[:method] = :GET
461
+ request[:path] = "/async/{{client_id}}/possibleConversions/#{file_ext}"
462
+ end
463
+ json = api.execute!
464
+ json[:possibleConversions]
465
+ end
466
+
467
+ end # Job
468
+ end # GroupDocs