groupdocs 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/.travis.yml +0 -0
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile +0 -0
  4. data/README.md +4 -2
  5. data/Rakefile +0 -0
  6. data/examples/README.md +0 -0
  7. data/examples/annotations/Gemfile +0 -0
  8. data/examples/annotations/app.rb +0 -0
  9. data/groupdocs.gemspec +0 -0
  10. data/lib/groupdocs/api/entity.rb +0 -0
  11. data/lib/groupdocs/api/helpers/access_mode_helper.rb +0 -0
  12. data/lib/groupdocs/api/helpers/access_rights_helper.rb +54 -0
  13. data/lib/groupdocs/api/helpers/byte_flag_helper.rb +49 -0
  14. data/lib/groupdocs/api/helpers/credentials_helper.rb +0 -0
  15. data/lib/groupdocs/api/helpers/path_helper.rb +0 -0
  16. data/lib/groupdocs/api/helpers/rest_helper.rb +0 -0
  17. data/lib/groupdocs/api/helpers/status_helper.rb +0 -0
  18. data/lib/groupdocs/api/helpers/url_helper.rb +0 -0
  19. data/lib/groupdocs/api/helpers.rb +2 -1
  20. data/lib/groupdocs/api/request.rb +0 -0
  21. data/lib/groupdocs/api.rb +0 -0
  22. data/lib/groupdocs/datasource/field.rb +0 -0
  23. data/lib/groupdocs/datasource.rb +0 -0
  24. data/lib/groupdocs/document/annotation/reply.rb +0 -0
  25. data/lib/groupdocs/document/annotation/reviewer.rb +60 -0
  26. data/lib/groupdocs/document/annotation.rb +19 -44
  27. data/lib/groupdocs/document/change.rb +0 -0
  28. data/lib/groupdocs/document/field.rb +0 -0
  29. data/lib/groupdocs/document/metadata.rb +0 -0
  30. data/lib/groupdocs/document/rectangle.rb +0 -0
  31. data/lib/groupdocs/document/view.rb +0 -0
  32. data/lib/groupdocs/document.rb +129 -0
  33. data/lib/groupdocs/errors.rb +0 -0
  34. data/lib/groupdocs/job.rb +53 -1
  35. data/lib/groupdocs/questionnaire/execution.rb +0 -0
  36. data/lib/groupdocs/questionnaire/page.rb +0 -0
  37. data/lib/groupdocs/questionnaire/question/answer.rb +0 -0
  38. data/lib/groupdocs/questionnaire/question.rb +0 -0
  39. data/lib/groupdocs/questionnaire.rb +0 -0
  40. data/lib/groupdocs/signature/contact.rb +0 -0
  41. data/lib/groupdocs/signature/envelope/log.rb +0 -0
  42. data/lib/groupdocs/signature/envelope.rb +0 -0
  43. data/lib/groupdocs/signature/field/location.rb +0 -0
  44. data/lib/groupdocs/signature/field.rb +0 -0
  45. data/lib/groupdocs/signature/form.rb +0 -0
  46. data/lib/groupdocs/signature/list.rb +0 -0
  47. data/lib/groupdocs/signature/recipient.rb +0 -0
  48. data/lib/groupdocs/signature/role.rb +0 -0
  49. data/lib/groupdocs/signature/shared/document_methods.rb +0 -0
  50. data/lib/groupdocs/signature/shared/entity_fields.rb +0 -0
  51. data/lib/groupdocs/signature/shared/entity_methods.rb +0 -0
  52. data/lib/groupdocs/signature/shared/field_methods.rb +0 -0
  53. data/lib/groupdocs/signature/shared/recipient_methods.rb +0 -0
  54. data/lib/groupdocs/signature/shared/resource_methods.rb +0 -0
  55. data/lib/groupdocs/signature/shared.rb +0 -0
  56. data/lib/groupdocs/signature/template.rb +0 -0
  57. data/lib/groupdocs/signature.rb +0 -0
  58. data/lib/groupdocs/storage/file.rb +0 -0
  59. data/lib/groupdocs/storage/folder.rb +0 -0
  60. data/lib/groupdocs/storage/package.rb +0 -0
  61. data/lib/groupdocs/storage.rb +0 -0
  62. data/lib/groupdocs/subscription/limit.rb +0 -0
  63. data/lib/groupdocs/subscription.rb +0 -0
  64. data/lib/groupdocs/user.rb +31 -4
  65. data/lib/groupdocs/version.rb +1 -1
  66. data/lib/groupdocs.rb +0 -0
  67. data/spec/groupdocs/api/entity_spec.rb +0 -0
  68. data/spec/groupdocs/api/helpers/access_mode_helper_spec.rb +0 -1
  69. data/spec/groupdocs/api/helpers/access_rights_helper_spec.rb +43 -0
  70. data/spec/groupdocs/api/helpers/byte_flag_helper_spec.rb +23 -0
  71. data/spec/groupdocs/api/helpers/credentials_helpers_spec.rb +0 -0
  72. data/spec/groupdocs/api/helpers/path_helper_spec.rb +0 -0
  73. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +0 -0
  74. data/spec/groupdocs/api/helpers/status_helper_spec.rb +0 -0
  75. data/spec/groupdocs/api/helpers/url_helper_spec.rb +0 -0
  76. data/spec/groupdocs/api/request_spec.rb +0 -0
  77. data/spec/groupdocs/datasource/field_spec.rb +0 -0
  78. data/spec/groupdocs/datasource_spec.rb +0 -0
  79. data/spec/groupdocs/document/annotation/reply_spec.rb +0 -0
  80. data/spec/groupdocs/document/annotation/reviewer_spec.rb +57 -0
  81. data/spec/groupdocs/document/annotation_spec.rb +12 -44
  82. data/spec/groupdocs/document/change_spec.rb +0 -0
  83. data/spec/groupdocs/document/field_spec.rb +0 -0
  84. data/spec/groupdocs/document/metadata_spec.rb +0 -0
  85. data/spec/groupdocs/document/rectangle_spec.rb +0 -0
  86. data/spec/groupdocs/document/view_spec.rb +0 -0
  87. data/spec/groupdocs/document_spec.rb +138 -0
  88. data/spec/groupdocs/errors_spec.rb +0 -0
  89. data/spec/groupdocs/job_spec.rb +42 -0
  90. data/spec/groupdocs/questionnaire/execution_spec.rb +0 -0
  91. data/spec/groupdocs/questionnaire/page_spec.rb +0 -0
  92. data/spec/groupdocs/questionnaire/question/answer_spec.rb +0 -0
  93. data/spec/groupdocs/questionnaire/question_spec.rb +0 -0
  94. data/spec/groupdocs/questionnaire_spec.rb +0 -0
  95. data/spec/groupdocs/signature/contact_spec.rb +0 -0
  96. data/spec/groupdocs/signature/envelope/log_spec.rb +0 -0
  97. data/spec/groupdocs/signature/envelope_spec.rb +0 -0
  98. data/spec/groupdocs/signature/field/location_spec.rb +0 -0
  99. data/spec/groupdocs/signature/field_spec.rb +0 -0
  100. data/spec/groupdocs/signature/form_spec.rb +0 -0
  101. data/spec/groupdocs/signature/list_spec.rb +0 -0
  102. data/spec/groupdocs/signature/recipient_spec.rb +0 -0
  103. data/spec/groupdocs/signature/role_spec.rb +0 -0
  104. data/spec/groupdocs/signature/template_spec.rb +0 -0
  105. data/spec/groupdocs/signature_spec.rb +0 -0
  106. data/spec/groupdocs/storage/file_spec.rb +0 -0
  107. data/spec/groupdocs/storage/folder_spec.rb +0 -0
  108. data/spec/groupdocs/storage/package_spec.rb +0 -0
  109. data/spec/groupdocs/storage_spec.rb +0 -0
  110. data/spec/groupdocs/subscription/limit_spec.rb +0 -0
  111. data/spec/groupdocs/subscription_spec.rb +0 -0
  112. data/spec/groupdocs/user_spec.rb +62 -37
  113. data/spec/groupdocs_spec.rb +0 -0
  114. data/spec/spec_helper.rb +0 -0
  115. data/spec/support/files/envelope.zip +0 -0
  116. data/spec/support/files/resume.pdf +0 -0
  117. data/spec/support/json/annotation_access_set.json +0 -0
  118. data/spec/support/json/annotation_collaborators_get.json +0 -0
  119. data/spec/support/json/annotation_collaborators_set.json +0 -0
  120. data/spec/support/json/annotation_create.json +0 -0
  121. data/spec/support/json/annotation_list.json +0 -0
  122. data/spec/support/json/annotation_move.json +0 -0
  123. data/spec/support/json/annotation_remove.json +0 -0
  124. data/spec/support/json/annotation_replies_create.json +0 -0
  125. data/spec/support/json/annotation_replies_get.json +0 -0
  126. data/spec/support/json/annotation_reviewers_get.json +18 -0
  127. data/spec/support/json/comparison_changes.json +0 -0
  128. data/spec/support/json/comparison_compare.json +0 -0
  129. data/spec/support/json/comparison_document.json +0 -0
  130. data/spec/support/json/contact_add.json +0 -0
  131. data/spec/support/json/contacts_get.json +0 -0
  132. data/spec/support/json/contacts_import.json +0 -0
  133. data/spec/support/json/datasource_add.json +0 -0
  134. data/spec/support/json/datasource_get.json +0 -0
  135. data/spec/support/json/datasource_remove.json +0 -0
  136. data/spec/support/json/datasource_update.json +0 -0
  137. data/spec/support/json/document_access_info_get.json +0 -0
  138. data/spec/support/json/document_convert.json +0 -0
  139. data/spec/support/json/document_datasource.json +0 -0
  140. data/spec/support/json/document_fields.json +0 -0
  141. data/spec/support/json/document_formats.json +0 -0
  142. data/spec/support/json/document_metadata.json +0 -0
  143. data/spec/support/json/document_questionnaire_create.json +0 -0
  144. data/spec/support/json/document_questionnaires.json +0 -0
  145. data/spec/support/json/document_sharers_remove.json +0 -0
  146. data/spec/support/json/document_sharers_set.json +0 -0
  147. data/spec/support/json/document_views.json +0 -0
  148. data/spec/support/json/envelope_get.json +0 -0
  149. data/spec/support/json/envelope_logs.json +0 -0
  150. data/spec/support/json/envelopes_all.json +0 -0
  151. data/spec/support/json/envelopes_resources.json +0 -0
  152. data/spec/support/json/file_compress.json +0 -0
  153. data/spec/support/json/file_copy.json +0 -0
  154. data/spec/support/json/file_delete.json +0 -0
  155. data/spec/support/json/file_move.json +0 -0
  156. data/spec/support/json/file_upload.json +0 -0
  157. data/spec/support/json/folder_create.json +0 -0
  158. data/spec/support/json/folder_delete.json +0 -0
  159. data/spec/support/json/folder_list.json +0 -0
  160. data/spec/support/json/folder_move.json +0 -0
  161. data/spec/support/json/folder_sharers_get.json +0 -0
  162. data/spec/support/json/folder_sharers_remove.json +0 -0
  163. data/spec/support/json/folder_sharers_set.json +0 -0
  164. data/spec/support/json/form_get.json +0 -0
  165. data/spec/support/json/forms_all.json +0 -0
  166. data/spec/support/json/job_add_url.json +0 -0
  167. data/spec/support/json/job_create.json +0 -0
  168. data/spec/support/json/job_documents.json +0 -0
  169. data/spec/support/json/job_file_add.json +0 -0
  170. data/spec/support/json/job_get.json +0 -0
  171. data/spec/support/json/job_update.json +0 -0
  172. data/spec/support/json/jobs_get.json +0 -0
  173. data/spec/support/json/list_add.json +0 -0
  174. data/spec/support/json/lists_get.json +0 -0
  175. data/spec/support/json/package_create.json +0 -0
  176. data/spec/support/json/questionnaire_create.json +0 -0
  177. data/spec/support/json/questionnaire_datasources.json +0 -0
  178. data/spec/support/json/questionnaire_execution_create.json +0 -0
  179. data/spec/support/json/questionnaire_execution_status_set.json +0 -0
  180. data/spec/support/json/questionnaire_execution_update.json +0 -0
  181. data/spec/support/json/questionnaire_executions.json +0 -0
  182. data/spec/support/json/questionnaire_get.json +0 -0
  183. data/spec/support/json/questionnaire_remove.json +0 -0
  184. data/spec/support/json/questionnaire_update.json +0 -0
  185. data/spec/support/json/questionnaires_get.json +0 -0
  186. data/spec/support/json/signature_create.json +0 -0
  187. data/spec/support/json/signature_field_add.json +0 -0
  188. data/spec/support/json/signature_fields_get.json +0 -0
  189. data/spec/support/json/signature_roles_get.json +0 -0
  190. data/spec/support/json/signatures_get.json +0 -0
  191. data/spec/support/json/storage_info.json +0 -0
  192. data/spec/support/json/subscription_plan_get.json +0 -0
  193. data/spec/support/json/subscription_plans_get.json +0 -0
  194. data/spec/support/json/template_get.json +0 -0
  195. data/spec/support/json/template_get_documents.json +0 -0
  196. data/spec/support/json/template_get_recipients.json +0 -0
  197. data/spec/support/json/templates_all.json +0 -0
  198. data/spec/support/json/user_profile_get.json +0 -0
  199. data/spec/support/json/user_users_get.json +0 -0
  200. data/spec/support/shared_examples/api/entity.rb +0 -0
  201. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +0 -0
  202. data/spec/support/shared_examples/api/helpers/status_helper.rb +0 -0
  203. data/spec/support/shared_examples/signature/shared/document_methods.rb +0 -0
  204. data/spec/support/shared_examples/signature/shared/entity_fields.rb +0 -0
  205. data/spec/support/shared_examples/signature/shared/entity_methods.rb +0 -0
  206. data/spec/support/shared_examples/signature/shared/field_methods.rb +0 -0
  207. data/spec/support/shared_examples/signature/shared/recipient_methods.rb +0 -0
  208. data/spec/support/shared_examples/signature/shared/resource_methods.rb +0 -0
  209. metadata +72 -24
  210. data/lib/groupdocs/api/helpers/actions_helper.rb +0 -48
  211. data/spec/groupdocs/api/helpers/actions_helper_spec.rb +0 -37
data/.travis.yml CHANGED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## v1.1
2
+
3
+ **New**
4
+
5
+ * Added `Annotation::Reviewer` class
6
+ * Added `Reviewer.all!`
7
+ * Added `Reviewer.set!`
8
+ * Added `Job#delete!`
9
+ * Added `Document#shared_link_access_rights!`
10
+ * Added `Document#set_shared_link_access_rights!`
11
+ * Added `Document#set_reviewers!`
12
+ * Added `Document#add_collaborotor!`
13
+ * More attributes for `User` class
14
+ * Added `Annotation#move_marker!`
15
+ * Added new `Job` action - `:compare`
16
+
17
+ **Changes**
18
+
19
+ * Moved `Annotation#collaborators!` and `Annotation#set_collaborators!` to `Document` class as it makes more sense
20
+ * `Document#set_collaborators!` now accepts options `version` parameter (default to `1`)
21
+
22
+
1
23
  ## v1.0
2
24
 
3
25
  **New**
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
@@ -23,7 +23,7 @@ Installing from source
23
23
 
24
24
  All "bang" methods (ending with exclamation sign) imply interaction with API server.
25
25
 
26
- Other methods (with expect to some methods - see documentation) do not operate with API Server
26
+ Other methods (with expect to some, see documentation) do not operate with API Server
27
27
 
28
28
  ### Configuration
29
29
 
@@ -53,7 +53,9 @@ GroupDocs::Storage::Folder.create!('/folder', client_id: 'your_client_id', priva
53
53
 
54
54
  ### Documentation
55
55
 
56
- Reference to [this page](http://rubydoc.info/gems/groupdocs) for docs
56
+ Reference to [this page](http://rubydoc.info/gems/groupdocs) for docs and examples.
57
+
58
+ There are also some examples in [repository](https://github.com/groupdocs/groupdocs-ruby/tree/master/examples) and on [wiki](https://github.com/groupdocs/groupdocs-ruby/wiki)
57
59
 
58
60
  ### Entities
59
61
 
data/Rakefile CHANGED
File without changes
data/examples/README.md CHANGED
File without changes
File without changes
File without changes
data/groupdocs.gemspec CHANGED
File without changes
File without changes
File without changes
@@ -0,0 +1,54 @@
1
+ module GroupDocs
2
+ module Api
3
+ module Helpers
4
+ module AccessRights
5
+
6
+ include Api::Helpers::ByteFlag
7
+
8
+ ACCESS_RIGHTS = {
9
+ export: 1,
10
+ download: 2,
11
+ proof: 4,
12
+ view: 8,
13
+ }
14
+
15
+ private
16
+
17
+ #
18
+ # Converts shared link access rights array to byte flag.
19
+ #
20
+ # @param [Array<String, Symbol>] rights
21
+ # @return [Integer]
22
+ # @raise [ArgumentError] if rights is not an array
23
+ # @raise [ArgumentError] if right is unknown
24
+ # @api private
25
+ #
26
+ def convert_access_rights_to_byte(rights)
27
+ rights.is_a?(Array) or raise ArgumentError, "Rights should be an array, received: #{rights.inspect}"
28
+ rights = rights.map(&:to_sym)
29
+
30
+ possible_rights = ACCESS_RIGHTS.map { |hash| hash.first }
31
+ rights.each do |right|
32
+ possible_rights.include?(right) or raise ArgumentError, "Unknown access right: #{rights.inspect}"
33
+ end
34
+
35
+ byte_from_array(rights, ACCESS_RIGHTS)
36
+ end
37
+
38
+ #
39
+ # Converts byte flag to shared link access rights array.
40
+ #
41
+ # @param [Integer] rights
42
+ # @return [Array<Symbol>]
43
+ # @raise [ArgumentError] if rights is not integer
44
+ # @api private
45
+ #
46
+ def convert_byte_to_access_rights(rights)
47
+ rights.is_a?(Integer) or raise ArgumentError, "Rights should be an integer, received: #{rights.inspect}"
48
+ array_from_byte(rights, ACCESS_RIGHTS)
49
+ end
50
+
51
+ end # AccessRights
52
+ end # Helpers
53
+ end # Api
54
+ end # GroupDocs
@@ -0,0 +1,49 @@
1
+ module GroupDocs
2
+ module Api
3
+ module Helpers
4
+ module ByteFlag
5
+
6
+ #
7
+ # Converts array of values to byte flag using hash of value => byte.
8
+ #
9
+ # @param [Array<String, Symbol>] values
10
+ # @param [Hash] value_byte_hash
11
+ # @return [Integer]
12
+ # @raise [ArgumentError] if values is not an array
13
+ # @api private
14
+ #
15
+ def byte_from_array(values, value_byte_hash)
16
+ flag = 0
17
+ values.each do |value|
18
+ flag += value_byte_hash[value]
19
+ end
20
+
21
+ flag
22
+ end
23
+
24
+ #
25
+ # Converts byte flag to array of values using hash of value => byte.
26
+ #
27
+ # @param [Integer] byte
28
+ # @param [Hash] value_byte_hash
29
+ # @return [Integer]
30
+ # @api private
31
+ #
32
+ def array_from_byte(byte, value_byte_hash)
33
+ values = []
34
+
35
+ value_byte_hash.reverse_each do |value, flag|
36
+ decreased_byte = byte - flag
37
+ if decreased_byte >= 0
38
+ values << value
39
+ byte = decreased_byte
40
+ end
41
+ end
42
+
43
+ values
44
+ end
45
+
46
+ end # ByteFlag
47
+ end # Helpers
48
+ end # Api
49
+ end # GroupDocs
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,6 @@
1
+ require 'groupdocs/api/helpers/byte_flag_helper'
1
2
  require 'groupdocs/api/helpers/access_mode_helper'
2
- require 'groupdocs/api/helpers/actions_helper'
3
+ require 'groupdocs/api/helpers/access_rights_helper'
3
4
  require 'groupdocs/api/helpers/credentials_helper'
4
5
  require 'groupdocs/api/helpers/path_helper'
5
6
  require 'groupdocs/api/helpers/rest_helper'
File without changes
data/lib/groupdocs/api.rb CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,60 @@
1
+ module GroupDocs
2
+ class Document::Annotation::Reviewer < Api::Entity
3
+
4
+ #
5
+ # Returns all reviewer contacts.
6
+ #
7
+ # @param [Hash] access Access credentials
8
+ # @option access [String] :client_id
9
+ # @option access [String] :private_key
10
+ # @return [Array<GroupDocs::Document::Annotation::Reviewer>]
11
+ #
12
+ def self.all!(access = {})
13
+ json = Api::Request.new do |request|
14
+ request[:access] = access
15
+ request[:method] = :GET
16
+ request[:path] = '/ant/{{client_id}}/contacts'
17
+ end.execute!
18
+
19
+ json[:reviewerContacts].map do |reviewer|
20
+ new(reviewer)
21
+ end
22
+ end
23
+
24
+ #
25
+ # Sets reviewer contacts to passed array.
26
+ #
27
+ # Please, note that it removes existing reviewer contacts.
28
+ #
29
+ # @example Add new reviewer contact
30
+ # reviewers = GroupDocs::Document::Annotation::Reviewer.all!
31
+ # reviewers << GroupDocs::Document::Annotation::Reviewer.new(full_name: 'John Smith', email_address: 'john@smith.com')
32
+ # GroupDocs::Document::Annotation::Reviewer.set! reviewers
33
+ #
34
+ # @param [Array<GroupDocs::Document::Annotation::Reviewer>] reviewers
35
+ # @param [Hash] access Access credentials
36
+ # @option access [String] :client_id
37
+ # @option access [String] :private_key
38
+ #
39
+ def self.set!(reviewers, access = {})
40
+ Api::Request.new do |request|
41
+ request[:access] = access
42
+ request[:method] = :PUT
43
+ request[:path] = '/ant/{{client_id}}/reviewerContacts'
44
+ request[:request_body] = reviewers.each.map(&:to_hash)
45
+ end.execute!
46
+ end
47
+
48
+ # @attr [String] emailAddress
49
+ attr_accessor :emailAddress
50
+ # @attr [String] FullName
51
+ attr_accessor :FullName
52
+
53
+ # Human-readable accessors
54
+ alias_method :email_address, :emailAddress
55
+ alias_method :email_address=, :emailAddress=
56
+ alias_method :full_name, :FullName
57
+ alias_method :full_name=, :FullName=
58
+
59
+ end # Document::Annotation::Reviewer
60
+ end # GroupDocs
@@ -2,6 +2,7 @@ module GroupDocs
2
2
  class Document::Annotation < Api::Entity
3
3
 
4
4
  require 'groupdocs/document/annotation/reply'
5
+ require 'groupdocs/document/annotation/reviewer'
5
6
 
6
7
  include Api::Helpers::AccessMode
7
8
 
@@ -181,50 +182,6 @@ module GroupDocs
181
182
  end
182
183
  end
183
184
 
184
- #
185
- # Returns annotation collaborators.
186
- #
187
- # @param [Hash] access Access credentials
188
- # @option access [String] :client_id
189
- # @option access [String] :private_key
190
- # @return [Array<GroupDocs::User>]
191
- #
192
- def collaborators!(access = {})
193
- json = Api::Request.new do |request|
194
- request[:access] = access
195
- request[:method] = :GET
196
- request[:path] = "/ant/{{client_id}}/files/#{document.file.guid}/collaborators"
197
- end.execute!
198
-
199
- json[:collaborators].map do |collaborator|
200
- User.new(collaborator)
201
- end
202
- end
203
-
204
- #
205
- # Sets annotation collaborators to given emails.
206
- #
207
- # @param [Array] emails List of collaborators' email addresses
208
- # @param [Hash] access Access credentials
209
- # @option access [String] :client_id
210
- # @option access [String] :private_key
211
- # @return [Array<GroupDocs::User>]
212
- #
213
- def collaborators_set!(emails, access = {})
214
- json = Api::Request.new do |request|
215
- request[:access] = access
216
- request[:method] = :PUT
217
- request[:path] = "/ant/{{client_id}}/files/#{document.file.guid}/collaborators"
218
- request[:request_body] = emails
219
- end.execute!
220
-
221
- json[:collaborators].map do |collaborator|
222
- User.new(collaborator)
223
- end
224
- end
225
- # note that aliased version cannot accept access credentials hash
226
- alias_method :collaborators=, :collaborators_set!
227
-
228
185
  #
229
186
  # Removes annotation.
230
187
  #
@@ -276,6 +233,24 @@ module GroupDocs
276
233
  self.annotation_position = { x: x, y: y }
277
234
  end
278
235
 
236
+ #
237
+ # Moves annotation marker to given coordinates.
238
+ #
239
+ # @param [Integer, Float] x
240
+ # @param [Integer, Float] y
241
+ # @param [Hash] access Access credentials
242
+ # @option access [String] :client_id
243
+ # @option access [String] :private_key
244
+ #
245
+ def move_marker!(x, y, access = {})
246
+ Api::Request.new do |request|
247
+ request[:access] = access
248
+ request[:method] = :PUT
249
+ request[:path] = "/ant/{{client_id}}/annotations/#{guid}/markerPosition"
250
+ request[:request_body] = { x: x, y: y }
251
+ end.execute!
252
+ end
253
+
279
254
  #
280
255
  # Sets access mode.
281
256
  #
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -16,6 +16,7 @@ module GroupDocs
16
16
  }
17
17
 
18
18
  include Api::Helpers::AccessMode
19
+ include Api::Helpers::AccessRights
19
20
  include Api::Helpers::Status
20
21
 
21
22
  #
@@ -535,6 +536,134 @@ module GroupDocs
535
536
  end
536
537
  end
537
538
 
539
+ #
540
+ # Returns document annotations collaborators.
541
+ #
542
+ # @param [Hash] access Access credentials
543
+ # @option access [String] :client_id
544
+ # @option access [String] :private_key
545
+ # @return [Array<GroupDocs::User>]
546
+ #
547
+ def collaborators!(access = {})
548
+ json = Api::Request.new do |request|
549
+ request[:access] = access
550
+ request[:method] = :GET
551
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
552
+ end.execute!
553
+
554
+ json[:collaborators].map do |collaborator|
555
+ User.new(collaborator)
556
+ end
557
+ end
558
+
559
+ #
560
+ # Sets document annotations collaborators to given emails.
561
+ #
562
+ # @param [Array<String>] emails List of collaborators' email addresses
563
+ # @param [Integer] version Annotation version
564
+ # @param [Hash] access Access credentials
565
+ # @option access [String] :client_id
566
+ # @option access [String] :private_key
567
+ # @return [Array<GroupDocs::User>]
568
+ #
569
+ def set_collaborators!(emails, version = 1, access = {})
570
+ json = Api::Request.new do |request|
571
+ request[:access] = access
572
+ request[:method] = :PUT
573
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/version/#{version}/collaborators"
574
+ request[:request_body] = emails
575
+ end.execute!
576
+
577
+ json[:collaborators].map do |collaborator|
578
+ User.new(collaborator)
579
+ end
580
+ end
581
+
582
+ #
583
+ # Adds document annotations collaborator.
584
+ #
585
+ # @param [GroupDocs::User] collaborator
586
+ # @param [Hash] access Access credentials
587
+ # @option access [String] :client_id
588
+ # @option access [String] :private_key
589
+ #
590
+ def add_collaborator!(collaborator, access = {})
591
+ collaborator.is_a?(GroupDocs::User) or raise ArgumentError,
592
+ "Collaborator should be GroupDocs::User object, received: #{collaborator.inspect}"
593
+
594
+ Api::Request.new do |request|
595
+ request[:access] = access
596
+ request[:method] = :POST
597
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators"
598
+ request[:request_body] = collaborator.to_hash
599
+ end.execute!
600
+ end
601
+
602
+ #
603
+ # Sets reviewers for document.
604
+ #
605
+ # @example Change reviewer rights
606
+ # reviewers = document.collaborators!
607
+ # reviewers.each do |reviewer|
608
+ # reviewer.access_rights = %w(view)
609
+ # end
610
+ # document.set_reviewers! reviewers
611
+ #
612
+ # @param [Array<GroupDocs::User>] reviewers
613
+ # @param [Hash] access Access credentials
614
+ # @option access [String] :client_id
615
+ # @option access [String] :private_key
616
+ # @return [Array<Symbol>]
617
+ #
618
+ def set_reviewers!(reviewers, access = {})
619
+ Api::Request.new do |request|
620
+ request[:access] = access
621
+ request[:method] = :PUT
622
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/reviewerRights"
623
+ request[:request_body] = reviewers.map(&:to_hash)
624
+ end.execute!
625
+ end
626
+
627
+ #
628
+ # Returns an array of access rights for shared link.
629
+ #
630
+ # @param [Hash] access Access credentials
631
+ # @option access [String] :client_id
632
+ # @option access [String] :private_key
633
+ # @return [Array<Symbol>]
634
+ #
635
+ def shared_link_access_rights!(access = {})
636
+ json = Api::Request.new do |request|
637
+ request[:access] = access
638
+ request[:method] = :GET
639
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
640
+ end.execute!
641
+
642
+ if json[:accessRights]
643
+ convert_byte_to_access_rights json[:accessRights]
644
+ else
645
+ []
646
+ end
647
+ end
648
+
649
+ #
650
+ # Sets access rights for shared link.
651
+ #
652
+ # @param [Array<Symbol>] rights
653
+ # @param [Hash] access Access credentials
654
+ # @option access [String] :client_id
655
+ # @option access [String] :private_key
656
+ # @return [Array<Symbol>]
657
+ #
658
+ def set_shared_link_access_rights!(rights, access = {})
659
+ json = Api::Request.new do |request|
660
+ request[:access] = access
661
+ request[:method] = :PUT
662
+ request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights"
663
+ request[:request_body] = convert_access_rights_to_byte(rights)
664
+ end.execute!
665
+ end
666
+
538
667
  #
539
668
  # Pass all unknown methods to file.
540
669
  #
File without changes
data/lib/groupdocs/job.rb CHANGED
@@ -1,7 +1,21 @@
1
1
  module GroupDocs
2
2
  class Job < Api::Entity
3
3
 
4
- extend Api::Helpers::Actions
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
+ }
17
+
18
+ extend Api::Helpers::ByteFlag
5
19
  include Api::Helpers::Status
6
20
 
7
21
  #
@@ -280,5 +294,43 @@ module GroupDocs
280
294
  end.execute!
281
295
  end
282
296
 
297
+ #
298
+ # Deletes draft job.
299
+ #
300
+ # @param [Hash] access Access credentials
301
+ # @option access [String] :client_id
302
+ # @option access [String] :private_key
303
+ #
304
+ def delete!(access = {})
305
+ Api::Request.new do |request|
306
+ request[:access] = access
307
+ request[:method] = :DELETE
308
+ request[:path] = "/async/{{client_id}}/jobs/#{id}"
309
+ end.execute!
310
+ end
311
+
312
+ private
313
+
314
+ #
315
+ # Converts actions array to byte flag.
316
+ #
317
+ # @param [Array<String, Symbol>] actions
318
+ # @return [Integer]
319
+ # @raise [ArgumentError] if actions is not an array
320
+ # @raise [ArgumentError] if action is unknown
321
+ # @api private
322
+ #
323
+ def self.convert_actions_to_byte(actions)
324
+ actions.is_a?(Array) or raise ArgumentError, "Actions should be an array, received: #{actions.inspect}"
325
+ actions = actions.map(&:to_sym)
326
+
327
+ possible_actions = ACTIONS.map { |hash| hash.first }
328
+ actions.each do |action|
329
+ possible_actions.include?(action) or raise ArgumentError, "Unknown action: #{action.inspect}"
330
+ end
331
+
332
+ byte_from_array(actions, ACTIONS)
333
+ end
334
+
283
335
  end # Job
284
336
  end # GroupDocs
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes