groupdocs 1.1.0 → 1.2.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 (130) hide show
  1. data/CHANGELOG.md +41 -0
  2. data/examples/README.md +2 -3
  3. data/examples/api-samples/Gemfile +5 -0
  4. data/examples/api-samples/Gemfile.lock +27 -0
  5. data/examples/api-samples/README.md +12 -0
  6. data/examples/api-samples/app.rb +17 -0
  7. data/examples/api-samples/public/css/style.css +166 -0
  8. data/examples/api-samples/samples/sample1.rb +17 -0
  9. data/examples/api-samples/samples/sample10.rb +36 -0
  10. data/examples/api-samples/samples/sample2.rb +19 -0
  11. data/examples/api-samples/samples/sample3.rb +23 -0
  12. data/examples/api-samples/samples/sample4.rb +31 -0
  13. data/examples/api-samples/samples/sample5.rb +44 -0
  14. data/examples/api-samples/samples/sample6.rb +3 -0
  15. data/examples/api-samples/samples/sample7.rb +33 -0
  16. data/examples/api-samples/samples/sample8.rb +40 -0
  17. data/examples/api-samples/samples/sample9.rb +22 -0
  18. data/examples/api-samples/views/index.haml +23 -0
  19. data/examples/api-samples/views/layout.haml +7 -0
  20. data/examples/api-samples/views/sample1.haml +71 -0
  21. data/examples/api-samples/views/sample10.haml +69 -0
  22. data/examples/api-samples/views/sample2.haml +59 -0
  23. data/examples/api-samples/views/sample3.haml +62 -0
  24. data/examples/api-samples/views/sample4.haml +58 -0
  25. data/examples/api-samples/views/sample5.haml +62 -0
  26. data/examples/api-samples/views/sample6.haml +145 -0
  27. data/examples/api-samples/views/sample7.haml +59 -0
  28. data/examples/api-samples/views/sample8.haml +75 -0
  29. data/examples/api-samples/views/sample9.haml +61 -0
  30. data/examples/{annotations → viewer}/Gemfile +0 -0
  31. data/examples/viewer/app.rb +52 -0
  32. data/groupdocs.gemspec +5 -4
  33. data/lib/groupdocs/api.rb +1 -0
  34. data/lib/groupdocs/api/entity.rb +2 -0
  35. data/lib/groupdocs/api/helpers.rb +2 -0
  36. data/lib/groupdocs/api/helpers/accessor_helper.rb +30 -0
  37. data/lib/groupdocs/api/helpers/mime_helper.rb +21 -0
  38. data/lib/groupdocs/api/helpers/rest_helper.rb +3 -2
  39. data/lib/groupdocs/api/request.rb +1 -3
  40. data/lib/groupdocs/datasource.rb +1 -2
  41. data/lib/groupdocs/document.rb +133 -3
  42. data/lib/groupdocs/document/annotation.rb +14 -13
  43. data/lib/groupdocs/document/annotation/reply.rb +4 -8
  44. data/lib/groupdocs/document/annotation/reviewer.rb +2 -4
  45. data/lib/groupdocs/document/field.rb +10 -8
  46. data/lib/groupdocs/document/rectangle.rb +10 -18
  47. data/lib/groupdocs/job.rb +1 -1
  48. data/lib/groupdocs/questionnaire.rb +138 -44
  49. data/lib/groupdocs/questionnaire/collector.rb +262 -0
  50. data/lib/groupdocs/questionnaire/execution.rb +93 -10
  51. data/lib/groupdocs/questionnaire/question.rb +1 -2
  52. data/lib/groupdocs/signature.rb +16 -24
  53. data/lib/groupdocs/signature/contact.rb +2 -4
  54. data/lib/groupdocs/signature/envelope.rb +3 -6
  55. data/lib/groupdocs/signature/envelope/log.rb +2 -4
  56. data/lib/groupdocs/signature/field.rb +21 -42
  57. data/lib/groupdocs/signature/field/location.rb +18 -36
  58. data/lib/groupdocs/signature/form.rb +9 -18
  59. data/lib/groupdocs/signature/list.rb +1 -2
  60. data/lib/groupdocs/signature/recipient.rb +3 -6
  61. data/lib/groupdocs/signature/role.rb +4 -8
  62. data/lib/groupdocs/signature/shared/entity_fields.rb +12 -20
  63. data/lib/groupdocs/signature/template.rb +1 -2
  64. data/lib/groupdocs/storage/file.rb +3 -1
  65. data/lib/groupdocs/storage/folder.rb +7 -1
  66. data/lib/groupdocs/subscription.rb +6 -12
  67. data/lib/groupdocs/subscription/limit.rb +4 -8
  68. data/lib/groupdocs/user.rb +3 -6
  69. data/lib/groupdocs/version.rb +1 -1
  70. data/spec/groupdocs/api/helpers/accessor_helper_spec.rb +16 -0
  71. data/spec/groupdocs/api/helpers/mime_helper_spec.rb +16 -0
  72. data/spec/groupdocs/api/helpers/rest_helper_spec.rb +4 -0
  73. data/spec/groupdocs/api/request_spec.rb +3 -5
  74. data/spec/groupdocs/datasource/field_spec.rb +3 -6
  75. data/spec/groupdocs/datasource_spec.rb +8 -15
  76. data/spec/groupdocs/document/annotation/reply_spec.rb +13 -24
  77. data/spec/groupdocs/document/annotation/reviewer_spec.rb +5 -9
  78. data/spec/groupdocs/document/annotation_spec.rb +35 -40
  79. data/spec/groupdocs/document/change_spec.rb +6 -11
  80. data/spec/groupdocs/document/field_spec.rb +13 -13
  81. data/spec/groupdocs/document/metadata_spec.rb +5 -10
  82. data/spec/groupdocs/document/rectangle_spec.rb +6 -18
  83. data/spec/groupdocs/document/view_spec.rb +3 -6
  84. data/spec/groupdocs/document_spec.rb +123 -10
  85. data/spec/groupdocs/job_spec.rb +9 -18
  86. data/spec/groupdocs/questionnaire/collector_spec.rb +201 -0
  87. data/spec/groupdocs/questionnaire/execution_spec.rb +91 -23
  88. data/spec/groupdocs/questionnaire/page_spec.rb +3 -6
  89. data/spec/groupdocs/questionnaire/question/answer_spec.rb +2 -4
  90. data/spec/groupdocs/questionnaire/question_spec.rb +7 -14
  91. data/spec/groupdocs/questionnaire_spec.rb +117 -41
  92. data/spec/groupdocs/signature/contact_spec.rb +9 -17
  93. data/spec/groupdocs/signature/envelope/log_spec.rb +8 -16
  94. data/spec/groupdocs/signature/envelope_spec.rb +9 -17
  95. data/spec/groupdocs/signature/field/location_spec.rb +32 -65
  96. data/spec/groupdocs/signature/field_spec.rb +48 -95
  97. data/spec/groupdocs/signature/form_spec.rb +22 -43
  98. data/spec/groupdocs/signature/list_spec.rb +6 -11
  99. data/spec/groupdocs/signature/recipient_spec.rb +11 -22
  100. data/spec/groupdocs/signature/role_spec.rb +11 -21
  101. data/spec/groupdocs/signature/template_spec.rb +2 -4
  102. data/spec/groupdocs/signature_spec.rb +28 -54
  103. data/spec/groupdocs/storage/file_spec.rb +14 -26
  104. data/spec/groupdocs/storage/folder_spec.rb +16 -22
  105. data/spec/groupdocs/storage/package_spec.rb +2 -4
  106. data/spec/groupdocs/subscription/limit_spec.rb +8 -16
  107. data/spec/groupdocs/subscription_spec.rb +11 -22
  108. data/spec/groupdocs/user_spec.rb +21 -41
  109. data/spec/groupdocs_spec.rb +4 -8
  110. data/spec/spec_helper.rb +12 -0
  111. data/spec/support/files/signature.png +0 -0
  112. data/spec/support/json/annotation_list.json +6 -6
  113. data/spec/support/json/comparison_changes.json +8 -8
  114. data/spec/support/json/document_fields.json +8 -8
  115. data/spec/support/json/document_page_images_get.json +20 -0
  116. data/spec/support/json/questionnaire_collector.json +17 -0
  117. data/spec/support/json/questionnaire_collectors.json +38 -0
  118. data/spec/support/json/questionnaire_collectors_add.json +10 -0
  119. data/spec/support/json/questionnaire_create.json +3 -1
  120. data/spec/support/json/{questionnaire_execution_create.json → questionnaire_execution_add.json} +1 -1
  121. data/spec/support/json/questionnaire_get.json +3 -0
  122. data/spec/support/json/questionnaires_get.json +36 -18
  123. data/spec/support/json/sign_documents.json +16 -0
  124. data/spec/support/json/templates_get.json +21 -0
  125. data/spec/support/shared_examples/api/entity.rb +2 -0
  126. data/spec/support/shared_examples/api/helpers/access_mode_helper.rb +1 -2
  127. data/spec/support/shared_examples/api/helpers/status_helper.rb +1 -2
  128. data/spec/support/shared_examples/signature/shared/entity_fields.rb +22 -43
  129. metadata +82 -16
  130. data/examples/annotations/app.rb +0 -67
data/groupdocs.gemspec CHANGED
@@ -17,11 +17,12 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_runtime_dependency 'rest-client', '~> 1.6'
19
19
  s.add_runtime_dependency 'json' , '~> 1.7'
20
+ s.add_runtime_dependency 'mime-types' , '~> 1.19'
20
21
 
21
- s.add_development_dependency 'rspec' , '~> 2.11'
22
+ s.add_development_dependency 'rspec' , '~> 2.12'
22
23
  s.add_development_dependency 'fuubar' , '~> 1.1'
23
- s.add_development_dependency 'rake' , '~> 0.9'
24
- s.add_development_dependency 'simplecov', '~> 0.6'
24
+ s.add_development_dependency 'rake' , '~> 10.0'
25
+ s.add_development_dependency 'simplecov', '~> 0.7'
25
26
  s.add_development_dependency 'yard' , '~> 0.8'
26
- s.add_development_dependency 'webmock' , '~> 1.8'
27
+ s.add_development_dependency 'webmock' , '~> 1.9'
27
28
  end
data/lib/groupdocs/api.rb CHANGED
@@ -1,2 +1,3 @@
1
+ require 'groupdocs/api/helpers'
1
2
  require 'groupdocs/api/entity'
2
3
  require 'groupdocs/api/request'
@@ -2,6 +2,8 @@ module GroupDocs
2
2
  module Api
3
3
  class Entity
4
4
 
5
+ extend Api::Helpers::Accessor
6
+
5
7
  #
6
8
  # Implements flexible API object creation.
7
9
  #
@@ -1,7 +1,9 @@
1
1
  require 'groupdocs/api/helpers/byte_flag_helper'
2
2
  require 'groupdocs/api/helpers/access_mode_helper'
3
3
  require 'groupdocs/api/helpers/access_rights_helper'
4
+ require 'groupdocs/api/helpers/accessor_helper'
4
5
  require 'groupdocs/api/helpers/credentials_helper'
6
+ require 'groupdocs/api/helpers/mime_helper'
5
7
  require 'groupdocs/api/helpers/path_helper'
6
8
  require 'groupdocs/api/helpers/rest_helper'
7
9
  require 'groupdocs/api/helpers/status_helper'
@@ -0,0 +1,30 @@
1
+ module GroupDocs
2
+ module Api
3
+ module Helpers
4
+ module Accessor
5
+
6
+ #
7
+ # Allows to easily alias accessors.
8
+ #
9
+ # @example
10
+ # class File < Api::Entity
11
+ # attr_accessor :fileName
12
+ # alias_accessor :file_name, :fileName
13
+ # end
14
+ # file = File.new
15
+ # file.file_name = "document"
16
+ # file.file_name
17
+ # #=> "document"
18
+ #
19
+ # @param [Symbol] new_name
20
+ # @param [Symbol] old_name
21
+ #
22
+ def alias_accessor(new_name, old_name)
23
+ alias_method :"#{new_name}", :"#{old_name}"
24
+ alias_method :"#{new_name}=", :"#{old_name}="
25
+ end
26
+
27
+ end # Accessor
28
+ end # Helpers
29
+ end # Api
30
+ end # GroupDocs
@@ -0,0 +1,21 @@
1
+ require 'mime/types'
2
+
3
+ module GroupDocs
4
+ module Api
5
+ module Helpers
6
+ module MIME
7
+
8
+ private
9
+
10
+ #
11
+ # Returns MIME type for file.
12
+ # @api private
13
+ #
14
+ def mime_type(filepath)
15
+ ::MIME::Types.type_for(filepath).first
16
+ end
17
+
18
+ end # MIME
19
+ end # Helpers
20
+ end # Api
21
+ end # GroupDocs
@@ -7,8 +7,9 @@ module GroupDocs
7
7
  module REST
8
8
 
9
9
  DEFAULT_HEADERS = {
10
- accept: 'application/json',
11
- content_length: 0
10
+ accept: 'application/json',
11
+ content_length: 0,
12
+ groupdocs_referrer: "ruby/#{VERSION}"
12
13
  }
13
14
 
14
15
  private
@@ -1,5 +1,3 @@
1
- require 'groupdocs/api/helpers'
2
-
3
1
  module GroupDocs
4
2
  module Api
5
3
  class Request
@@ -9,7 +7,7 @@ module GroupDocs
9
7
  include Api::Helpers::REST
10
8
 
11
9
  # @attr_reader [RestClient::Resource] resource Entry point for all API requests
12
- attr_reader :resource
10
+ attr_reader :resource
13
11
  # @attr [String] response Response from server in JSON format
14
12
  attr_accessor :response
15
13
  # @attr [Hash] options Hash of options
@@ -42,8 +42,7 @@ module GroupDocs
42
42
  attr_accessor :fields
43
43
 
44
44
  # Human-readable accessors
45
- alias_method :description, :descr
46
- alias_method :description=, :descr=
45
+ alias_accessor :description, :descr
47
46
 
48
47
  #
49
48
  # Converts timestamp which is return by API server to Time object.
@@ -18,6 +18,7 @@ module GroupDocs
18
18
  include Api::Helpers::AccessMode
19
19
  include Api::Helpers::AccessRights
20
20
  include Api::Helpers::Status
21
+ extend Api::Helpers::MIME
21
22
 
22
23
  #
23
24
  # Returns an array of views for all documents.
@@ -34,7 +35,7 @@ module GroupDocs
34
35
  api = Api::Request.new do |request|
35
36
  request[:access] = access
36
37
  request[:method] = :GET
37
- request[:path] = "/doc/{{client_id}}/views"
38
+ request[:path] = '/doc/{{client_id}}/views'
38
39
  end
39
40
  api.add_params(options)
40
41
  json = api.execute!
@@ -44,6 +45,101 @@ module GroupDocs
44
45
  end
45
46
  end
46
47
 
48
+ #
49
+ # Returns an array of all templates (documents in "Templates" directory).
50
+ #
51
+ # @param [Hash] access Access credentials
52
+ # @option access [String] :client_id
53
+ # @option access [String] :private_key
54
+ # @return [Array<GroupDocs::Document>]
55
+ #
56
+ def self.templates!(options = {}, access = {})
57
+ json = Api::Request.new do |request|
58
+ request[:access] = access
59
+ request[:method] = :GET
60
+ request[:path] = '/merge/{{client_id}}/templates'
61
+ end.execute!
62
+
63
+ json[:templates].map do |template|
64
+ template.merge!(file: Storage::File.new(template))
65
+ Document.new(template)
66
+ end
67
+ end
68
+
69
+ #
70
+ # Signs given documents with signatures.
71
+ #
72
+ # @example
73
+ # # prepare documents
74
+ # file_one = GroupDocs::Storage::File.new(name: 'document_one.doc', local_path: '~/Documents/document_one.doc')
75
+ # file_two = GroupDocs::Storage::File.new(name: 'document_one.pdf', local_path: '~/Documents/document_one.pdf')
76
+ # document_one = file_one.to_document
77
+ # document_two = file_two.to_document
78
+ # # prepare signatures
79
+ # signature_one = GroupDocs::Signature.new(name: 'John Smith', image_path: '~/Documents/signature_one.png')
80
+ # signature_two = GroupDocs::Signature.new(name: 'Sara Smith', image_path: '~/Documents/signature_two.png')
81
+ # signature_one.position = { top: 0.1, left: 0.07, width: 50, height: 50 }
82
+ # signature_two.position = { top: 0.2, left: 0.2, width: 100, height: 100 }
83
+ # # sign documents and download results
84
+ # signed_documents = GroupDocs::Document.sign_documents!([document_one, document_two], [signature_one, signature_two])
85
+ # signed_documents.each do |document|
86
+ # document.file.download! '~/Documents'
87
+ # end
88
+ #
89
+ # @param [Array<GroupDocs::Document>] documents Each document file should have "#name" and "#local_path"
90
+ # @param [Array<GroupDocs::Signature>] signatures Each signature should have "#name", "#image_path" and "#position"
91
+ #
92
+ def self.sign_documents!(documents, signatures, options = {}, access = {})
93
+ documents.each do |document|
94
+ document.is_a?(Document) or raise ArgumentError, "Each document should be GroupDocs::Document object, received: #{document.inspect}"
95
+ document.file.name or raise ArgumentError, "Each document file should have name, received: #{document.file.name.inspect}"
96
+ document.file.local_path or raise ArgumentError, "Each document file should have local_path, received: #{document.file.local_path.inspect}"
97
+ end
98
+ signatures.each do |signature|
99
+ signature.is_a?(Signature) or raise ArgumentError, "Each signature should be GroupDocs::Signature object, received: #{signature.inspect}"
100
+ signature.name or raise ArgumentError, "Each signature should have name, received: #{signature.name.inspect}"
101
+ signature.image_path or raise ArgumentError, "Each signature should have image_path, received: #{signature.image_path.inspect}"
102
+ signature.position or raise ArgumentError, "Each signature should have position, received: #{signature.position.inspect}"
103
+ end
104
+
105
+ documents_to_sign = []
106
+ documents.map(&:file).each do |file|
107
+ document = { name: file.name }
108
+ contents = File.read(file.local_path)
109
+ contents = Base64.strict_encode64(contents)
110
+ document.merge!(data: "data:#{mime_type(file.local_path)};base64,#{contents}")
111
+
112
+ documents_to_sign << document
113
+ end
114
+
115
+ signers = []
116
+ signatures.each do |signature|
117
+ contents = File.read(signature.image_path)
118
+ contents = Base64.strict_encode64(contents)
119
+ signer = { name: signature.name, data: "data:#{mime_type(signature.image_path)};base64,#{contents}" }
120
+ signer.merge!(signature.position)
121
+ # place signature on is not implemented yet
122
+ signer.merge!(placeSignatureOn: nil)
123
+
124
+ signers << signer
125
+ end
126
+
127
+ json = Api::Request.new do |request|
128
+ request[:access] = access
129
+ request[:method] = :POST
130
+ request[:path] = '/signature/{{client_id}}/sign'
131
+ request[:request_body] = { documents: documents_to_sign, signers: signers }
132
+ end.execute!
133
+
134
+ signed_documents = []
135
+ json[:documents].each_with_index do |document, i|
136
+ file = Storage::File.new(guid: document[:documentId], name: "#{documents[i].file.name}_signed.pdf")
137
+ signed_documents << Document.new(file: file)
138
+ end
139
+
140
+ signed_documents
141
+ end
142
+
47
143
  # @attr [GroupDocs::Storage::File] file
48
144
  attr_accessor :file
49
145
  # @attr [Time] process_date
@@ -54,8 +150,10 @@ module GroupDocs
54
150
  attr_accessor :output_formats
55
151
  # @attr [Symbol] status
56
152
  attr_accessor :status
57
- # @attr [Integet] order
153
+ # @attr [Integer] order
58
154
  attr_accessor :order
155
+ # @attr [Integer] field_count
156
+ attr_accessor :field_count
59
157
 
60
158
  #
61
159
  # Coverts passed array of attributes hash to array of GroupDocs::Storage::File.
@@ -114,6 +212,39 @@ module GroupDocs
114
212
  "You have to pass GroupDocs::Storage::File object: #{file.inspect}."
115
213
  end
116
214
 
215
+ #
216
+ # Returns array of URLs to images representing document pages.
217
+ #
218
+ # @example
219
+ # file = GroupDocs::Storage::Folder.list!.last
220
+ # document = file.to_document
221
+ # document.page_images! 1024, 768, first_page: 0, page_count: 1
222
+ #
223
+ # @param [Integer] width Image width
224
+ # @param [Integer] height Image height
225
+ # @param [Hash] options
226
+ # @option options [Integer] :first_page Start page to return image for (starting with 0)
227
+ # @option options [Integer] :page_count Number of pages to return image for
228
+ # @option options [Integer] :quality
229
+ # @option options [Boolean] :use_pdf
230
+ # @option options [Boolean] :token
231
+ # @param [Hash] access Access credentials
232
+ # @option access [String] :client_id
233
+ # @option access [String] :private_key
234
+ # @return [Array<String>]
235
+ #
236
+ def page_images!(width, height, options = {}, access = {})
237
+ api = Api::Request.new do |request|
238
+ request[:access] = access
239
+ request[:method] = :GET
240
+ request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/images/#{width}x#{height}/urls"
241
+ end
242
+ api.add_params(options)
243
+ json = api.execute!
244
+
245
+ json[:url]
246
+ end
247
+
117
248
  #
118
249
  # Returns access mode of document.
119
250
  #
@@ -613,7 +744,6 @@ module GroupDocs
613
744
  # @param [Hash] access Access credentials
614
745
  # @option access [String] :client_id
615
746
  # @option access [String] :private_key
616
- # @return [Array<Symbol>]
617
747
  #
618
748
  def set_reviewers!(reviewers, access = {})
619
749
  Api::Request.new do |request|
@@ -39,19 +39,13 @@ module GroupDocs
39
39
  alias_method :annotationGuid=, :guid=
40
40
 
41
41
  # Human-readable accessors
42
- alias_method :session_guid, :sessionGuid
43
- alias_method :session_guid=, :sessionGuid=
44
- alias_method :document_guid, :documentGuid
45
- alias_method :document_guid=, :documentGuid=
46
- alias_method :creator_guid, :creatorGuid
47
- alias_method :creator_guid=, :creatorGuid=
48
- alias_method :reply_guid, :replyGuid
49
- alias_method :reply_guid=, :replyGuid=
50
- alias_method :created_on, :createdOn
51
- alias_method :created_on=, :createdOn=
52
- alias_method :annotation_position, :annotationPosition
53
- alias_method :annotation_position=, :annotationPosition=
54
- alias_method :position, :annotation_position
42
+ alias_accessor :session_guid, :sessionGuid
43
+ alias_accessor :document_guid, :documentGuid
44
+ alias_accessor :creator_guid, :creatorGuid
45
+ alias_accessor :reply_guid, :replyGuid
46
+ alias_accessor :created_on, :createdOn
47
+ alias_accessor :annotation_position, :annotationPosition
48
+ alias_accessor :position, :annotationPosition
55
49
 
56
50
  #
57
51
  # Creates new GroupDocs::Document::Annotation.
@@ -249,6 +243,13 @@ module GroupDocs
249
243
  request[:path] = "/ant/{{client_id}}/annotations/#{guid}/markerPosition"
250
244
  request[:request_body] = { x: x, y: y }
251
245
  end.execute!
246
+
247
+ if box
248
+ box.x = x
249
+ box.y = y
250
+ else
251
+ self.box = { x: x, y: y }
252
+ end
252
253
  end
253
254
 
254
255
  #
@@ -55,14 +55,10 @@ module GroupDocs
55
55
  attr_accessor :repliedOn
56
56
 
57
57
  # Human-readable accessors
58
- alias_method :annotation_guid, :annotationGuid
59
- alias_method :annotation_guid=, :annotationGuid=
60
- alias_method :user_guid, :userGuid
61
- alias_method :user_guid=, :userGuid=
62
- alias_method :user_name, :userName
63
- alias_method :user_name=, :userName=
64
- alias_method :replied_on, :repliedOn
65
- alias_method :replied_on=, :repliedOn=
58
+ alias_accessor :annotation_guid, :annotationGuid
59
+ alias_accessor :user_guid, :userGuid
60
+ alias_accessor :user_name, :userName
61
+ alias_accessor :replied_on, :repliedOn
66
62
 
67
63
  #
68
64
  # Creates new GroupDocs::Document::Annotation.
@@ -51,10 +51,8 @@ module GroupDocs
51
51
  attr_accessor :FullName
52
52
 
53
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=
54
+ alias_accessor :email_address, :emailAddress
55
+ alias_accessor :full_name, :FullName
58
56
 
59
57
  end # Document::Annotation::Reviewer
60
58
  end # GroupDocs
@@ -7,21 +7,23 @@ module GroupDocs
7
7
  attr_accessor :name
8
8
  # @attr [String] type
9
9
  attr_accessor :type
10
- # @attr [GroupDocs::Document::Rectangle] rectangle
11
- attr_accessor :rectangle
10
+ # @attr [GroupDocs::Document::Rectangle] rect
11
+ attr_accessor :rect
12
12
 
13
13
  #
14
14
  # Coverts passed hash to GroupDocs::Document::Rectangle object.
15
- #
16
15
  # @param [Hash] options
17
- # @return [GroupDocs::Document::Rectangle]
18
16
  #
19
- def rectangle=(options)
20
- @rectangle = GroupDocs::Document::Rectangle.new(options)
17
+ def rect=(rectangle)
18
+ if rectangle.is_a?(Hash)
19
+ rectangle = GroupDocs::Document::Rectangle.new(rectangle)
20
+ end
21
+
22
+ @rect = rectangle
21
23
  end
22
24
 
23
- # Compatibility with response JSON
24
- alias_method :rect=, :rectangle=
25
+ # Human-readable accessors
26
+ alias_accessor :rectangle, :rect
25
27
 
26
28
  end # Document::Field
27
29
  end # GroupDocs
@@ -1,26 +1,18 @@
1
1
  module GroupDocs
2
2
  class Document::Rectangle < Api::Entity
3
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
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
12
 
13
13
  # Human-readable accessors
14
- alias_method :x, :X
15
- alias_method :x=, :X=
16
- alias_method :y, :Y
17
- alias_method :y=, :Y=
18
- alias_method :w, :Width
19
- alias_method :w=, :Width=
20
- alias_method :width, :w
21
- alias_method :h, :Height
22
- alias_method :h=, :Height=
23
- alias_method :height, :Height
14
+ alias_accessor :w, :width
15
+ alias_accessor :h, :height
24
16
 
25
17
  end # Document::Rectangle
26
18
  end # GroupDocs