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 template form api document for more information about this.

Author:

  • hellosign

Instance Method Summary collapse

Instance Method Details

#add_user_to_template(opts) ⇒ Template

Gives the specified Account on your team access to a Template

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 id of the Template to give access to.

  • account_id (String)

    The id of the Account to get access. The account_id prevails if account_id and email_address are both provided.

  • email_address (String)

    The email address of the Account to give access to the Template. The account_id prevails if account_id and email_address are both provided.

Returns:



88
89
90
91
92
# File 'lib/hello_sign/api/template.rb', line 88

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 (Integer) — default: 0

    Whether this is a test, the signature request will not be legally binding if set to 1.

  • files (Array<String>)

    Use files to indicate the uploaded 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>)

    Use file_urls to have HelloSign 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 email subject.

  • subject (String)

    The subject in the email that will be sent to the signers.

  • requester_email_address (String)

    The email address of the requester.

  • message (String)

    The custom message in the email that will be sent to the signers.

  • signers (Array<Hash>)

    List of signer_roles, each item is a Hash with these keys:

    • :name (String) signer’s role name

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

  • cc_roles (Array<Hash>)

    The email addresses CC roles. Will mean the CC role will be Required when sending the template.

  • merge_fields (Array<Hash>)

    List of fields that can be pre-populated by your application when using the resulting template to send a signature request

    • :name (String) merge field name

    • :type (String) <text|checkbox>



154
155
156
157
158
159
# File 'lib/hello_sign/api/template.rb', line 154

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 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 id of the Template 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 id of the Template 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



161
162
163
# File 'lib/hello_sign/api/template.rb', line 161

def get_template_files(opts)
  get("/template/files/#{opts[:template_id]}")
end

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

Retrieves the Templates for the current user account.

Examples:

templates = @client.get_templates :page => 1

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • page (Integer) — default: 1

    Which page number of the Template List to return.

Returns:



70
71
72
73
74
75
# File 'lib/hello_sign/api/template.rb', line 70

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’s access to the specified Template. The user can be designated using their account ID or email address.

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 id of the Template to remove the Account access to.

  • account_id (String)

    The id of the Account to remove access to the Template. The account_id prevails if account_id and email_address are both provided.

  • email_address (String)

    The email address of the Account to remove access to the Template. The account_id prevails if account_id and email_address are both provided.

Returns:



105
106
107
108
109
# File 'lib/hello_sign/api/template.rb', line 105

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