Class: ZohoSign::Document::CreateService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data:, file:, file_content_type:, file_name: nil) ⇒ CreateService

Returns a new instance of CreateService.



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

def initialize(data:, file:, file_content_type:, file_name: nil)
  @file              = file
  @file_content_type = file_content_type
  @file_name         = file_name
  @data              = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



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

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#file_content_typeObject (readonly)

Returns the value of attribute file_content_type.



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

def file_content_type
  @file_content_type
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



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

def file_name
  @file_name
end

Instance Method Details

#callObject

Create a document.

www.zoho.com/sign/api/document-managment/create-document.html

Examples

service = ZohoSign::Document::CreateService.call(
  file: '/path/to/file.pdf', # or File.open('/path/to/file.pdf')
  file_name: 'file.pdf',
  file_content_type: 'application/pdf',
  data: {
    requests: {
      request_name: 'Name',
      is_sequential: false,
      actions: [{
        action_type: 'SIGN',
        recipient_email: '[email protected]',
        recipient_name: 'Eric Cartman',
        verify_recipient: true,
        verification_type: 'EMAIL'
      }]
    }
  }
)

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

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

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

POST /api/v1/requests



56
57
58
# File 'lib/zoho_sign/document/create_service.rb', line 56

def call
  connection.post('requests', **params)
end