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.
-
.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
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
Returns document details.
-
#document_status!(job_guid, access = {}) ⇒ Object
Get sign documents status.
-
#download!(path, options = {}, access = {}) ⇒ Object
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.
-
#initialize(options = {}, &blk) ⇒ Document
constructor
Creates new GroupDocs::Document.
-
#metadata!(access = {}) ⇒ GroupDocs::Document::MetaData
Returns document metadata.
-
#method_missing(method, *args, &blk) ⇒ Object
Pass all unknown methods to file.
-
#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.
-
#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.
291 292 293 294 295 |
# File 'lib/groupdocs/document.rb', line 291 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
Pass all unknown methods to file.
1360 1361 1362 |
# File 'lib/groupdocs/document.rb', line 1360 def method_missing(method, *args, &blk) file.respond_to?(method) ? file.send(method, *args, &blk) : super end |
Instance Attribute Details
#field_count ⇒ Object
199 200 201 |
# File 'lib/groupdocs/document.rb', line 199 def field_count @field_count end |
#file ⇒ Object
187 188 189 |
# File 'lib/groupdocs/document.rb', line 187 def file @file end |
#order ⇒ Object
197 198 199 |
# File 'lib/groupdocs/document.rb', line 197 def order @order end |
#output_formats ⇒ Array<Symbol>
Returns output formats in human-readable format.
193 194 195 |
# File 'lib/groupdocs/document.rb', line 193 def output_formats @output_formats end |
#outputs ⇒ Object
191 192 193 |
# File 'lib/groupdocs/document.rb', line 191 def outputs @outputs end |
#process_date ⇒ Time
Converts timestamp which is return by API server to Time object.
189 190 191 |
# File 'lib/groupdocs/document.rb', line 189 def process_date @process_date end |
#status ⇒ Symbol
Converts status to human-readable format.
195 196 197 |
# File 'lib/groupdocs/document.rb', line 195 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 184 |
# 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 |
.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.
625 626 627 628 629 630 631 632 633 |
# File 'lib/groupdocs/document.rb', line 625 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.
644 645 646 647 648 649 650 651 652 653 654 |
# File 'lib/groupdocs/document.rb', line 644 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.guid}/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.
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
# File 'lib/groupdocs/document.rb', line 1245 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.
980 981 982 983 984 985 986 987 988 989 |
# File 'lib/groupdocs/document.rb', line 980 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.
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 |
# File 'lib/groupdocs/document.rb', line 1046 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.
1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 |
# File 'lib/groupdocs/document.rb', line 1153 def changes!(access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/comparison/{{client_id}}/comparison/changes' end api.add_params(:resultFileId => file.guid) json = api.execute! json[:changes].map do |change| Document::Change.new(change) end end |
#collaborators!(access = {}) ⇒ Array<GroupDocs::User>
Returns document annotations collaborators.
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File 'lib/groupdocs/document.rb', line 1202 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
Schedules a job for comparing document with given.
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
# File 'lib/groupdocs/document.rb', line 1092 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}}/comparison/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
546 547 548 549 550 551 552 553 554 |
# File 'lib/groupdocs/document.rb', line 546 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.
874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'lib/groupdocs/document.rb', line 874 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.
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 |
# File 'lib/groupdocs/document.rb', line 1002 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.
902 903 904 905 906 907 908 909 910 911 912 913 914 915 |
# File 'lib/groupdocs/document.rb', line 902 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.
933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
# File 'lib/groupdocs/document.rb', line 933 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
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}}/comparison/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
Download comparison result file.
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 |
# File 'lib/groupdocs/document.rb', line 1178 def download!( path, = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/comparison/{{client_id}}/comparison/download" end api.add_params() response = api.execute! filepath = "#{path}/#{file.name}" Object::File.open(filepath, 'wb') do |file| file.write(response) end end |
#editlock!(access = {}) ⇒ Object
Returns editing metadata.
462 463 464 465 466 467 468 |
# File 'lib/groupdocs/document.rb', line 462 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
480 481 482 483 484 485 486 487 |
# File 'lib/groupdocs/document.rb', line 480 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.
712 713 714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/groupdocs/document.rb', line 712 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.
666 667 668 669 670 671 672 673 674 675 676 |
# File 'lib/groupdocs/document.rb', line 666 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 |
#metadata!(access = {}) ⇒ GroupDocs::Document::MetaData
Returns document metadata.
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 |
# File 'lib/groupdocs/document.rb', line 686 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
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/groupdocs/document.rb', line 346 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
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File 'lib/groupdocs/document.rb', line 376 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.
443 444 445 446 447 448 449 450 451 452 453 |
# File 'lib/groupdocs/document.rb', line 443 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.
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/groupdocs/document.rb', line 315 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.
415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/groupdocs/document.rb', line 415 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.
806 807 808 809 810 811 812 813 814 |
# File 'lib/groupdocs/document.rb', line 806 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 |
#questionnaires!(access = {}) ⇒ Array<GroupDocs::Questionnaire>
Returns an array of questionnaires.
958 959 960 961 962 963 964 965 966 967 968 |
# File 'lib/groupdocs/document.rb', line 958 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
1266 1267 1268 1269 1270 1271 1272 1273 |
# File 'lib/groupdocs/document.rb', line 1266 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.
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
# File 'lib/groupdocs/document.rb', line 1027 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.
604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/groupdocs/document.rb', line 604 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
1364 1365 1366 |
# File 'lib/groupdocs/document.rb', line 1364 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.
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 |
# File 'lib/groupdocs/document.rb', line 1224 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.
1290 1291 1292 1293 1294 1295 1296 1297 |
# File 'lib/groupdocs/document.rb', line 1290 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.
1347 1348 1349 1350 1351 1352 1353 1354 |
# File 'lib/groupdocs/document.rb', line 1347 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.
1330 1331 1332 1333 1334 1335 1336 1337 |
# File 'lib/groupdocs/document.rb', line 1330 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.
759 760 761 762 763 764 765 766 767 |
# File 'lib/groupdocs/document.rb', line 759 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.
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 |
# File 'lib/groupdocs/document.rb', line 1307 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.
734 735 736 737 738 739 740 741 742 743 744 |
# File 'lib/groupdocs/document.rb', line 734 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.
843 844 845 846 847 848 849 850 |
# File 'lib/groupdocs/document.rb', line 843 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.
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'lib/groupdocs/document.rb', line 780 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
497 498 499 500 501 502 503 |
# File 'lib/groupdocs/document.rb', line 497 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
529 530 531 532 533 534 535 |
# File 'lib/groupdocs/document.rb', line 529 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.
513 514 515 516 517 518 519 |
# File 'lib/groupdocs/document.rb', line 513 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.
575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/groupdocs/document.rb', line 575 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.
1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 |
# File 'lib/groupdocs/document.rb', line 1122 def update_changes!(changes, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/comparison/{{client_id}}/comparison/changes" request[:request_body] = changes end api.add_params(:resultFileId => file.guid) json = api.execute! json[:changes].map do |change| Document::Change.new(change) end end |
#user_status_set!(status, access = {}) ⇒ String
Sets document user status.
825 826 827 828 829 830 831 832 833 |
# File 'lib/groupdocs/document.rb', line 825 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 |