Class: GroupDocs::Signature::Envelope
- Inherits:
-
Api::Entity
- Object
- Api::Entity
- GroupDocs::Signature::Envelope
- Extended by:
- ResourceMethods
- Includes:
- Api::Helpers::SignaturePublic, DocumentMethods, EntityFields, EntityMethods, FieldMethods, RecipientMethods
- Defined in:
- lib/groupdocs/signature/envelope.rb
Defined Under Namespace
Classes: Log
Constant Summary collapse
- STATUSES =
{ :draft => -1, :annotation => 0, :in_progress => 1, :expired => 2, :canceled => 3, :failed => 4, :completed => 5, :archived => 6, :scheduled => 99, }
Instance Attribute Summary collapse
- #creationDateTime ⇒ Object
- #envelopeExpireTime ⇒ Object
- #isDemo ⇒ Object
-
#status ⇒ Symbol
Converts status to human-readable format.
- #statusDateTime ⇒ Object
Attributes included from EntityFields
#documentsCount, #documentsPages, #emailBody, #emailSubject, #id, #name, #orderedSignature, #ownerGuid, #ownerId, #ownerShouldSign, #recipients, #reminderTime, #stepExpireTime, #waterMarkImage, #waterMarkText
Class Method Summary collapse
-
.all!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Envelope>
Returns a list of all envelopes.
-
.for_me!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Envelope>
Returns a list of all envelopes where user is recipient.
Instance Method Summary collapse
-
#add_recipient!(recipient, access = {}) ⇒ Object
Changed in release 1.5.8.
-
#archive!(access = {}) ⇒ Object
Archives completed envelope.
-
#cancel!(access = {}) ⇒ Object
Cancel envelope.
-
#date!(recipient, field, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#decline!(recipient, access = {}) ⇒ Object
Declines envelope.
-
#delegate_recipient!(old, new, access = {}) ⇒ Object
Delegates recipient to another one.
-
#fill_field!(value, field, document, recipient, options = {}, access = {}) ⇒ GroupDocs::Signature::Field
Fills field with value.
-
#get_envelope!(path, document, access = {}) ⇒ Object
Get signed envelope document.
-
#logs!(access = {}) ⇒ Array<GroupDocs::Signature::Envelope::Log>
Returns a list of audit logs.
-
#modify_field_location!(location, field, document, recipient, order, access = {}) ⇒ Object
Modify signature envelope field location.
-
#modify_recipient!(recipient, access = {}) ⇒ Object
Modify recipient of envelope.
-
#public_get!(recipient, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#public_signed_documents!(path, recipient, access = {}) ⇒ Array
Changed in release 1.5.8.
-
#restart!(access = {}) ⇒ Object
Restarts expired envelope.
-
#retry!(access = {}) ⇒ Object
Retry sign envelope.
-
#send!(webhook = {}, access = {}) ⇒ Object
Sends envelope.
-
#sign!(recipient, options = {}, access = {}) ⇒ Object
Signs envelope.
-
#signed_document!(document, path, access = {}) ⇒ String
Path to file.
-
#signed_documents!(path, access = {}) ⇒ String
Downloads signed documents to given path.
-
#update_envelope!(template, access = {}) ⇒ Array
Update envelope.
Methods included from ResourceMethods
Methods included from RecipientMethods
#recipients!, #remove_recipient!
Methods included from FieldMethods
#add_field!, #assign_field!, #delete_field!, #delete_field_location!, #fields!, #modify_field!
Methods included from EntityMethods
#create!, #delete!, included, #modify!, #rename!
Methods included from Api::Helpers::Accessor
Methods included from DocumentMethods
#add_document!, #documents!, #remove_document!, #rename_document!
Methods inherited from Api::Entity
#initialize, #inspect, #to_hash
Constructor Details
This class inherits a constructor from GroupDocs::Api::Entity
Instance Attribute Details
#creationDateTime ⇒ Object
86 87 88 |
# File 'lib/groupdocs/signature/envelope.rb', line 86 def creationDateTime @creationDateTime end |
#envelopeExpireTime ⇒ Object
92 93 94 |
# File 'lib/groupdocs/signature/envelope.rb', line 92 def envelopeExpireTime @envelopeExpireTime end |
#isDemo ⇒ Object
94 95 96 |
# File 'lib/groupdocs/signature/envelope.rb', line 94 def isDemo @isDemo end |
#status ⇒ Symbol
Converts status to human-readable format.
88 89 90 |
# File 'lib/groupdocs/signature/envelope.rb', line 88 def status @status end |
#statusDateTime ⇒ Object
90 91 92 |
# File 'lib/groupdocs/signature/envelope.rb', line 90 def statusDateTime @statusDateTime end |
Class Method Details
.all!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Envelope>
Returns a list of all envelopes.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/groupdocs/signature/envelope.rb', line 42 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}}/envelopes' end api.add_params() json = api.execute! json[:envelopes].map do |envelope| new(envelope) end end |
.for_me!(options = {}, access = {}) ⇒ Array<GroupDocs::Signature::Envelope>
Returns a list of all envelopes where user is recipient.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/groupdocs/signature/envelope.rb', line 71 def self.for_me!( = {}, access = {}) api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = '/signature/{{client_id}}/envelopes/recipient' end api.add_params() json = api.execute! json[:envelopes].map do |envelope| new(envelope) end end |
Instance Method Details
#add_recipient!(recipient, access = {}) ⇒ Object
Changed in release 1.5.8
Adds recipient to envelope.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/groupdocs/signature/envelope.rb', line 133 def add_recipient!(recipient, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient" end api.add_params(:email => recipient.email, :firstname => recipient.first_name, :lastname => recipient.last_name, :role => recipient.role_id, :order => recipient.order) json = api.execute! Signature::Recipient.new(json[:recipient]) end |
#archive!(access = {}) ⇒ Object
Archives completed envelope.
444 445 446 447 448 449 450 |
# File 'lib/groupdocs/signature/envelope.rb', line 444 def archive!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/archive" end.execute! end |
#cancel!(access = {}) ⇒ Object
Cancel envelope.
513 514 515 516 517 518 519 |
# File 'lib/groupdocs/signature/envelope.rb', line 513 def cancel!( access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/cancel" end.execute! end |
#date!(recipient, field, access = {}) ⇒ Array
Changed in release 1.5.8
Get signed envelope field data.
673 674 675 676 677 678 679 680 681 682 683 684 685 |
# File 'lib/groupdocs/signature/envelope.rb', line 673 def date!(recipient, field, access = {}) field.is_a?(GroupDocs::Signature::Field) or raise ArgumentError, "Field should be GroupDocs::Signature::Field object, received: #{field.inspect}" recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/envelopes/#{id}/fields/recipient/#{recipient.id}/field/#{field.id}" end.execute! end |
#decline!(recipient, access = {}) ⇒ Object
Declines envelope.
325 326 327 328 329 330 331 332 333 334 |
# File 'lib/groupdocs/signature/envelope.rb', line 325 def decline!(recipient, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}/decline" end.execute! end |
#delegate_recipient!(old, new, access = {}) ⇒ Object
Delegates recipient to another one.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/groupdocs/signature/envelope.rb', line 205 def delegate_recipient!(old, new, access = {}) old.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Old recipient should be GroupDocs::Signature::Recipient object, received: #{old.inspect}" new.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "New recipient should be GroupDocs::Signature::Recipient object, received: #{new.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{old.id}/delegate" end api.add_params(:email => new.email, :firstname => new.first_name, :lastname => new.last_name) api.execute! end |
#fill_field!(value, field, document, recipient, options = {}, access = {}) ⇒ GroupDocs::Signature::Field
Fills field with value.
Value differs depending on field type. See examples below.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/groupdocs/signature/envelope.rb', line 263 def fill_field!(value, field, document, recipient, = {}, 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}" recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" client_id = client_id([:public]) api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/#{client_id}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/field/#{field.id}" end type = field.field_type if type == :signature && value.is_a?(GroupDocs::Signature) api.add_params(:signatureId => value.id) else if type == :checkbox value = (value ? 'on' : 'off') end api.[:request_body] = value api.[:plain] = true end json = api.execute! Signature::Field.new(json[:field]) end |
#get_envelope!(path, document, access = {}) ⇒ Object
Get signed envelope document.
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/groupdocs/signature/envelope.rb', line 481 def get_envelope!(path, document, access = {}) document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" response = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}" 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 |
#logs!(access = {}) ⇒ Array<GroupDocs::Signature::Envelope::Log>
Returns a list of audit logs.
407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/groupdocs/signature/envelope.rb', line 407 def logs!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/{{client_id}}/envelopes/#{id}/logs" end.execute! json[:logs].map do |log| Log.new(log) end end |
#modify_field_location!(location, field, document, recipient, order, access = {}) ⇒ Object
Modify signature envelope field location.
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
# File 'lib/groupdocs/signature/envelope.rb', line 579 def modify_field_location!(location, field, document, recipient, order, 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}" recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/documents/#{document.file.guid}/recipient/#{recipient.id}/fields/#{field.id}/locations/#{location.id}" end api.add_params(:order => order) api.execute! end |
#modify_recipient!(recipient, access = {}) ⇒ Object
Modify recipient of envelope.
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/groupdocs/signature/envelope.rb', line 167 def modify_recipient!(recipient, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" api = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/recipient/#{recipient.id}" end api.add_params(:email => recipient.email, :firstname => recipient.first_name, :lastname => recipient.last_name, :role => recipient.role_id, :order => recipient.order) api.execute! end |
#public_get!(recipient, access = {}) ⇒ Array
Changed in release 1.5.8
Get signature envelope.
609 610 611 612 613 614 615 616 617 618 619 620 |
# File 'lib/groupdocs/signature/envelope.rb', line 609 def public_get!(recipient, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}" end.execute! Signature::Envelope.new(json[:envelope]) end |
#public_signed_documents!(path, recipient, access = {}) ⇒ Array
Changed in release 1.5.8
Public 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.
637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
# File 'lib/groupdocs/signature/envelope.rb', line 637 def public_signed_documents!(path, recipient, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" json = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/signature/public/envelopes/#{id}/recipient/#{recipient.id}/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(json) end filepath end |
#restart!(access = {}) ⇒ Object
Restarts expired envelope.
459 460 461 462 463 464 465 |
# File 'lib/groupdocs/signature/envelope.rb', line 459 def restart!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/restart" end.execute! end |
#retry!(access = {}) ⇒ Object
Retry sign envelope.
528 529 530 531 532 533 534 |
# File 'lib/groupdocs/signature/envelope.rb', line 528 def retry!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/retry" end.execute! end |
#send!(webhook = {}, access = {}) ⇒ Object
Sends envelope.
428 429 430 431 432 433 434 435 |
# File 'lib/groupdocs/signature/envelope.rb', line 428 def send!(webhook = {}, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/{{client_id}}/envelopes/#{id}/send" request[:request_body] = webhook end.execute! end |
#sign!(recipient, options = {}, access = {}) ⇒ Object
Signs envelope.
304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/groupdocs/signature/envelope.rb', line 304 def sign!(recipient, = {}, access = {}) recipient.is_a?(GroupDocs::Signature::Recipient) or raise ArgumentError, "Recipient should be GroupDocs::Signature::Recipient object, received: #{recipient.inspect}" client_id = client_id([:public]) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/signature/#{client_id}/envelopes/#{id}/recipient/#{recipient.id}/sign" end.execute! end |
#signed_document!(document, path, access = {}) ⇒ String
Returns path to file.
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/groupdocs/signature/envelope.rb', line 380 def signed_document!(document, path, access = {}) document.is_a?(GroupDocs::Document) or raise ArgumentError, "Document should be GroupDocs::Document object, received: #{document.inspect}" response = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/signature/{{client_id}}/envelopes/#{id}/document/#{document.file.guid}" end.execute! document.file.name ? filepath = "#{path}/#{document.file.name}" : filepath = "#{path}/#{name}.pdf" Object::File.open(filepath, 'wb') do |file| file.write(response) end filepath end |
#signed_documents!(path, access = {}) ⇒ String
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.
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/groupdocs/signature/envelope.rb', line 347 def signed_documents!(path, access = {}) response = Api::Request.new do |request| request[:access] = access request[:method] = :DOWNLOAD request[:path] = "/signature/{{client_id}}/envelopes/#{id}/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 |
#update_envelope!(template, access = {}) ⇒ Array
Update envelope.
544 545 546 547 548 549 550 551 552 553 |
# File 'lib/groupdocs/signature/envelope.rb', line 544 def update_envelope!(template, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/signature/{{client_id}}/envelopes/#{id}/templates/#{template}" end.execute! json[:envelope] end |