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
-
#canParticipantPrintForm ⇒ Object
added in release 1.6.0.
- #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.
-
#document_fields!(document, options = {}, access = {}) ⇒ Object
Added in release 1.7.0.
-
#documents!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns documents array.
-
#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.
-
#get_fields!(options = {}, access = {}) ⇒ Object
Changed in release 2.0.0.
-
#get_logs!(access = {}) ⇒ Object
Added in release 1.7.0.
-
#get_participants!(access = {}) ⇒ Object
Added in release 1.8.0.
-
#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!(filepath, participant, authentication, participant_name, settings = {}, access = {}) ⇒ Array
Changed in release 1.7.0.
-
#signed_documents!(path, access = {}) ⇒ String
Changed in release 1.5.8.
-
#update_from_template!(template, access = {}) ⇒ Object
Updates form adding fields from template.
-
#update_partipicant!(participant, email, access = {}) ⇒ Array
Added in release 1.7.0.
-
#validate_partipicant!(participant, code, access = {}) ⇒ Array
Added in release 1.7.0.
Methods included from ResourceMethods
Methods included from FieldMethods
#assign_field!, #delete_field!, #delete_field_location!, #fields!, #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
99 100 101 |
# File 'lib/groupdocs/signature/form.rb', line 99 def canParticipantDownloadForm @canParticipantDownloadForm end |
#canParticipantPrintForm ⇒ Object
added in release 1.6.0
111 112 113 |
# File 'lib/groupdocs/signature/form.rb', line 111 def canParticipantPrintForm @canParticipantPrintForm end |
#createdTimeStamp ⇒ Object
87 88 89 |
# File 'lib/groupdocs/signature/form.rb', line 87 def createdTimeStamp @createdTimeStamp end |
#documentsCount ⇒ Object
91 92 93 |
# File 'lib/groupdocs/signature/form.rb', line 91 def documentsCount @documentsCount end |
#documentsPages ⇒ Object
93 94 95 |
# File 'lib/groupdocs/signature/form.rb', line 93 def documentsPages @documentsPages end |
#fieldsInFinalFileName ⇒ Object
97 98 99 |
# File 'lib/groupdocs/signature/form.rb', line 97 def fieldsInFinalFileName @fieldsInFinalFileName end |
#id ⇒ Object
79 80 81 |
# File 'lib/groupdocs/signature/form.rb', line 79 def id @id end |
#name ⇒ Object
81 82 83 |
# File 'lib/groupdocs/signature/form.rb', line 81 def name @name end |
#notifyOwnerOnSign ⇒ Object
107 108 109 |
# File 'lib/groupdocs/signature/form.rb', line 107 def notifyOwnerOnSign @notifyOwnerOnSign end |
#ownerGuid ⇒ Object
83 84 85 |
# File 'lib/groupdocs/signature/form.rb', line 83 def ownerGuid @ownerGuid end |
#participantsCount ⇒ Object
95 96 97 |
# File 'lib/groupdocs/signature/form.rb', line 95 def participantsCount @participantsCount end |
#status ⇒ Symbol
Converts status to human-readable format.
101 102 103 |
# File 'lib/groupdocs/signature/form.rb', line 101 def status @status end |
#statusDateTime ⇒ Object
89 90 91 |
# File 'lib/groupdocs/signature/form.rb', line 89 def statusDateTime @statusDateTime end |
#templateGuid ⇒ Object
85 86 87 |
# File 'lib/groupdocs/signature/form.rb', line 85 def templateGuid @templateGuid end |
#waterMarkImage ⇒ Object
105 106 107 |
# File 'lib/groupdocs/signature/form.rb', line 105 def waterMarkImage @waterMarkImage end |
#waterMarkText ⇒ Object
103 104 105 |
# File 'lib/groupdocs/signature/form.rb', line 103 def waterMarkText @waterMarkText end |
Class Method Details
.all!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Form>
Returns a list of all forms.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/groupdocs/signature/form.rb', line 36 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.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/groupdocs/signature/form.rb', line 64 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.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/groupdocs/signature/form.rb', line 316 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.
260 261 262 263 264 265 266 |
# File 'lib/groupdocs/signature/form.rb', line 260 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.
245 246 247 248 249 250 251 |
# File 'lib/groupdocs/signature/form.rb', line 245 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.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/groupdocs/signature/form.rb', line 174 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 |
#document_fields!(document, options = {}, access = {}) ⇒ Object
Added in release 1.7.0
Get form fields for document in form per participant.
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
# File 'lib/groupdocs/signature/form.rb', line 707 def document_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 |
#documents!(options = {}, access = {}) ⇒ Array<GroupDocs::Document>
Returns documents array.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/groupdocs/signature/form.rb', line 204 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_in_final_file_name ⇒ Array<String>
Converts field names to human-readable format.
154 155 156 |
# File 'lib/groupdocs/signature/form.rb', line 154 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.
142 143 144 145 146 147 148 |
# File 'lib/groupdocs/signature/form.rb', line 142 def fields_in_final_file_name=(fields) if fields.is_a?(Array) fields = fields.join(',') end @fieldsInFinalFileName = fields end |
#get_fields!(options = {}, access = {}) ⇒ Object
Changed in release 2.0.0
Returns an array of fields for document per participant.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/groupdocs/signature/form.rb', line 279 def get_fields!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/{{client_id}}/forms/#{id}/fields" end api.add_params() json = api.execute! json[:fields].map do |field| Signature::Field.new(field) end end |
#get_logs!(access = {}) ⇒ Object
Added in release 1.7.0
Get form audit logs
736 737 738 739 740 741 742 743 |
# File 'lib/groupdocs/signature/form.rb', line 736 def get_logs!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/{{client_id}}/forms/#{id}/logs" end.execute! end |
#get_participants!(access = {}) ⇒ Object
Added in release 1.8.0
Get form participants
757 758 759 760 761 762 763 764 |
# File 'lib/groupdocs/signature/form.rb', line 757 def get_participants!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/{{client_id}}/forms/#{id}/participants" end.execute! end |
#modify_field_location!(location, field, document, access = {}) ⇒ Object
Modifies field location.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
# File 'lib/groupdocs/signature/form.rb', line 360 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
416 417 418 419 420 421 422 423 424 425 426 |
# File 'lib/groupdocs/signature/form.rb', line 416 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.
606 607 608 609 610 611 612 613 614 |
# File 'lib/groupdocs/signature/form.rb', line 606 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
580 581 582 583 584 585 586 587 588 589 590 591 592 |
# File 'lib/groupdocs/signature/form.rb', line 580 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
469 470 471 472 473 474 475 |
# File 'lib/groupdocs/signature/form.rb', line 469 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.
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/groupdocs/signature/form.rb', line 518 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.
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/groupdocs/signature/form.rb', line 628 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
229 230 231 232 233 234 235 236 |
# File 'lib/groupdocs/signature/form.rb', line 229 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!(filepath, participant, authentication, participant_name, settings = {}, access = {}) ⇒ Array
Changed in release 1.7.0
Public sign form.
553 554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/groupdocs/signature/form.rb', line 553 def sign!( filepath, participant, authentication, participant_name, settings = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/public/forms/#{id}/participant/#{participant}/sign" request[:request_body] = Object::File.new(filepath, 'rb') request[:request_body] = settings 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.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/groupdocs/signature/form.rb', line 441 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.
385 386 387 388 389 390 391 392 393 394 |
# File 'lib/groupdocs/signature/form.rb', line 385 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/#{id}/templates/#{template.id}" end.execute! end |
#update_partipicant!(participant, email, access = {}) ⇒ Array
Added in release 1.7.0
Update Form Participant.
664 665 666 667 668 669 670 671 672 |
# File 'lib/groupdocs/signature/form.rb', line 664 def update_partipicant!(participant, email, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/public/forms/#{id}/participant/#{participant}" end api.add_params(:email => email) api.execute! end |
#validate_partipicant!(participant, code, access = {}) ⇒ Array
Added in release 1.7.0
Validate Particpiant Identity.
686 687 688 689 690 691 692 |
# File 'lib/groupdocs/signature/form.rb', line 686 def validate_partipicant!(participant, code, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/forms/#{id}/participant/#{participant}/validationCode/#{code}" end.execute! end |