Class: ZohoSign::Template::Document::CreateService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/zoho_sign/template/document/create_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, data:, is_quicksend: false) ⇒ CreateService



13
14
15
16
17
# File 'lib/zoho_sign/template/document/create_service.rb', line 13

def initialize(id:, data:, is_quicksend: false)
  @id           = id
  @data         = data
  @is_quicksend = is_quicksend
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



4
5
6
# File 'lib/zoho_sign/template/document/create_service.rb', line 4

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/zoho_sign/template/document/create_service.rb', line 4

def id
  @id
end

#is_quicksendObject (readonly)

Returns the value of attribute is_quicksend.



4
5
6
# File 'lib/zoho_sign/template/document/create_service.rb', line 4

def is_quicksend
  @is_quicksend
end

Instance Method Details

#callObject

Create a document from a template.

www.zoho.com/sign/api/template-managment/send-documents-using-template.html

Examples

service = ZohoSign::Template::Document::CreateService.call!(
  id: '',
  is_quicksend: true,
  data: {
    templates: {
      request_name: 'Request Document',
      field_data: {
        field_text_data: {
          'Full name' => 'Eric Cartman',
          'Email' => '[email protected]'
        },
        field_boolean_data: {
          'Agreed to terms' => true
        },
        field_date_data: {
          'Inception date' => '31/01/2025'
        }
      },
      actions: [{
        action_type: 'SIGN',
        recipient_email: '[email protected]',
        recipient_name: 'Eric Cartman',
        verify_recipient: false,
        delivery_mode: 'EMAIL',
        action_id: '',
        role: 'Client'
      }]
    }
  }
)

service.success? # => true
service.errors # => #<ActiveModel::Errors []>

service.response # => #<Faraday::Response ...>
service.response.status # => 200
service.response.body # => {}

service.facade # => #<ZohoSign::Temlate::Document::Facade ...>
service.facade.request_name
service.request_name

POST /api/v1/templates/:id/createdocument



68
69
70
# File 'lib/zoho_sign/template/document/create_service.rb', line 68

def call
  connection.post("templates/#{id}/createdocument", **params)
end