Module: HelloSign::Api::Template

Included in:
Client
Defined in:
lib/hello_sign/api/template.rb

Overview

Contains all the API calls for the Template resource. Take a look at our API Documentation for Templates (app.hellosign.com/api/reference#Template) for more information about this.

Author:

  • hellosign

Instance Method Summary collapse

Instance Method Details

#add_user_to_template(opts) ⇒ Template

Gives the specified Account access to a Template. The Account must be part of your Team.

Note: The account_id prevails if both email_address and acccount_id are provided.

Examples:

templates = @client.add_user_to_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => '[email protected]'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to give access to.

  • account_id (String)

    The Account ID to receive access to the Template.

  • email_address (String)

    The email address of the Account to receive access to the Template.

Returns:



92
93
94
95
96
# File 'lib/hello_sign/api/template.rb', line 92

def add_user_to_template(opts)
  path = "/template/add_user/#{opts[:template_id]}"
  opts.delete(:template_id)
  HelloSign::Resource::Template.new post(path, :body => opts)
end

#create_embedded_template_draft(opts) ⇒ Object

Creates a new embedded template draft object that can be launched in an iFrame using the claim_url.

Examples:

create_embedded_draft

template_draft = @client.create_embedded_template_draft(
  :test_mode => 1,
  :subject => 'The NDA we talked about',
  :requester_email_address => [email protected]",
  :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.',
  :signer_roles => [{
      :name => 'Manager',
      :order => 0
    },{
      :name => 'Client',
      :order => 1
    }
  ],
  :cc_roles => ['HRManager'],
  :files => ['NDA.pdf', 'AppendixA.pdf'],
  :merge_fields => '[{
      :name => 'contract_id',
      :type => 'text'
    },{
      :name => 'purchase_price',
      :order => 'text'
    }
  ]'
)

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • test_mode (Boolean)

    Indicates if this is a test Template draft. SignatureRequests using this Template will not be legally binding if set to 1. Defaults to 0. (optional)

  • client_id (String)

    The API App Client ID associated with the Template draft. (optional)

  • files (Array<String>)

    Specified file path(s) to upload file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.

  • file_urls (Array<String>)

    URL(s) for HelloSign to download the file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.

  • title (String)

    The default Template title. (optional)

  • subject (String)

    The default Template title alias. (optional)

  • message (String)

    The default message in the email that will be sent to the signer(s). (optional)

  • signers (Array<Hash>)

    List of signers displayed when the Template is used to create a SignatureRequest

    • :name (String) Signer role name

    • :order (Integer) The order the signer role is required to sign in. (optional)

  • cc_roles (Array<Hash>)

    The CC roles that must be assigned when using the Template to create a SignatureRequest. (optional)

  • merge_fields (String<Array><Hash>)

    List of fields that can be pre-populated by your application when using the Template to send a SignatureRequest. (optional)

    • :name (String) Merge field name

    • :type (String) Field type - either “text” or “checkbox”

  • skip_me_now (Boolean)

    Sets the “Me (Now)” option for the Template preparer. Defaults to 0. (optional)

  • use_preexisting_fields (Boolean)

    Sets the detection of predefined PDF fields. Defaults to 0. (optional)

  • metadata (Hash)

    Key-value data attached to the Template and all SignatureRequests created from the Template. (optional)

  • allow_reassign (Boolean)

    Sets the ability for signers to reassign the SignatureRequest to other signers. Defaults to 0. (optional)



163
164
165
166
167
168
# File 'lib/hello_sign/api/template.rb', line 163

def create_embedded_template_draft(opts)
  opts[:client_id] ||= self.client_id
  prepare_files opts
  prepare_signer_roles opts
  HelloSign::Resource::TemplateDraft.new post("/template/create_embedded_draft", :body => opts)
end

#delete_template(opts) ⇒ Object

Deletes the specified Template.

Examples:

template = @client.delete_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to delete.



57
58
59
# File 'lib/hello_sign/api/template.rb', line 57

def delete_template(opts)
  post("/template/delete/#{opts[:template_id]}")
end

#get_template(opts) ⇒ HelloSign::Resource::Template

Retrieves the Template specified by the id parameter.

Examples:

template = @client.get_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to retrieve.

Returns:



46
47
48
# File 'lib/hello_sign/api/template.rb', line 46

def get_template(opts)
  HelloSign::Resource::Template.new get("/template/#{opts[:template_id]}")
end

#get_template_files(opts) ⇒ Object

Downloads the original files of a specified Template.

Examples:

templates = @client.get_template_files :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :file_type => 'zip'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to retrieve.

  • file_type (String)

    Determines the format of the file - either ‘pdf’ or ‘zip’ depending on the file type desired. Defaults to pdf. (optional)

  • get_url (Boolean)

    Response contains a URL link to the file if set to true. Links are only available for PDFs and have a TTL of 3 days. Defaults to false. (optional)

Returns:

  • a PDF or Zip



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/hello_sign/api/template.rb', line 181

def get_template_files(opts)
  path = "/template/files/#{opts[:template_id]}"
  if opts[:file_type]
    path = path + "?file_type=#{opts[:file_type]}"
  end
  if opts[:get_url]
    separator = opts[:file_type].nil? ? '?' : '&'
    path = path + "#{separator}get_url=#{opts[:get_url]}"
  end

  get(path)
end

#get_templates(opts = {}) ⇒ HelloSign::Resource::ResourceArray

Retrieves the Templates for the accessible by the current user.

Examples:

templates = @client.get_templates :page => 1

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • acount_id (String)

    The Account ID to return Templates for and must be a team member. Use “all” for all team members. Defaults to current account. (optional)

  • page (Integer)

    Sets the page number of the list to return. Defaults to 1. (optional)

  • page_size (Integer)

    Determines the number of Templates returned per page. Defaults to 20. (optional)

  • query (String)

    Search terms and/or fields to filter the Templates. (optional)

Returns:



73
74
75
76
77
78
# File 'lib/hello_sign/api/template.rb', line 73

def get_templates(opts={})
  path = '/template/list'
  path += opts[:page] ? "?page=#{opts[:page]}" : ''
  path += opts[:page_size] ? "&page_size=#{opts[:page_size]}" : ''
  HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template
end

#remove_user_from_template(opts) ⇒ Template

Removes the specified Account access to the specified Template.

Note: The account_id prevails if both email_address and acccount_id are provided.

Examples:

templates = @client.remove_user_from_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => '[email protected]'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to remove access to.

  • account_id (String)

    The Account ID to remove access to the Template.

  • email_address (String)

    The email address of the Account to remove access to the Template.

Returns:



110
111
112
113
114
# File 'lib/hello_sign/api/template.rb', line 110

def remove_user_from_template(opts)
  path = "/template/remove_user/#{opts[:template_id]}"
  opts.delete(:template_id)
  HelloSign::Resource::Template.new post(path, :body => opts)
end

#update_template_files(opts) ⇒ Object

Overlays a new file with the overlay of the specified Template.

Examples:

templates = @client.update_template_files :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :file => '@NDA.pdf'

Parameters:

  • opts (Hash)

    a customizable set of options

Options Hash (opts):

  • template_id (String)

    The Template ID to update.

  • files (Array<String>)

    Specified file path(s) to upload file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.

  • file_urls (Array<String>)

    URL(s) for HelloSign to download the file(s) to send for signature. Currently we only support use of either the files parameter or file_urls parameter, not both.

  • subject (String)

    The updated default Template title alias. (optional)

  • message (String)

    The updated default message in the email that will be sent to the signer(s). (optional)

  • client_id (String)

    The API App Client ID associated with the Template draft. (optional)

  • test_mode (Boolean)

    Indicates if this is a test Template draft. SignatureRequests using this Template will not be legally binding if set to 1. Defaults to 0. (optional)

Returns:

  • a Template ID



209
210
211
212
213
214
# File 'lib/hello_sign/api/template.rb', line 209

def update_template_files(opts)
  template_id = opts.delete(:template_id)
  path = "/template/update_files/#{template_id}"
  prepare_files opts
  HelloSign::Resource::Template.new post(path, :body => opts)
end