Class: GroupDocs::Document
- Inherits:
-
Api::Entity
- Object
- Api::Entity
- GroupDocs::Document
- Extended by:
- Api::Helpers::MIME
- Defined in:
- lib/groupdocs/document.rb
Defined Under Namespace
Classes: Annotation, Change, Field, MetaData, Rectangle, View
Constant Summary collapse
- ACCESS_MODES =
{ :private => 0, :restricted => 1, :public => 2, :inherited => 254, :denied => 255, }
Constants included from Api::Helpers::AccessRights
Api::Helpers::AccessRights::ACCESS_RIGHTS
Instance Attribute Summary collapse
- #field_count ⇒ Object
- #file ⇒ Object
- #order ⇒ Object
-
#output_formats ⇒ Array<Symbol>
Returns output formats in human-readable format.
- #outputs ⇒ Object
-
#process_date ⇒ Time
Converts timestamp which is return by API server to Time object.
-
#status ⇒ Symbol
Converts status to human-readable format.
Class Method Summary collapse
-
.metadata!(path, access = {}) ⇒ Array<GroupDocs::Document::View>
Returns a document metadata by given path.
-
.public_fields!(access = {}) ⇒ Array
Changed in release 1.5.8.
-
.sign_documents!(documents, signatures, options = {}, access = {}) ⇒ Object
Signs given documents with signatures.
-
.templates!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns an array of all templates (documents in “Templates” directory).
-
.views!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::View>
Returns an array of views for all documents.
Instance Method Summary collapse
-
#access_mode!(access = {}) ⇒ Symbol
Returns access mode of document.
-
#access_mode_set!(mode, access = {}) ⇒ Symbol
(also: #access_mode=)
Sets access mode of document.
-
#add_collaborator!(collaborator, access = {}) ⇒ Object
Adds document annotations collaborator.
-
#add_questionnaire!(questionnaire, access = {}) ⇒ Object
Adds questionnaire to document.
-
#annotations!(access = {}) ⇒ Array<GroupDocs::Document::Annotation>
Returns an array of annotations.
-
#changes!(access = {}) ⇒ Object
Returns an array of changes in document.
-
#collaborators!(access = {}) ⇒ Array<GroupDocs::User>
Returns document annotations collaborators.
-
#compare!(document, callback, access = {}) ⇒ GroupDocs::Job
Changed in release 1.5.8 Schedules a job for comparing document with given.
-
#content!(content_type, access = {}) ⇒ String
Returns document content.
-
#convert!(format, options = {}, access = {}) ⇒ GroupDocs::Job
Converts document to given format.
-
#create_questionnaire!(questionnaire, access = {}) ⇒ GroupDocs::Questionnaire
Creates questionnaire and adds it to document.
-
#datasource!(datasource, options = {}, access = {}) ⇒ GroupDocs::Job
Creates new job to merge datasource into document.
-
#datasource_fields!(datasource, options = {}, access = {}) ⇒ GroupDocs::Job
Creates new job to merge datasource fields into document.
-
#details!(access = {}) ⇒ Hash
Changed in release 1.5.8 Returns document details.
-
#document_status!(job_guid, access = {}) ⇒ Object
Get sign documents status.
-
#download!(path, options = {}, access = {}) ⇒ Object
Changed in realese 1.5.8 Download comparison result file.
-
#editlock!(access = {}) ⇒ Object
Returns editing metadata.
-
#editlock_clear!(options = {}, access = {}) ⇒ Integer
Removes edit lock for a document and replaces the document with its edited copy.
-
#fields!(access = {}) ⇒ Array<GroupDocs::Document::Field>
Returns an array of document fields.
-
#formats!(access = {}) ⇒ Array<Symbol>
Returns array of file formats document can be converted to.
-
#hyperlinks!(access = {}) ⇒ Object
added in release 1.5.8.
-
#initialize(options = {}, &blk) ⇒ Document
constructor
Creates new GroupDocs::Document.
-
#metadata!(access = {}) ⇒ GroupDocs::Document::MetaData
Returns document metadata.
- #method_missing(method, *args, &blk) ⇒ Object
-
#page_fixed_html!(path, name, page_number, options = {}, access = {}) ⇒ Object
Returns an HTML Fixed representation of a particular document page.
-
#page_html!(path, name, page_number, options = {}, access = {}) ⇒ Object
Returns an HTML representation of a particular document page.
-
#page_html_urls!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to html representing document pages.
-
#page_image!(path, name, page_number, dimension, options = {}, access = {}) ⇒ Object
Returns a stream of bytes representing a particular document page image.
-
#page_images!(width, height, options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages.
-
#password_set!(password, access = {}) ⇒ Array<GroupDocs::User>
Sets document password.
-
#public_sign_document!(options = {}, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#questionnaires!(access = {}) ⇒ Array<GroupDocs::Questionnaire>
Returns an array of questionnaires.
-
#remove_collaborators!(reviewerId, access = {}) ⇒ Object
Delete document reviewer.
-
#remove_questionnaire!(questionnaire, access = {}) ⇒ Object
Detaches questionnaire from document.
-
#representations!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages htmlRepresentations.
- #respond_to?(method) ⇒ Boolean
-
#set_collaborators!(emails, version = 1, access = {}) ⇒ Array<GroupDocs::User>
Sets document annotations collaborators to given emails.
-
#set_reviewers!(reviewers, access = {}) ⇒ Object
Sets reviewers for document.
-
#set_session_callback!(url, access = {}) ⇒ Object
Sets session callback URL.
-
#set_shared_link_access_rights!(rights, access = {}) ⇒ Array<Symbol>
Sets access rights for shared link.
-
#shared_documents!(sharers_types, options = {}, access = {}) ⇒ Array<GroupDocs::User>
Returns an array of users a document is shared with.
-
#shared_link_access_rights!(access = {}) ⇒ Array<Symbol>
Returns an array of access rights for shared link.
-
#sharers!(access = {}) ⇒ Array<GroupDocs::User>
Returns an array of users a document is shared with.
-
#sharers_clear!(access = {}) ⇒ Object
Clears sharers list.
-
#sharers_set!(emails, access = {}) ⇒ Array<GroupDocs::User>
Sets document sharers to given emails.
-
#tags!(access = {}) ⇒ Array<String>
Returns tags assigned to the document.
-
#tags_clear!(access = {}) ⇒ String
Removes tags assigned to the document.
-
#tags_set!(access = {}) ⇒ String
Assign tags to the document.
-
#thumbnails!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages thumbnails.
-
#update_changes!(changes, access = {}) ⇒ GroupDocs::Change
Schedules a job for comparing document with given.
-
#user_status_set!(status, access = {}) ⇒ String
Sets document user status.
Methods included from Api::Helpers::ByteFlag
#array_from_byte, #byte_from_array
Methods inherited from Api::Entity
Methods included from Api::Helpers::Accessor
Constructor Details
#initialize(options = {}, &blk) ⇒ Document
Creates new GroupDocs::Document.
You should avoid creating documents directly. Instead, use #to_document instance method of GroupDocs::Storage::File.
290 291 292 293 294 |
# File 'lib/groupdocs/document.rb', line 290 def initialize( = {}, &blk) super(, &blk) file.is_a?(GroupDocs::Storage::File) or raise ArgumentError, "You have to pass GroupDocs::Storage::File object: #{file.inspect}." end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &blk) ⇒ Object
1374 1375 1376 |
# File 'lib/groupdocs/document.rb', line 1374 def method_missing(method, *args, &blk) file.respond_to?(method) ? file.send(method, *args, &blk) : super end |
Instance Attribute Details
#field_count ⇒ Object
198 199 200 |
# File 'lib/groupdocs/document.rb', line 198 def field_count @field_count end |
#file ⇒ Object
186 187 188 |
# File 'lib/groupdocs/document.rb', line 186 def file @file end |
#order ⇒ Object
196 197 198 |
# File 'lib/groupdocs/document.rb', line 196 def order @order end |
#output_formats ⇒ Array<Symbol>
Returns output formats in human-readable format.
192 193 194 |
# File 'lib/groupdocs/document.rb', line 192 def output_formats @output_formats end |
#outputs ⇒ Object
190 191 192 |
# File 'lib/groupdocs/document.rb', line 190 def outputs @outputs end |
#process_date ⇒ Time
Converts timestamp which is return by API server to Time object.
188 189 190 |
# File 'lib/groupdocs/document.rb', line 188 def process_date @process_date end |
#status ⇒ Symbol
Converts status to human-readable format.
194 195 196 |
# File 'lib/groupdocs/document.rb', line 194 def status @status end |
Class Method Details
.metadata!(path, access = {}) ⇒ Array<GroupDocs::Document::View>
Returns a document metadata by given path.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/groupdocs/document.rb', line 167 def self.(path, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{path}" end.execute! Document::MetaData.new do || .id = json[:id] .guid = json[:guid] .page_count = json[:page_count] .views_count = json[:views_count] if json[:last_view] .last_view = json[:last_view] end end end |
.public_fields!(access = {}) ⇒ Array
Changed in release 1.5.8
Get document fields
1448 1449 1450 1451 1452 1453 1454 |
# File 'lib/groupdocs/document.rb', line 1448 def self.public_fields!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/documents/#{file.guid}/fields" end.execute! end |
.sign_documents!(documents, signatures, options = {}, access = {}) ⇒ Object
Signs given documents with signatures.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/groupdocs/document.rb', line 93 def self.sign_documents!(documents, signatures, = {}, access = {}) documents.each do |document| document.is_a?(Document) or raise ArgumentError, "Each document should be GroupDocs::Document object, received: #{document.inspect}" document.file.name or raise ArgumentError, "Each document file should have name, received: #{document.file.name.inspect}" document.file.local_path or raise ArgumentError, "Each document file should have local_path, received: #{document.file.local_path.inspect}" end signatures.each do |signature| signature.is_a?(Signature) or raise ArgumentError, "Each signature should be GroupDocs::Signature object, received: #{signature.inspect}" signature.name or raise ArgumentError, "Each signature should have name, received: #{signature.name.inspect}" signature.image_path or raise ArgumentError, "Each signature should have image_path, received: #{signature.image_path.inspect}" signature.position or raise ArgumentError, "Each signature should have position, received: #{signature.position.inspect}" end documents_to_sign = [] documents.map(&:file).each do |file| document = { :name => file.name } contents = File.open(file.local_path, 'rb').read contents = Base64.strict_encode64(contents) document.merge!(:data => "data:#{mime_type(file.local_path)};base64,#{contents}") documents_to_sign << document end signers = [] signatures.each do |signature| contents = File.open(signature.image_path, 'rb').read contents = Base64.strict_encode64(contents) signer = { :name => signature.name, :data => "data:#{mime_type(signature.image_path)};base64,#{contents}" } signer.merge!(signature.position) # place signature on is not implemented yet signer.merge!(:placeSignatureOn => nil) signers << signer end json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = '/signature/{{client_id}}/sign' request[:request_body] = { :documents => documents_to_sign, :signers => signers } end.execute! json[:jobId] end |
.templates!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns an array of all templates (documents in “Templates” directory).
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/groupdocs/document.rb', line 57 def self.templates!( = {}, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/merge/{{client_id}}/templates' end.execute! json[:templates].map do |template| template.merge!(:file => Storage::File.new(template)) Document.new(template) end end |
.views!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::View>
Returns an array of views for all documents.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/groupdocs/document.rb', line 35 def self.views!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/doc/{{client_id}}/views' end api.add_params() json = api.execute! json[:views].map do |view| Document::View.new(view) end end |
Instance Method Details
#access_mode!(access = {}) ⇒ Symbol
Returns access mode of document.
624 625 626 627 628 629 630 631 632 |
# File 'lib/groupdocs/document.rb', line 624 def access_mode!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/accessinfo" end.execute! parse_access_mode(json[:access]) end |
#access_mode_set!(mode, access = {}) ⇒ Symbol Also known as: access_mode=
Sets access mode of document.
643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/groupdocs/document.rb', line 643 def access_mode_set!(mode, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo" end api.add_params(:mode => ACCESS_MODES[mode]) json = api.execute! parse_access_mode(json[:access]) end |
#add_collaborator!(collaborator, access = {}) ⇒ Object
Adds document annotations collaborator.
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 |
# File 'lib/groupdocs/document.rb', line 1258 def add_collaborator!(collaborator, access = {}) collaborator.is_a?(GroupDocs::User) or raise ArgumentError, "Collaborator should be GroupDocs::User object, received: #{collaborator.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators" request[:request_body] = collaborator.to_hash end.execute! end |
#add_questionnaire!(questionnaire, access = {}) ⇒ Object
Adds questionnaire to document.
979 980 981 982 983 984 985 986 987 988 |
# File 'lib/groupdocs/document.rb', line 979 def add_questionnaire!(questionnaire, access = {}) questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError, "Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}" end.execute! end |
#annotations!(access = {}) ⇒ Array<GroupDocs::Document::Annotation>
Returns an array of annotations.
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
# File 'lib/groupdocs/document.rb', line 1045 def annotations!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/ant/{{client_id}}/files/#{file.guid}/annotations" end.execute! if json[:annotations] json[:annotations].map do |annotation| annotation.merge!(:document => self) Document::Annotation.new(annotation) end else [] end end |
#changes!(access = {}) ⇒ Object
Returns an array of changes in document.
1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
# File 'lib/groupdocs/document.rb', line 1154 def changes!(access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/comparison/public/#{file.guid}/changes' end json = api.execute! json[:changes].map do |change| Document::Change.new(change) end end |
#collaborators!(access = {}) ⇒ Array<GroupDocs::User>
Returns document annotations collaborators.
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/groupdocs/document.rb', line 1215 def collaborators!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators" end.execute! json[:collaborators].map do |collaborator| User.new(collaborator) end end |
#compare!(document, callback, access = {}) ⇒ GroupDocs::Job
Changed in release 1.5.8 Schedules a job for comparing document with given.
1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
# File 'lib/groupdocs/document.rb', line 1093 def compare!(document, callback, access = {}) document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/comparison/{{client_id}}/compare" end api.add_params(:source => file.guid, :target => document.file.guid, :callback => callback) json = api.execute! Job.new(:id => json[:job_id]) end |
#content!(content_type, access = {}) ⇒ String
Returns document content
545 546 547 548 549 550 551 552 553 |
# File 'lib/groupdocs/document.rb', line 545 def content!(content_type, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/content/#{content_type}" end.execute! json[:content] end |
#convert!(format, options = {}, access = {}) ⇒ GroupDocs::Job
Converts document to given format.
873 874 875 876 877 878 879 880 881 882 883 884 885 |
# File 'lib/groupdocs/document.rb', line 873 def convert!(format, = {}, access = {}) .merge!(:new_type => format) api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/async/{{client_id}}/files/#{file.guid}" end api.add_params() json = api.execute! Job.new(:id => json[:job_id]) end |
#create_questionnaire!(questionnaire, access = {}) ⇒ GroupDocs::Questionnaire
Creates questionnaire and adds it to document.
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
# File 'lib/groupdocs/document.rb', line 1001 def create_questionnaire!(questionnaire, access = {}) questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError, "Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}" json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires" request[:request_body] = questionnaire.to_hash end.execute! questionnaire.id = json[:questionnaire_id] questionnaire end |
#datasource!(datasource, options = {}, access = {}) ⇒ GroupDocs::Job
Creates new job to merge datasource into document.
901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
# File 'lib/groupdocs/document.rb', line 901 def datasource!(datasource, = {}, access = {}) datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError, "Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources/#{datasource.id}" end api.add_params() json = api.execute! Job.new(:id => json[:job_id]) end |
#datasource_fields!(datasource, options = {}, access = {}) ⇒ GroupDocs::Job
Creates new job to merge datasource fields into document.
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 |
# File 'lib/groupdocs/document.rb', line 932 def datasource_fields!(datasource, = {}, access = {}) datasource.is_a?(GroupDocs::DataSource) or raise ArgumentError, "Datasource should be GroupDocs::DataSource object, received: #{datasource.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/merge/{{client_id}}/files/#{file.guid}/datasources" request[:request_body] = datasource.fields end api.add_params() json = api.execute! Job.new(:id => json[:job_id]) end |
#details!(access = {}) ⇒ Hash
Changed in release 1.5.8 Returns document details.
1071 1072 1073 1074 1075 1076 1077 1078 1079 |
# File 'lib/groupdocs/document.rb', line 1071 def details!(access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/comparison/{{client_id}}document" end api.add_params(:guid => file.guid) api.execute! end |
#document_status!(job_guid, access = {}) ⇒ Object
Get sign documents status
148 149 150 151 152 153 154 155 156 |
# File 'lib/groupdocs/document.rb', line 148 def document_status!(job_guid, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/documents/#{job_guid}" end.execute! json[:documents] end |
#download!(path, options = {}, access = {}) ⇒ Object
Changed in realese 1.5.8 Download comparison result file.
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 |
# File 'lib/groupdocs/document.rb', line 1186 def download!( path, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/comparison/public/#{file.guid}/download" end api.add_params() response = api.execute! if file.name.split('.').last != [:format] file_name = file.name.delete!(file.name.split('.').last) + [:format] else file_name = file.name end filepath = "#{path}/#{file_name}" Object::File.open(filepath, 'wb') do |file| file.write(response) end end |
#editlock!(access = {}) ⇒ Object
Returns editing metadata.
461 462 463 464 465 466 467 |
# File 'lib/groupdocs/document.rb', line 461 def editlock!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock" end.execute! end |
#editlock_clear!(options = {}, access = {}) ⇒ Integer
Removes edit lock for a document and replaces the document with its edited copy
479 480 481 482 483 484 485 486 |
# File 'lib/groupdocs/document.rb', line 479 def editlock_clear!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/doc/{{client_id}}/files/#{file.guid}/editlock" end api.add_params().execute! end |
#fields!(access = {}) ⇒ Array<GroupDocs::Document::Field>
Returns an array of document fields.
711 712 713 714 715 716 717 718 719 720 721 722 723 |
# File 'lib/groupdocs/document.rb', line 711 def fields!(access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/fields" end api.add_params(:include_geometry => true) json = api.execute! json[:fields].map do |field| Document::Field.new(field) end end |
#formats!(access = {}) ⇒ Array<Symbol>
Returns array of file formats document can be converted to.
665 666 667 668 669 670 671 672 673 674 675 |
# File 'lib/groupdocs/document.rb', line 665 def formats!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.id}/formats" end.execute! json[:types].map do |format| format.downcase.to_sym end end |
#hyperlinks!(access = {}) ⇒ Object
added in release 1.5.8
Returns document hyperlinks
1392 1393 1394 1395 1396 1397 1398 1399 1400 |
# File 'lib/groupdocs/document.rb', line 1392 def hyperlinks!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/hyperlinks" end.execute! json[:links] end |
#metadata!(access = {}) ⇒ GroupDocs::Document::MetaData
Returns document metadata.
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
# File 'lib/groupdocs/document.rb', line 685 def (access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/metadata" end.execute! Document::MetaData.new do || .id = json[:id] .guid = json[:guid] .page_count = json[:page_count] .views_count = json[:views_count] if json[:last_view] .last_view = json[:last_view] end end end |
#page_fixed_html!(path, name, page_number, options = {}, access = {}) ⇒ Object
Returns an HTML Fixed representation of a particular document page
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/groupdocs/document.rb', line 345 def page_fixed_html!(path, name, page_number, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/#{page_number}/htmlFixed" end api.add_params() response = api.execute! filepath = "#{path}/#{name}" Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#page_html!(path, name, page_number, options = {}, access = {}) ⇒ Object
Returns an HTML representation of a particular document page
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/groupdocs/document.rb', line 375 def page_html!(path, name, page_number, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/#{page_number}/htmlRepresentations" end api.add_params() response = api.execute! filepath = "#{path}/#{name}" Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#page_html_urls!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to html representing document pages.
442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/groupdocs/document.rb', line 442 def page_html_urls!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/htmlRepresentationUrls" end api.add_params() json = api.execute! json[:url] end |
#page_image!(path, name, page_number, dimension, options = {}, access = {}) ⇒ Object
Returns a stream of bytes representing a particular document page image.
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/groupdocs/document.rb', line 314 def page_image!(path, name, page_number, dimension, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/#{page_number}/images/#{dimension}" end api.add_params() response = api.execute! filepath = "#{path}/#{name}" Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#page_images!(width, height, options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages.
414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/groupdocs/document.rb', line 414 def page_images!(width, height, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/pages/images/#{width}x#{height}/urls" end api.add_params() json = api.execute! json[:url] end |
#password_set!(password, access = {}) ⇒ Array<GroupDocs::User>
Sets document password.
805 806 807 808 809 810 811 812 813 |
# File 'lib/groupdocs/document.rb', line 805 def password_set!(password, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/doc/{{client_id}}/files/#{file.guid}/password" request[:request_body] = password end.execute! end |
#public_sign_document!(options = {}, access = {}) ⇒ Array
Changed in release 1.5.8
Public Sign document
1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 |
# File 'lib/groupdocs/document.rb', line 1424 def public_sign_document!( = {}, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/public/documents/#{file.guid}/sign" request[:request_body] = end.execute! json[:jobId] end |
#questionnaires!(access = {}) ⇒ Array<GroupDocs::Questionnaire>
Returns an array of questionnaires.
957 958 959 960 961 962 963 964 965 966 967 |
# File 'lib/groupdocs/document.rb', line 957 def questionnaires!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires" end.execute! json[:questionnaires].map do |questionnaire| Questionnaire.new(questionnaire) end end |
#remove_collaborators!(reviewerId, access = {}) ⇒ Object
Delete document reviewer
1279 1280 1281 1282 1283 1284 1285 1286 |
# File 'lib/groupdocs/document.rb', line 1279 def remove_collaborators!(reviewerId, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/ant/{{client_id}}/files/#{file.guid}/collaborators/#{reviewerId}" end.execute! end |
#remove_questionnaire!(questionnaire, access = {}) ⇒ Object
Detaches questionnaire from document.
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File 'lib/groupdocs/document.rb', line 1026 def remove_questionnaire!(questionnaire, access = {}) questionnaire.is_a?(GroupDocs::Questionnaire) or raise ArgumentError, "Questionnaire should be GroupDocs::Questionnaire object, received: #{questionnaire.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/merge/{{client_id}}/files/#{file.guid}/questionnaires/#{questionnaire.id}" end.execute! end |
#representations!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages htmlRepresentations.
603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/groupdocs/document.rb', line 603 def representations!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/doc/{{client_id}}/files/#{file.guid}/htmlRepresentations" end api.add_params() json = api.execute! json[:pageHtml] end |
#respond_to?(method) ⇒ Boolean
1378 1379 1380 |
# File 'lib/groupdocs/document.rb', line 1378 def respond_to?(method) super or file.respond_to?(method) end |
#set_collaborators!(emails, version = 1, access = {}) ⇒ Array<GroupDocs::User>
Sets document annotations collaborators to given emails.
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
# File 'lib/groupdocs/document.rb', line 1237 def set_collaborators!(emails, version = 1, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/files/#{file.guid}/version/#{version}/collaborators" request[:request_body] = emails end.execute! json[:collaborators].map do |collaborator| User.new(collaborator) end end |
#set_reviewers!(reviewers, access = {}) ⇒ Object
Sets reviewers for document.
1303 1304 1305 1306 1307 1308 1309 1310 |
# File 'lib/groupdocs/document.rb', line 1303 def set_reviewers!(reviewers, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/files/#{file.guid}/reviewerRights" request[:request_body] = reviewers.map(&:to_hash) end.execute! end |
#set_session_callback!(url, access = {}) ⇒ Object
Sets session callback URL.
1360 1361 1362 1363 1364 1365 1366 1367 |
# File 'lib/groupdocs/document.rb', line 1360 def set_session_callback!(url, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sessionCallbackUrl" request[:request_body] = url end.execute! end |
#set_shared_link_access_rights!(rights, access = {}) ⇒ Array<Symbol>
Sets access rights for shared link.
1343 1344 1345 1346 1347 1348 1349 1350 |
# File 'lib/groupdocs/document.rb', line 1343 def set_shared_link_access_rights!(rights, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights" request[:request_body] = convert_access_rights_to_byte(rights) end.execute! end |
#shared_documents!(sharers_types, options = {}, access = {}) ⇒ Array<GroupDocs::User>
Returns an array of users a document is shared with.
758 759 760 761 762 763 764 765 766 |
# File 'lib/groupdocs/document.rb', line 758 def shared_documents!(sharers_types, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/shares/#{sharers_types}" end api.add_params().execute! end |
#shared_link_access_rights!(access = {}) ⇒ Array<Symbol>
Returns an array of access rights for shared link.
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 |
# File 'lib/groupdocs/document.rb', line 1320 def shared_link_access_rights!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/ant/{{client_id}}/files/#{file.guid}/sharedLinkAccessRights" end.execute! if json[:accessRights] convert_byte_to_access_rights json[:accessRights] else [] end end |
#sharers!(access = {}) ⇒ Array<GroupDocs::User>
Returns an array of users a document is shared with.
733 734 735 736 737 738 739 740 741 742 743 |
# File 'lib/groupdocs/document.rb', line 733 def sharers!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.id}/accessinfo" end.execute! json[:sharers].map do |user| User.new(user) end end |
#sharers_clear!(access = {}) ⇒ Object
Clears sharers list.
842 843 844 845 846 847 848 849 |
# File 'lib/groupdocs/document.rb', line 842 def sharers_clear!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers" end.execute![:shared_users] end |
#sharers_set!(emails, access = {}) ⇒ Array<GroupDocs::User>
Sets document sharers to given emails.
If empty array or nil passed, clears sharers.
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
# File 'lib/groupdocs/document.rb', line 779 def sharers_set!(emails, access = {}) if emails.nil? || emails.empty? sharers_clear!(access) else json = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/doc/{{client_id}}/files/#{file.id}/sharers" request[:request_body] = emails end.execute! json[:shared_users].map do |user| User.new(user) end end end |
#tags!(access = {}) ⇒ Array<String>
Returns tags assigned to the document
496 497 498 499 500 501 502 |
# File 'lib/groupdocs/document.rb', line 496 def (access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags" end.execute! end |
#tags_clear!(access = {}) ⇒ String
Removes tags assigned to the document
528 529 530 531 532 533 534 |
# File 'lib/groupdocs/document.rb', line 528 def (access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags" end.execute! end |
#tags_set!(access = {}) ⇒ String
Assign tags to the document.
512 513 514 515 516 517 518 |
# File 'lib/groupdocs/document.rb', line 512 def (access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/doc/{{client_id}}/files/#{file.guid}/tags" end.execute! end |
#thumbnails!(options = {}, access = {}) ⇒ Array<String>
Returns array of URLs to images representing document pages thumbnails.
574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/groupdocs/document.rb', line 574 def thumbnails!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/doc/{{client_id}}/files/#{file.guid}/thumbnails" end api.add_params() json = api.execute! json[:image_urls] end |
#update_changes!(changes, access = {}) ⇒ GroupDocs::Change
Schedules a job for comparing document with given.
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/groupdocs/document.rb', line 1123 def update_changes!(changes, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/comparison/public/#{file.guid}/changes" request[:request_body] = changes end json = api.execute! json[:changes].map do |change| Document::Change.new(change) end end |
#user_status_set!(status, access = {}) ⇒ String
Sets document user status.
824 825 826 827 828 829 830 831 832 |
# File 'lib/groupdocs/document.rb', line 824 def user_status_set!(status, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/doc/{{client_id}}/files/#{file.guid}/sharer" request[:request_body] = status end.execute! end |