Class: GroupDocs::Signature::Form
- Inherits:
-
Api::Entity
- Object
- Api::Entity
- GroupDocs::Signature::Form
- Extended by:
- ResourceMethods
- Defined in:
- lib/groupdocs/signature/form.rb
Constant Summary collapse
- STATUSES =
{ :draft => -1, :in_progress => 1, :completed => 2, :archived => 3, }
Instance Attribute Summary collapse
- #canParticipantDownloadForm ⇒ Object
- #createdTimeStamp ⇒ Object
- #documentsCount ⇒ Object
- #documentsPages ⇒ Object
- #fieldsInFinalFileName ⇒ Object
- #id ⇒ Object
- #name ⇒ Object
- #notifyOwnerOnSign ⇒ Object
- #ownerGuid ⇒ Object
- #participantsCount ⇒ Object
-
#status ⇒ Symbol
Converts status to human-readable format.
- #statusDateTime ⇒ Object
- #templateGuid ⇒ Object
- #waterMarkImage ⇒ Object
- #waterMarkText ⇒ Object
Class Method Summary collapse
-
.all!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Form>
Returns a list of all forms.
-
.get!(id, options = {}, access = {}) ⇒ GroupDocs::Signature::Form
Returns form by its identifier.
Instance Method Summary collapse
-
#add_field!(field, document, opts = {}, access = {}) ⇒ Object
Adds field for document.
-
#archive!(access = {}) ⇒ Object
Archives completed form.
-
#complete!(access = {}) ⇒ Object
Completes form.
-
#create!(options = {}, access = {}) ⇒ Object
Creates form.
-
#documents!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns documents array.
-
#fields!(document, options = {}, access = {}) ⇒ Object
Changed in release 1.5.8.
-
#fields_in_final_file_name ⇒ Array<String>
Converts field names to human-readable format.
-
#fields_in_final_file_name=(fields) ⇒ Object
Converts array of field names to machine-readable format.
-
#modify_field_location!(location, field, document, access = {}) ⇒ Object
Modifies field location.
-
#modify_form_document!(document, options = {}, access = {}) ⇒ Object
Modify signature form document.
-
#participant!(participant, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#public_fields!(options = {}, access = {}) ⇒ Array
Changed in release 1.5.8.
- #public_fill!(access = {}) ⇒ Array
-
#public_fill_field!(value, field, document, participant, authentication, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#public_signed_documents!(path, participant, access = {}) ⇒ Array
Changed in release 1.5.8.
- #publish!(callbackUrl = {}, access = {}) ⇒ Object
-
#sign!(participant, authentication, participant_name, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#signed_documents!(path, access = {}) ⇒ String
Changed in release 1.5.8.
-
#update_from_template!(template, access = {}) ⇒ Object
Updates form adding fields from template.
Methods included from ResourceMethods
Methods included from FieldMethods
#assign_field!, #delete_field!, #delete_field_location!, #modify_field!
Methods included from DocumentMethods
#add_document!, #remove_document!, #rename_document!
Methods included from EntityMethods
#delete!, included, #modify!, #rename!
Methods inherited from Api::Entity
#initialize, #inspect, #to_hash
Methods included from Api::Helpers::Accessor
Constructor Details
This class inherits a constructor from GroupDocs::Api::Entity
Instance Attribute Details
#canParticipantDownloadForm ⇒ Object
98 99 100 |
# File 'lib/groupdocs/signature/form.rb', line 98 def canParticipantDownloadForm @canParticipantDownloadForm end |
#createdTimeStamp ⇒ Object
86 87 88 |
# File 'lib/groupdocs/signature/form.rb', line 86 def createdTimeStamp @createdTimeStamp end |
#documentsCount ⇒ Object
90 91 92 |
# File 'lib/groupdocs/signature/form.rb', line 90 def documentsCount @documentsCount end |
#documentsPages ⇒ Object
92 93 94 |
# File 'lib/groupdocs/signature/form.rb', line 92 def documentsPages @documentsPages end |
#fieldsInFinalFileName ⇒ Object
96 97 98 |
# File 'lib/groupdocs/signature/form.rb', line 96 def fieldsInFinalFileName @fieldsInFinalFileName end |
#id ⇒ Object
78 79 80 |
# File 'lib/groupdocs/signature/form.rb', line 78 def id @id end |
#name ⇒ Object
80 81 82 |
# File 'lib/groupdocs/signature/form.rb', line 80 def name @name end |
#notifyOwnerOnSign ⇒ Object
106 107 108 |
# File 'lib/groupdocs/signature/form.rb', line 106 def notifyOwnerOnSign @notifyOwnerOnSign end |
#ownerGuid ⇒ Object
82 83 84 |
# File 'lib/groupdocs/signature/form.rb', line 82 def ownerGuid @ownerGuid end |
#participantsCount ⇒ Object
94 95 96 |
# File 'lib/groupdocs/signature/form.rb', line 94 def participantsCount @participantsCount end |
#status ⇒ Symbol
Converts status to human-readable format.
100 101 102 |
# File 'lib/groupdocs/signature/form.rb', line 100 def status @status end |
#statusDateTime ⇒ Object
88 89 90 |
# File 'lib/groupdocs/signature/form.rb', line 88 def statusDateTime @statusDateTime end |
#templateGuid ⇒ Object
84 85 86 |
# File 'lib/groupdocs/signature/form.rb', line 84 def templateGuid @templateGuid end |
#waterMarkImage ⇒ Object
104 105 106 |
# File 'lib/groupdocs/signature/form.rb', line 104 def waterMarkImage @waterMarkImage end |
#waterMarkText ⇒ Object
102 103 104 |
# File 'lib/groupdocs/signature/form.rb', line 102 def waterMarkText @waterMarkText end |
Class Method Details
.all!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Form>
Returns a list of all forms.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/groupdocs/signature/form.rb', line 35 def self.all!( = {}, access = {}) status_id = .delete(:status_id) [:statusId] = status_id if status_id api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/signature/{{client_id}}/forms' end api.add_params() json = api.execute! json[:forms].map do |form| new(form) end end |
.get!(id, options = {}, access = {}) ⇒ GroupDocs::Signature::Form
Returns form by its identifier.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/groupdocs/signature/form.rb', line 63 def self.get!(id, = {}, access = {}) if [:public] json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/forms/#{id}" end.execute! new(json[:form]) else super(id, access) end end |
Instance Method Details
#add_field!(field, document, opts = {}, access = {}) ⇒ Object
Adds field for document.
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/groupdocs/signature/form.rb', line 312 def add_field!(field, document, opts = {}, access = {}) field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError, "Field should be GroupDocs::Signature::Field object, received: #{field.inspect}" document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" field.location or raise ArgumentError, "You have to specify field location, received: #{field.location.inspect}" opts[:force_new_field] = true if opts[:force_new_field].nil? payload = field.to_hash # field itself payload.merge!(field.location.to_hash) # location should added in plain view (i.e. not "location": {...}) payload.merge!(:forceNewField => opts[:force_new_field]) # create new field flag Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/{{client_id}}/forms/#{id}/documents/#{document.file.guid}/field/#{field.id}" request[:request_body] = payload end.execute! end |
#archive!(access = {}) ⇒ Object
Archives completed form.
253 254 255 256 257 258 259 |
# File 'lib/groupdocs/signature/form.rb', line 253 def archive!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/forms/#{id}/archive" end.execute! end |
#complete!(access = {}) ⇒ Object
Completes form.
238 239 240 241 242 243 244 |
# File 'lib/groupdocs/signature/form.rb', line 238 def complete!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/forms/#{id}/complete" end.execute! end |
#create!(options = {}, access = {}) ⇒ Object
Creates form.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/groupdocs/signature/form.rb', line 167 def create!( = {}, access = {}) #template_id = options.delete(:template_id) #assembly_id = options.delete(:assembly_id) #options[:templateId] = template_id if template_id #options[:assemblyId] = assembly_id if assembly_id api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = '/signature/{{client_id}}/form' request[:request_body] = to_hash end api.add_params(.merge(:name => name)) json = api.execute! self.id = json[:form][:id] end |
#documents!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns documents array.
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/groupdocs/signature/form.rb', line 197 def documents!( = {}, access = {}) client_id = client_id([:public]) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/#{client_id}/forms/#{id}/documents" end.execute! json[:documents].map do |document| id = document[:documentId] || document[:id] file = Storage::File.new(:guid => id, :name => document[:name]) Document.new(document.merge(:file => file)) end end |
#fields!(document, options = {}, access = {}) ⇒ Object
Changed in release 1.5.8
Returns an array of fields for document per participant.
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/groupdocs/signature/form.rb', line 274 def fields!(document, = {}, 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] = "/signature/{{client_id}}/forms/#{id}/documents/#{document.file.guid}/fields" end api.add_params() json = api.execute! json[:fields].map do |field| Signature::Field.new(field) end end |
#fields_in_final_file_name ⇒ Array<String>
Converts field names to human-readable format.
147 148 149 |
# File 'lib/groupdocs/signature/form.rb', line 147 def fields_in_final_file_name @fieldsInFinalFileName.split(',') if @fieldsInFinalFileName end |
#fields_in_final_file_name=(fields) ⇒ Object
Converts array of field names to machine-readable format.
135 136 137 138 139 140 141 |
# File 'lib/groupdocs/signature/form.rb', line 135 def fields_in_final_file_name=(fields) if fields.is_a?(Array) fields = fields.join(',') end @fieldsInFinalFileName = fields end |
#modify_field_location!(location, field, document, access = {}) ⇒ Object
Modifies field location.
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/groupdocs/signature/form.rb', line 356 def modify_field_location!(location, field, document, access = {}) location.is_a?(GroupDocs::Signature::Field::Location) or raise ArgumentError, "Location should be GroupDocs::Signature::Field::Location object, received: #{location.inspect}" field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError, "Field should be GroupDocs::Signature::Field object, received: #{field.inspect}" document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/forms/#{id}/documents/#{document.file.guid}/fields/#{field.id}/locations/#{location.id}" request[:request_body] = location.to_hash end.execute! end |
#modify_form_document!(document, options = {}, access = {}) ⇒ Object
Modify signature form document
412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/groupdocs/signature/form.rb', line 412 def modify_form_document!(document, = {}, access = {}) document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/forms/#{id}/document/#{document.file.guid}/" request[:request_body] = end.execute! end |
#participant!(participant, access = {}) ⇒ Array
Changed in release 1.5.8
Get signature form participant.
596 597 598 599 600 601 602 603 604 |
# File 'lib/groupdocs/signature/form.rb', line 596 def participant!(participant, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/forms/#{form}/participants/#{participant}" end.execute! json[:participant] end |
#public_fields!(options = {}, access = {}) ⇒ Array
Changed in release 1.5.8
Get form fields for document in form per participant
570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/groupdocs/signature/form.rb', line 570 def public_fields!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/forms/#{id}/fields" end api.add_params() json = api.execute! json[:fields].map do |field| Signature::Field.new(field) end end |
#public_fill!(access = {}) ⇒ Array
465 466 467 468 469 470 471 |
# File 'lib/groupdocs/signature/form.rb', line 465 def public_fill!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/forms/#{id}/fill" end.execute! end |
#public_fill_field!(value, field, document, participant, authentication, access = {}) ⇒ Array
Changed in release 1.5.8
Public fill form field.
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/groupdocs/signature/form.rb', line 514 def public_fill_field!(value, field, document, participant, authentication, access = {}) field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError, "Field should be GroupDocs::Signature::Field object, received: #{field.inspect}" 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] = :PUT request[:path] = "/signature/public/forms/#{id}/documents/#{document.guid}/participant/#{participant}/field/#{field.id}" request[:request_body] = value request[:plain] = true end api.add_params(:participantAuthSignature => authentication) json = api.execute! Signature::Field.new(json[:field]) end |
#public_signed_documents!(path, participant, access = {}) ⇒ Array
Changed in release 1.5.8
Get signed form documents.
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/groupdocs/signature/form.rb', line 618 def public_signed_documents!(path, participant, access = {}) response = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/signature/public/forms/#{id}/participant/#{participant}/documents/get" end.execute! filepath = "#{path}/#{name}." if documents!.size == 1 filepath << 'pdf' else filepath << 'zip' end Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#publish!(callbackUrl = {}, access = {}) ⇒ Object
222 223 224 225 226 227 228 229 |
# File 'lib/groupdocs/signature/form.rb', line 222 def publish!(callbackUrl = {}, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/forms/#{id}/publish" request[:request_body] = callbackUrl end.execute! end |
#sign!(participant, authentication, participant_name, access = {}) ⇒ Array
Changed in release 1.5.8
Public sign form.
546 547 548 549 550 551 552 553 554 |
# File 'lib/groupdocs/signature/form.rb', line 546 def sign!( participant, authentication, participant_name, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/public/forms/#{id}/participant/#{participant}/sign" end api.add_params(:participantAuthSignature => authentication, :name => participant_name) api.execute! end |
#signed_documents!(path, access = {}) ⇒ String
Changed in release 1.5.8
Downloads signed documents to given path. If there is only one file in envelope, it’s saved as PDF. If there are two or more files in envelope, it’s saved as ZIP.
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/groupdocs/signature/form.rb', line 437 def signed_documents!(path, access = {}) response = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/signature/{{client_id}}/forms/#{id}/documents/get" end.execute! filepath = "#{path}/#{name}.zip" Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#update_from_template!(template, access = {}) ⇒ Object
Updates form adding fields from template.
381 382 383 384 385 386 387 388 389 390 |
# File 'lib/groupdocs/signature/form.rb', line 381 def update_from_template!(template, access = {}) template.is_a?(GroupDocs::Signature::Template) or raise ArgumentError, "Template should be GroupDocs::Signature::Template object, received: #{template.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/{{client_id}}/forms/#{form.id}/templates/#{template.id}" end.execute! end |