Class: HelloSign::Client

Inherits:
Object
  • Object
show all
Includes:
Api::Account, Api::ApiApp, Api::BulkSendJob, Api::Embedded, Api::OAuth, Api::SignatureRequest, Api::Team, Api::Template, Api::UnclaimedDraft
Defined in:
lib/hello_sign/client.rb

Overview

You’ll need the HelloSign::Client to do just about everything, from creating signatures to updating account information.

Author:

  • hellosign

Constant Summary collapse

ERRORS =
{
  400 => Error::BadRequest,
  401 => Error::Unauthorized,
  402 => Error::PaidApiPlanRequired,
  403 => Error::Forbidden,
  404 => Error::NotFound,
  405 => Error::MethodNotAllowed,
  409 => Error::Conflict,
  410 => Error::Gone,
  429 => Error::ExceededRate,
  500 => Error::InternalServerError,
  502 => Error::BadGateway,
  503 => Error::ServiceUnavailable
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Api::BulkSendJob

#get_bulk_send_job, #get_bulk_send_jobs

Methods included from Api::ApiApp

#create_api_app, #delete_api_app, #get_api_app, #get_api_apps, #update_api_app

Methods included from Api::OAuth

#get_oauth_token, #oauth_create_account, #oauth_url, #refresh_oauth_token

Methods included from Api::Embedded

#get_embedded_sign_url, #get_embedded_template_edit_url

Methods included from Api::UnclaimedDraft

#create_embedded_unclaimed_draft, #create_embedded_unclaimed_draft_with_template, #create_unclaimed_draft, #edit_and_resend_unclaimed_draft

Methods included from Api::Team

#add_member_to_team, #create_team, #destroy_team, #get_team, #remove_member_from_team, #update_team

Methods included from Api::Template

#add_user_to_template, #create_embedded_template_draft, #delete_template, #get_template, #get_template_files, #get_templates, #remove_user_from_template, #update_template_files

Methods included from Api::SignatureRequest

#bulk_send_with_template, #cancel_signature_request, #create_embedded_signature_request, #create_embedded_signature_request_with_template, #embedded_bulk_send_with_template, #get_signature_request, #get_signature_requests, #release_hold_signature_request, #release_on_hold_signature_request, #remind_signature_request, #remove_signature_request, #send_signature_request, #send_signature_request_with_template, #signature_request_files, #update_signature_request

Methods included from Api::Account

#create_account, #get_account, #update_account, #verify

Constructor Details

#initialize(opts = {}) ⇒ HelloSign::Client

Initiates a new HelloSign Client

Examples:

Authenticating with username and password

client = HelloSign::Client.new email_address: '[email protected]', password: 'mypassword'

Authenticating with API key

client = HelloSign::Client.new api_key: '1234567890123456789012345678901234567890123456789012345678901234'

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • email_address (String)

    The account’s email address. (optional)

  • password (String)

    The account’s password, if authenticating with an email_address. (optional)

  • api_key (String)

    The account’s API key.



79
80
81
82
83
84
# File 'lib/hello_sign/client.rb', line 79

def initialize(opts={})
  options = HelloSign.options.merge(opts)
  HelloSign::Configuration::VALID_OPTIONS_KEYS.each do |key|
    self.send("#{key}=", options[key])
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def api_key
  @api_key
end

#api_versionObject

Returns the value of attribute api_version.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def api_version
  @api_version
end

#auth_tokenObject

Returns the value of attribute auth_token.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def auth_token
  @auth_token
end

#client_idObject

Returns the value of attribute client_id.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def client_secret
  @client_secret
end

#email_addressObject

Returns the value of attribute email_address.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def email_address
  @email_address
end

#end_pointObject

Returns the value of attribute end_point.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def end_point
  @end_point
end

#log_levelObject

Returns the value of attribute log_level.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def log_level
  @log_level
end

#loggingObject

Returns the value of attribute logging.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def logging
  @logging
end

#oauth_end_pointObject

Returns the value of attribute oauth_end_point.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def oauth_end_point
  @oauth_end_point
end

#passwordObject

Returns the value of attribute password.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def password
  @password
end

#proxy_passObject

Returns the value of attribute proxy_pass.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def proxy_pass
  @proxy_pass
end

#proxy_uriObject

Returns the value of attribute proxy_uri.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def proxy_uri
  @proxy_uri
end

#proxy_userObject

Returns the value of attribute proxy_user.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def proxy_user
  @proxy_user
end

#timeoutObject

Returns the value of attribute timeout.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def timeout
  @timeout
end

#user_agentObject

Returns the value of attribute user_agent.



50
51
52
# File 'lib/hello_sign/client.rb', line 50

def user_agent
  @user_agent
end

Instance Method Details

#delete(path, options = {}) ⇒ Object

Makes an HTTP DELETE request

Parameters:

  • path (String)

    Relative path of the request.

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

    a customizable set of options

Options Hash (options):

  • Params (Hash)

    of the URL.



121
122
123
124
125
126
# File 'lib/hello_sign/client.rb', line 121

def delete(path, options={})
  response = request(path, :delete, options)
  validate response
  parsed_response = parse response
  data = { headers: response.headers, body: parsed_response }
end

#get(path, options = {}) ⇒ Object

Makes an HTTP GET request

Parameters:

  • path (String)

    Relative path of the request.

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

    a customizable set of options

Options Hash (options):

  • params (Hash)

    Params of the URL.



89
90
91
92
93
94
# File 'lib/hello_sign/client.rb', line 89

def get(path, options={})
  response = request(path, :get, options)
  validate response
  parsed_response = parse response
  data = { headers: response.headers, body: parsed_response }
end

#post(path, options = {}) ⇒ Object

Makes an HTTP POST request

Parameters:

  • path (String)

    Relative path of the request.

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

    a customizable set of options

Options Hash (options):

  • params (Hash)

    Params of the URL.

  • body (Hash)

    Body of the request.



100
101
102
103
104
105
# File 'lib/hello_sign/client.rb', line 100

def post(path, options={})
  response = request(path, :post, options)
  validate response
  parsed_response = parse response
  data = { headers: response.headers, body: parsed_response }
end

#put(path, options = {}) ⇒ Object

Makes an HTTP PUT request

Parameters:

  • path (String)

    Relative path of the request.

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

    a customizable set of options

Options Hash (options):

  • params (Hash)

    Params of the URL.

  • body (Hash)

    Body of the request.



111
112
113
114
115
116
# File 'lib/hello_sign/client.rb', line 111

def put(path, options={})
  response = request(path, :put, options)
  validate response
  responsed_response = parse response
  data = { headers: response.headers, body: parsed_response }
end