diff --git a/README.md b/README.md index 638a211..6f70782 100644 --- a/README.md +++ b/README.md @@ -40,12 +40,12 @@ my_account = HelloSign.get_account my_signature_requests = HelloSign.get_signature_requests # view a specific signature request -signature_request = HelloSign.get_signature_request :signature_request_id => '42383e7327eda33f4b8b91217cbe95408cc1285f' +signature_request = HelloSign.get_signature_request signature_request_id: '42383e7327eda33f4b8b91217cbe95408cc1285f' ``` If you need to authenticate for multiple users and you want a separated client for them, you can run: ```ruby -client2 = HelloSign::Client.new :api_key => 'your_user_api_key' +client2 = HelloSign::Client.new api_key: 'your_user_api_key' user_account = client2.get_account ``` ### Specifying files diff --git a/lib/hello_sign.rb b/lib/hello_sign.rb index 0f2e870..a26f47e 100644 --- a/lib/hello_sign.rb +++ b/lib/hello_sign.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# require 'hello_sign/version' require 'hello_sign/configuration' @@ -28,21 +26,18 @@ module HelloSign extend Configuration - # - # # If HelloSign module doesn't respond to method, then delegates it to HelloSign::Client - # @param method [Symbol] method name - # @param *args [Array] arguments passed into the method - # @param &block [Block] a block passed into the method - # + + # If HelloSign module doesn't respond to method, then delegates it to HelloSign::Client + # @param method [Symbol] method name + # @param *args [Array] arguments passed into the method + # @param &block [Block] a block passed into the method def self.method_missing(method, *args, &block) return super unless client.respond_to?(method) client.send(method, *args, &block) end - # - # If HelloSign module don't respond to method, asks HelloSign::Client whether it responded or not - # @param method [Symbol] method name - # + # If HelloSign module doesn't respond to method, asks HelloSign::Client whether it responded or not + # @param method [Symbol] method name def self.respond_to?(method, include_all=false) return super || client.respond_to?(method) end diff --git a/lib/hello_sign/api.rb b/lib/hello_sign/api.rb index 4859eec..da5b276 100644 --- a/lib/hello_sign/api.rb +++ b/lib/hello_sign/api.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# require 'hello_sign/api/account' require 'hello_sign/api/embedded' @@ -30,3 +28,4 @@ require 'hello_sign/api/unclaimed_draft' require 'hello_sign/api/oauth' require 'hello_sign/api/api_app' +require 'hello_sign/api/bulk_send_job' diff --git a/lib/hello_sign/api/account.rb b/lib/hello_sign/api/account.rb index 62a4434..0281f60 100644 --- a/lib/hello_sign/api/account.rb +++ b/lib/hello_sign/api/account.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,71 +19,59 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - - # # Contains all the API calls for the Account resource. # Take a look at our API Documentation on the Account resource (https://app.hellosign.com/api/reference#Account) # for more information about this. # # @author [hellosign] - # + module Account - # + # Returns the current user's account information. # - # @return [HelloSign::Resource::Account] current user's account + # @return [HelloSign::Resource::Account] Current user's Account # # @example # account = @client.get_account - # def get_account HelloSign::Resource::Account.new get('/account') end - # - # Creates a new HelloSign account. The user will still need to confirm the email address + # Creates a new HelloSign account. The user will need to confirm the email address # to complete the creation process. - # - # Note: This request does not require authentication. - # # @option opts [String] email_address New user's email address # - # @return [HelloSign::Resource::Account] New user's account information + # @return [HelloSign::Resource::Account] New user's Account # # @example - # account = @client.create_account :email_address => 'newuser@example.com' - # + # account = @client.create_account email_address: 'newuser@example.com' def create_account(opts) - HelloSign::Resource::Account.new post('/account/create', :body => opts) + HelloSign::Resource::Account.new post('/account/create', body: opts) end + # Updates the current user's Account Callback URL. + # @option opts [String] callback_url New callback URL # - # Updates the current user's callback URL - # @option opts [String] callback_url New user's callback url - # - # @return [HelloSign::Resource::Account] Updated user's account information + # @return [HelloSign::Resource::Account] Updated Account # # @example - # account = @client.update_account :callback_url => 'https://www.example.com/callback' - # + # account = @client.update_account callback_url: 'https://www.example.com/callback' def update_account(opts) - HelloSign::Resource::Account.new post('/account', :body => opts) + HelloSign::Resource::Account.new post('/account', body: opts) end - # - # Check whether an account exists - # @option opts [String] email_address user email + # Checks whether an Account exists + # @option opts [String] email_address User's email address # # @return [Bool] true if exists, else false - # @example - # account = @client.verify :email_address => 'newuser@example.com' # + # @example + # account = @client.verify email_address: 'newuser@example.com' def verify(opts) - post('/account/verify', :body => opts).empty? ? false : true + post('/account/verify', body: opts).empty? ? false : true end end end diff --git a/lib/hello_sign/api/api_app.rb b/lib/hello_sign/api/api_app.rb index 880585a..474f0cf 100644 --- a/lib/hello_sign/api/api_app.rb +++ b/lib/hello_sign/api/api_app.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,42 +19,36 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - # # Contains all the API calls for the ApiApp resource. - # Take a look at our API Documentation for ApiApps (https://app.hellosign.com/api/reference#ApiApp) + # Take a look at our API Documentation on ApiApps (https://app.hellosign.com/api/reference#ApiApp) # for more information about this. # # @author [hellosign] - # + module ApiApp - # - # Retrieves information about a specific API App by a given ID + # Retrieves an ApiApp with a given ID # @option opts [String] client_id The Client ID of the ApiApp. # - # @return [HelloSign::Resource::ApiApp] the ApiApp + # @return [HelloSign::Resource::ApiApp] # # @example - # app = @client.get_api_app :client_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967' - # + # app = @client.get_api_app client_id: 'fa5c8a0b0f492d768749333ad6fcc214c111e967' def get_api_app(opts) HelloSign::Resource::ApiApp.new get("/api_app/#{opts[:client_id]}") end - # - # Returns a list of ApiApps that you currently have access to on your account + # Returns a list of ApiApps that your Account can access. # @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional) # @option opts [Integer] page_size Determines the number of ApiApps returned per page. Defaults to 20. (optional) # # @return [HelloSign::Resource::ResourceArray] # # @example - # apps = @client.get_api_apps :page => 1 - # + # apps = @client.get_api_apps page: 1 def get_api_apps(opts={}) path = '/api_app/list' path += opts[:page] ? "?page=#{opts[:page]}" : '' @@ -63,8 +56,7 @@ def get_api_apps(opts={}) HelloSign::Resource::ResourceArray.new get(path, opts), 'api_apps', HelloSign::Resource::ApiApp end - # - # Creates a new API Application on your account + # Creates a new ApiApp on your Account # @option opts [String] name The name assigned to the ApiApp. # @option opts [String] domain The domain associated with the ApiApp. # @option opts [String] callback_url The URL that will receive callback events for the ApiApp. (optional) @@ -74,16 +66,20 @@ def get_api_apps(opts={}) # @option opts [String] white_labeling_options Object with elements and values serialized to a string to customize the signer page, if available in the API subscription. (optional) # @option opts [Boolean] options[can_insert_everywhere] Determines if signers can "Insert Everywhere" when signing a document. (optional) # - # @return [HelloSign::Resource::ApiApp] newly created ApiApp object + # @return [HelloSign::Resource::ApiApp] newly created ApiApp # # @example - # app = @client.create_api_app :name => 'My Production App', :domain => 'example.com', :'oauth[callback_url]' => 'https://example.com/oauth', 'oauth[scopes]' => 'basic_account_info,request_signature' + # app = @client.create_api_app( + # name: 'My Production App', + # domain: 'example.com', + # 'oauth[callback_url]': 'https://example.com/oauth', + # 'oauth[scopes]': 'basic_account_info,request_signature' + # ) def create_api_app(opts) - HelloSign::Resource::ApiApp.new post('/api_app', :body => opts) + HelloSign::Resource::ApiApp.new post('/api_app', body: opts) end - # - # Updates settings for a specific ApiApp on your account + # Updates the ApiApp settings. # @option opts [String] client_id The Client ID of the ApiApp you want to update. # @option opts [String] name The name assigned to the ApiApp. (optional) # @option opts [String] domain The domain associated with the ApiApp. (optional) @@ -97,19 +93,25 @@ def create_api_app(opts) # @return [HelloSign::Resource::ApiApp] an ApiApp object # # @example - # app = @client.update_api_app :name => 'My Newly Renamed App', :domain => 'example2.com', :'oauth[callback_url]' => 'https://example2.com/oauth', 'oauth[scopes]' => 'basic_account_info,request_signature' + # app = @client.update_api_app( + # name: 'My Newly Renamed App', + # domain: 'example2.com', + # 'oauth[callback_url]': 'https://example2.com/oauth', + # 'oauth[scopes]': 'basic_account_info, request_signature' + # ) def update_api_app(opts) id = opts.delete(:client_id) path = '/api_app/' + id - HelloSign::Resource::ApiApp.new post(path, :body => opts) + HelloSign::Resource::ApiApp.new post(path, body: opts) end - # # Deletes an ApiApp. Only available for ApiApps you own. # @option opts [String] client_id The Client ID of the ApiApp you want to delete. # + # @return [HTTP::Status] 204 No Content + # # @example - # result = @client.delete_api_app :client_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967' + # response = @client.delete_api_app client_id: 'fa5c8a0b0f492d768749333ad6fcc214c111e967' def delete_api_app(opts) path = '/api_app/' + opts[:client_id] delete(path) diff --git a/lib/hello_sign/api/bulk_send_job.rb b/lib/hello_sign/api/bulk_send_job.rb new file mode 100644 index 0000000..9182d78 --- /dev/null +++ b/lib/hello_sign/api/bulk_send_job.rb @@ -0,0 +1,62 @@ +# The MIT License (MIT) +# +# Copyright (C) 2014 hellosign.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +module HelloSign + module Api + # Contains all the API calls for the BulkSendJob resource. + # Take a look at our API Documentation on BulkSendJobs (https://app.hellosign.com/api/reference#BulkSendJob) + # for more information about this. + # + # @author [hellosign] + + module BulkSendJob + + # Retrieves a BulkSendJob with a given ID + # @option opts [String] bulk_send_job_id The BulkSendJob ID to retrieve. + # + # @return [HelloSign::Resource::BulkSendJob] + # + # @example + # bulk_send_job = @client.get_bulk_send_job bulk_send_job_id: 'af299494bdcad318b4856aa34aa263dbdaaee9ab' + def get_bulk_send_job(opts) + path = "/bulk_send_job/#{opts[:bulk_send_job_id]}" + + HelloSign::Resource::BulkSendJob.new get(path) + end + + # Returns a list of BulkSendJobs that your Account can access. + # @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional) + # @option opts [Integer] page_size Determines the number of BulkSendJobs returned per page. Defaults to 20. (optional) + # + # @return [HelloSign::Resource::ResourceArray] + # + # @example + # bulk_send_jobs = @client.get_bulk_send_jobs page: 1 + def get_bulk_send_jobs(opts={}) + path = '/bulk_send_job/list' + path += opts[:page] ? "?page=#{opts[:page]}" : '' + path += opts[:page_size] ? "&page_size=#{opts[:page_size]}" : '' + HelloSign::Resource::ResourceArray.new get(path, opts), 'bulk_send_jobs', HelloSign::Resource::BulkSendJob + end + end + end +end diff --git a/lib/hello_sign/api/embedded.rb b/lib/hello_sign/api/embedded.rb index 0dc586a..1dd9929 100644 --- a/lib/hello_sign/api/embedded.rb +++ b/lib/hello_sign/api/embedded.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,54 +19,49 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - # - # HelloSign allows you to embed the signing page on your site in an iFrame - # without the need for the signer/preparer to create a HelloSign account. + # Contains all the API calls for Embedded SignatureRequests. # Take a look at our Embedded Signing Walkthrough (https://app.hellosign.com/api/embeddedSigningWalkthrough) # for more information about this. # # @author [hellosign] - # + module Embedded - # - # Retrieves the embedded signature sign_url. - # + # Retrieves the sign_url for an Embedded SignatureRequest. # @option opts [String] signature_id The Signature ID to retrieve the embedded sign_url for. # - # @return [HelloSign::Resource::Embedded] Returns an Embedded object - # @example - # embedded = @client.get_embedded_sign_url :signature_id => '50e3542f738adfa7ddd4cbd4c00d2a8ab6e4194b' + # @return [HelloSign::Resource::Embedded] # + # @example + # embedded = @client.get_embedded_sign_url signature_id: '50e3542f738adfa7ddd4cbd4c00d2a8ab6e4194b' def get_embedded_sign_url(opts) HelloSign::Resource::Embedded.new get("/embedded/sign_url/#{opts[:signature_id]}") end - # - # Retrieves the edit_url for an embedded template. - # @option opts [Boolean] test_mode Indicates if this is a test Embedded Template. A boolean value is also accepted. Defaults to 0. (optional) - # @option opts [String] template_id The Template ID to retreive the embedded edit_url for. + + # Retrieves the edit_url for an Embedded Template. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [String] template_id The Template ID to retrieve the embedded edit_url for. # @option opts [Array] cc_roles The CC roles that must be assigned when using the Embedded Template to create a SignatureRequest. (optional) # @option opts [String] merge_fields List of fields that can be pre-populated by your application when using the Embedded Template to send a SignatureRequest. (optional) - # * :name (String) Merge field name - # * :type (String) Field type - either "text" or "checkbox" + # * name (String) Merge field name + # * type (String) Field type - either "text" or "checkbox" # @option opts [Boolean] skip_signer_roles Removes the prompt to edit signer roles, if already provided. Defaults to 0. (optional) # @option opts [Boolean] skip_subject_message Removes the prompt to edit the subject and message, if already provided. Defaults to 0. (optional) # - # @return [HelloSign::Resource::Embedded] Returns an Embedded object - # @example - # edit_url = @client.get_embedded_template_edit_url :template_id => '39e3387f738adfa7ddd4cbd4c00d2a8ab6e4194b' + # @return [HelloSign::Resource::Embedded] # + # @example + # edit_url = @client.get_embedded_template_edit_url template_id: '39e3387f738adfa7ddd4cbd4c00d2a8ab6e4194b' def get_embedded_template_edit_url(opts) - defaults = { :skip_signer_roles => 0, :skip_subject_message => 0, :test_mode => 0 } + defaults = { skip_signer_roles: 0, skip_subject_message: 0, test_mode: 0 } opts = defaults.merge(opts) prepare_merge_fields opts - HelloSign::Resource::Embedded.new post("/embedded/edit_url/#{opts[:template_id]}", :body => opts) + HelloSign::Resource::Embedded.new post("/embedded/edit_url/#{opts[:template_id]}", body: opts) end end end diff --git a/lib/hello_sign/api/oauth.rb b/lib/hello_sign/api/oauth.rb index 12cdcf3..26cc93e 100644 --- a/lib/hello_sign/api/oauth.rb +++ b/lib/hello_sign/api/oauth.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,83 +19,76 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - - # + # Contains all the API calls for OAuth workflows. # OAuth allows you to perform actions on behalf of other users after they grant you the authorization to do so. - # For example, you could send signature requests on behalf of your users. - # For more information, see our OAuth API documentation (https://app.hellosign.com/api/oauthWalkthrough). - # - # IMPORTANT: With some OAuth scopes, you (the app owner) will be charged for all signature requests sent on behalf of other users via your app. + # See our OAuth API documentation (https://app.hellosign.com/api/oauthWalkthrough) for more information. # # @author [hellosign] - # + module OAuth - # - # Returns the OAuth URL where users can give permission for your application to perform actions on their behalf. - # - # @param state [String] used for security and must match throughout the flow for a given user. + # Returns the OAuth URL where users can authorize your application to perform actions on their behalf. + # @param state [String] Random security value that must match throughout the user's flow. # It can be set to the value of your choice (preferably something random). You should verify it matches the expected value when validating the OAuth callback. - # @return [type] [description] def oauth_url(state) "#{self.oauth_end_point}/oauth/authorize?response_type=code&client_id=#{self.client_id}&state=#{state}" end - # # Retrieves the OAuth token - # - # @option opts [String] state Random value that was used when you created oauth_url for a specific user. + # @option opts [String] state Random security value that was used when you created oauth_url for a specific user. # @option opts [String] code The code passed to your callback when the user granted access. - # @option opts [String] client_id The API App Client ID. - # @option opts [String] client_secret The secret token of your API App. + # @option opts [String] client_id The ApiApp Client ID. + # @option opts [String] client_secret The secret token of your ApiApp. # # @return [Hash] OAuth data of the user # # @example - # client = HelloSign::Client.new :api_key => '%apikey%', :client_id => 'cc91c61d00f8bb2ece1428035716b', :client_secret => '1d14434088507ffa390e6f5528465' - # client.get_oauth_token :state => '900e06e2', :code =>'1b0d28d90c86c141' + # client = HelloSign::Client.new( + # api_key: '%apikey%', + # client_id: 'cc91c61d00f8bb2ece1428035716b', + # client_secret: '1d14434088507ffa390e6f5528465' + # ) + # client.get_oauth_token( + # state: '900e06e2', + # code:'1b0d28d90c86c141' + # ) def get_oauth_token(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret opts[:grant_type] = 'authorization_code' - post('/oauth/token', { :body => opts, :oauth_request => true }) + post('/oauth/token', { body: opts, oauth_request: true }) end - # # Refreshes the user's OAuth token. - # - # @option opts [String] refresh_token The refresh provided when the access token has expired. + # @option opts [String] refresh_token The token provided when the access token has expired. # # @return [Hash] Refreshed OAuth info # # @example - # client.refresh_oauth_token :refresh_token => 'hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3' + # client.refresh_oauth_token refresh_token: 'hNTI2MTFmM2VmZDQxZTZjOWRmZmFjZmVmMGMyNGFjMzI2MGI5YzgzNmE3' def refresh_oauth_token(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret opts[:grant_type] = 'refresh_token' - post('/oauth/token', { :body => opts, :oauth_request => true }) + post('/oauth/token', { body: opts, oauth_request: true }) end - # - # Create new user and get their OAuth token. The user will receive an email asking them to confirm the access being granted. + # Creates a new user and retrieves the OAuth token. The user will receive an email asking them to confirm the access being granted. # Your app will not be able to perform actions on behalf of this user until they confirm. + # @option opts [String] email_address New user's email address. # - # @option opts [String] email_address New user email address. + # @return [Hash] details about new user, including OAuth data # # @example - # client.oauth_create_account :email_address => 'new_user@example.com' - # - # @return [Hash] details about new user, including OAuth data + # client.oauth_create_account email_address: 'new_user@example.com' def oauth_create_account(opts) opts[:client_id] = self.client_id opts[:client_secret] = self.client_secret - HelloSign::Resource::Account.new post('/account/create', { :body => opts }) + HelloSign::Resource::Account.new post('/account/create', { body: opts }) end end end diff --git a/lib/hello_sign/api/signature_request.rb b/lib/hello_sign/api/signature_request.rb index 4c014f1..99a3549 100644 --- a/lib/hello_sign/api/signature_request.rb +++ b/lib/hello_sign/api/signature_request.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,48 +19,43 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - - # # Contains all the API calls for the SignatureRequest resource. - # Take a look at our API Documentation for sending Signature Requests (https://app.hellosign.com/api/reference#SignatureRequest) + # Take a look at our API Documentation on Signature Requests (https://app.hellosign.com/api/reference#SignatureRequest) # for more information about this. # # @author [hellosign] - # + module SignatureRequest + # Retrieves a SignatureRequest with the given ID. + # @option opts [String] signature_request_id The ID of the SignatureRequest to retrieve. # - # Retrieves a Signature Request with the given ID. - # @option opts [String] signature_request_id The id of the SignatureRequest to retrieve. - # - # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest object + # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest # # @example - # signature_request = @client.get_signature_request :signature_request_id => 'fa5c8a0b0f492d768749333ad6fcc214c111e967' - # + # signature_request = @client.get_signature_request signature_request_id: 'fa5c8a0b0f492d768749333ad6fcc214c111e967' def get_signature_request(opts) - path = "/signature_request/#{opts[:signature_request_id]}" - query = create_query_string(opts, [:ux_version]) - path += query + path = "/signature_request/#{opts[:signature_request_id]}" + HelloSign::Resource::SignatureRequest.new get(path) end - # - # Returns a list of SignatureRequests that you can access. This includes SignatureRequests you have sent as well as received, but not ones that you have been CC'd on. + # Returns a list of send and received SignatureRequests that you can access. This does not include ones that you have been CC'd on. # @option opts [String] account_id Indicates which account to return SignatureRequests for. Defaults to your account. (optional) # @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional) # @option opts [Integer] page_size Determines the number of SignatureRequests returned per page. Defaults to 20. (optional) - # @option opts [String] query Search terms and/or fields to filter the SignatureRequests. (optional) + # @option opts [String] query Filters the SignatureRequests based on the search parameters. (optional) # # @return [HelloSign::Resource::ResourceArray] # # @example - # signature_requests = @client.get_signature_requests :page => 1 - # + # signature_requests = @client.get_signature_requests( + # page: 1, + # query: "to:jack@example.com+AND+client_id:b6b8e7deaf8f0b95c029dca049356d4a2cf9710a" + # ) def get_signature_requests(opts={}) path = '/signature_request/list' opts[:query] = create_search_string(opts[:query]) if opts[:query] @@ -70,27 +64,29 @@ def get_signature_requests(opts={}) HelloSign::Resource::ResourceArray.new get(path, opts), 'signature_requests', HelloSign::Resource::SignatureRequest end - # # Creates and sends a new SignatureRequest with the submitted documents. - # If form_fields_per_document is not specified or use_text_tags is not enabled, a signature page will be affixed at the end - # and all signers will be required to add their signature there. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) - # @option opts [Array] files 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. - # @option opts [Array] file_urls 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. - # @option opts [String] title The title you want to assign to the SignatureRequest. (optional) - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [String] signing_redirect_url The URL you want the signer(s) redirected to after they successfully sign. (optional) - # @option opts [Array] signers List of signers, each item is a Hash with these keys: - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :order (Integer) The order the signers are required to sign in (optional) - # * :pin (Integer) The 4- to 12-character access code that will secure this signer's signature page. You must have a business plan to use this feature. (optional) + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [Array] files Specifies the file path(s) to send for the SignatureRequest. + # @option opts [Array] file_urls Specifies the URL(s) for the file(s) to send for the SignatureRequest. + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) + # @option opts [Array] signers Sets a list of signers, each item is a Hash with these keys: + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * order (Integer) The order the signers are required to sign in (optional) + # * pin (Integer) Secures the SignatureRequest using this 4-12 character access code. A business plan is required to use this feature. (optional) + # @option opts [Array] attachments Sets a list of attachments signers can upload + # * name (String) Attachment name + # * instructions (String) Instructions for uploading the attachment. (optional) + # * signer_index (Integer) The signer's unique number. + # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional) # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. - # * :editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) - # * :required (Boolean) Determines if the field is required or not. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # * editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) + # * required (Boolean) Determines if the field is required or not. (optional) # @option opts [Array] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional) # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional) # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional) @@ -99,156 +95,157 @@ def get_signature_requests(opts={}) # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional) # @option opts [Array] form_fields_per_document The fields that should appear on the document. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest # # @example # signature_request = @client.send_signature_request( - # :test_mode => 1, - # :allow_decline => 1, - # :title => 'NDA with Acme Co.', - # :subject => 'The NDA we talked about', - # :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # allow_decline: 1, + # title: 'NDA with Acme Co.', + # subject: 'The NDA we talked about', + # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [{ - # :email_address => 'jack@example.com', - # :name => 'Jack', - # :order => 0, - # },{ - # :email_address => 'jill@example.com', - # :name => 'Jill', - # :order => 1, + # signers: [{ + # email_address: 'jack@example.com', + # name: 'Jack', + # order: 0, + # }, + # { + # email_address: 'jill@example.com', + # name: 'Jill', + # order: 1, + # }], + # attachments: [{ + # name: 'Passport', + # instructions: 'Upload your US Passport', + # signer_index: 0, + # required: true + # }, + # { + # name: 'Driver's License', + # instructions: 'Upload your CA Driver's License', + # signer_index: 1, + # required: false # } # ], - # :cc_email_addresses => ['lawyer@example.com', 'lawyer@example2.com'], - # :files => ['NDA.pdf', 'AppendixA.pdf'], - # :form_fields_per_document => [ - # [ - # { - # "name": "address", - # "type": "text", - # "x": 160, - # "y": 80, - # "width": 206, - # "height": 32, - # "signer": 0 - # } - # ], - # [ - # { - # "name": "phone", - # "type": "text", - # "x": 160, - # "y": 150, - # "width": 206, - # "height": 32, - # "signer": 1 - # } - # ] - # ] - # ) - # - + # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'], + # files: ['NDA.pdf', 'AppendixA.pdf'], + # form_fields_per_document: [ + # [ + # { + # name: 'address', + # type: 'text', + # x: 160, + # y: 80, + # width: 206, + # height: 32, + # signer: 0 + # } + # ], + # [ + # { + # name: 'phone', + # type: 'text', + # x: 160, + # y: 150, + # width: 206, + # height: 32, + # signer: 1 + # } + # ] + # ], + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } + # ) def send_signature_request(opts) prepare_files opts prepare_signers opts prepare_form_fields opts prepare_custom_fields opts + prepare_attachments opts - request = HelloSign::Resource::SignatureRequest.new post('/signature_request/send', :body => opts) + request = HelloSign::Resource::SignatureRequest.new post('/signature_request/send', body: opts) end - # # Creates and sends a new SignatureRequest based off of the Template specified with the template_id parameter. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [String] template_id The Template ID to use when creating the SignatureRequest. # * Use template_ids[%i%] if using multiple templates, replacing %i% with an integer to indicate the order of the Templates - # @option opts [String] title The title you want to assign to the SignatureRequest. (optional) - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [String] signing_redirect_url The URL you want the signer(s) redirected to after they successfully sign. (optional) - # @option opts [Array] signers List of signers - # * :role (String) The signer role indicated on the Template. Note that the role name is case sensitive. - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :pin (Integer) The 4- to 12-character access code that will secure this signer's signature page. You must have a business plan to use this feature. (optional) + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) + # @option opts [Array] signer_file Sets a list of signers, each item is a Hash with these keys: + # * role (Integer) The signer role indicated on the Template. + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * pin (Integer) Secures the SignatureRequest using this 4-12 character access code. A business plan is required to use this feature. (optional) # @option opts [Array] ccs The individual(s) to be CC'd on the SignatureRequest. Required when a CC role exists for the Template. - # * :role (String) The CC role indicated on the Template. Note that the role name is case sensitive. - # * :email_address (String) CC Recipient's email address - # @option opts [Array] custom_fields An array of custom merge fields, representing those present in the Template. (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. - # * :editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) - # * :required (Boolean) Determines if the field is required or not. (optional) + # * role (String) The CC role indicated on the Template. Note that the role name is case sensitive. + # * email_address (String) CC Recipient's email address + # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the Template. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # * editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) + # * required (Boolean) Determines if the field is required or not. (optional) # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional) # @option opts [String] client_id The API App Client ID associated with the SignatureRequest. (optional) # @option opts [Array] files Use files to indicate the uploaded file(s) to append to the SignatureRequest. (optional) # @option opts [Array] file_urls Use file_urls to have HelloSign download the file(s) to append to the SignatureRequest. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) + # # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest + # # @example - # signature_request = @client.send_signature_request_with_template( - # :test_mode => 1, - # :allow_decline => 1, - # :template_ids => [ - # 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', - # 'c7ab48e9a9ee7102dd6229dbbc719abc7d90ff9f' - # ], - # :title => 'Purchase Order', - # :subject => 'Purchase Order', - # :message => 'Glad we could come to an agreement.', - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' - # }, - # :signers => [ - # { - # :email_address => 'george@example.com', - # :name => 'George', - # :role => 'Client' - # }, - # { - # :email_address => 'mary@example.com', - # :name => 'Mary', - # :role => 'Manager' - # } - # ] - # ) - # @example - # signature_request = @client.send_signature_request_with_template( - # :test_mode => 1, - # :allow_decline => 0, - # :template_id => 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', - # :title => 'Purchase Order', - # :subject => 'Purchase Order', - # :message => 'Glad we could come to an agreement.', - # :files => ['NDA.pdf', 'AppendixA.pdf'], - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # signature_request = @client.send_signature_request_with_template( + # test_mode: 1, + # allow_decline: 0, + # template_id: 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', + # title: 'Purchase Order', + # subject: 'Purchase Order', + # message: 'Glad we could come to an agreement.', + # files: ['NDA.pdf', 'AppendixA.pdf'], + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [ - # { - # :email_address => 'george@example.com', - # :name => 'George', - # :role => 'Client' - # } - # ], - # :ccs => [ - # { - # :email_address =>'accounting@example.com', - # :role => "Accounting" + # signers: [ + # { + # email_address: 'george@example.com', + # name: 'George', + # role: 'Client' + # } + # ], + # ccs: [ + # { + # email_address: 'accounting@example.com', + # role: 'Accounting' + # } + # ], + # custom_fields: [ + # { + # CustomFieldName: '$20,000' + # } + # ], + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' # } - # ], - # :custom_fields => [ - # { - # :CustomFieldName => '$20,000' - # } - # ] - # ) - # + # ) def send_signature_request_with_template(opts) prepare_signers opts prepare_ccs opts @@ -256,45 +253,120 @@ def send_signature_request_with_template(opts) prepare_custom_fields opts prepare_files opts - HelloSign::Resource::SignatureRequest.new post('/signature_request/send_with_template', :body => opts) + HelloSign::Resource::SignatureRequest.new post('/signature_request/send_with_template', body: opts) end + # Creates a BulkSendJob based off of the Template specified with the template_id parameter. + # @option opts [Boolean] test_mode Indicates if this is a test BulkSendJob, its SignatureRequests will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [String] template_id The Template ID to use when creating the SignatureRequest. + # * Use template_ids[%i%] if using multiple templates, replacing %i% with an integer to indicate the order of the Templates + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) + # @option opts [String] signer_file Uploads a CSV file defining values and options for signer fields. Required if signer_list is not used. + # @option opts [String] signer_list A JSON array defining values and options for signer fields. Required if signer_file is not used. + # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the Template. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # * editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) + # * required (Boolean) Determines if the field is required or not. (optional) + # @option opts [Array] ccs The individual(s) to be CC'd on the SignatureRequest. Required when a CC role exists for the Template. + # * role (String) The CC role indicated on the Template. Note that the role name is case sensitive. + # * email_address (String) CC Recipient's email address + # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional) + # @option opts [String] client_id The API App Client ID associated with the SignatureRequest. (optional) + # + # @return [HelloSign::Resource::BulkSendJob] a BulkSendJob # - # Sends an email to the signer reminding them to sign the signature request. + # @example + # signature_request = @client.bulk_send_with_template( + # test_mode: 1, + # allow_decline: 0, + # template_id: 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', + # title: 'Purchase Order', + # subject: 'Purchase Order', + # message: 'Glad we could come to an agreement.', + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' + # }, + # signer_list: [ + # { + # signers: { + # Client: { + # name: 'George', + # email_address: 'bulksend1@example.com' + # } + # }, + # custom_fields: { + # address: '100 Grand' + # } + # }, + # { + # signers: { + # Client: { + # name: 'Mary', + # email_address: 'bulksend2@example.com' + # } + # } + # } + # ], + # ccs: [ + # { + # email_address: 'accounting@example.com', + # role: 'Accounting' + # } + # ] + # ) + def bulk_send_with_template(opts) + prepare_bulk_signers opts + prepare_ccs opts + prepare_templates opts + prepare_custom_fields opts + + HelloSign::Resource::BulkSendJob.new post('/signature_request/bulk_send_with_template', body: opts) + end + + # Sends an email reminder to the signer about the SignatureRequest. # @option opts [String] signature_request_id Indicates the ID of the SignatureRequest to send a reminder. # @option opts [String] email_address The email address of the signer who will receive a reminder. # @option opts [String] name The name of the signer who will receive a reminder. (optional) # # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest - # @example - # signature_request = @client.remind_signature_request :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491', :email_address => 'john@example.com' # + # @example + # signature_request = @client.remind_signature_request( + # signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491', + # :email_address: 'john@example.com' + # ) def remind_signature_request(opts) - HelloSign::Resource::SignatureRequest.new post("/signature_request/remind/#{opts[:signature_request_id]}", :body => opts) + HelloSign::Resource::SignatureRequest.new post("/signature_request/remind/#{opts[:signature_request_id]}", body: opts) end + # Cancels an incomplete SignatureRequest. + # @option opts [String] signature_request_id The ID of SignatureRequest to cancel. # - # Cancels a SignatureRequest. - # @option opts [String] signature_request_id The ID of the incomplete SignatureRequest to cancel. + # @return [HTTP::Status] 200 OK # # @example - # @client.cancel_signature_request :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491' + # @client.cancel_signature_request signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491' def cancel_signature_request(opts) - post("/signature_request/cancel/#{opts[:signature_request_id]}", :body => opts) + post("/signature_request/cancel/#{opts[:signature_request_id]}", body: opts) end - # # Removes your access to a completed a SignatureRequest. # @option opts [String] signature_request_id The ID of the completed SignatureRequest to remove access. # + # @return [HTTP::Status] 200 OK + # # @example - # @client.remove_signature_request :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491' + # @client.remove_signature_request signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491' def remove_signature_request(opts) - post("/signature_request/remove/#{opts[:signature_request_id]}", :body => opts) + post("/signature_request/remove/#{opts[:signature_request_id]}", body: opts) end - # - # Download a copy of the SignatureRequest documents specified by the signature_request_id parameter. + # Downloads a copy of the SignatureRequest documents. # @option opts [String] signature_request_id The ID of the SignatureRequest to download. # @option opts [String] file_type Determines the format of the file - either 'pdf' or 'zip' depending on the file type desired. Defaults to pdf. (optional) # @option opts [Boolean] get_url 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) @@ -302,44 +374,49 @@ def remove_signature_request(opts) # @return a PDF or Zip # # @example - # pdf = @client.signature_request_files :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491' - # + # pdf = @client.signature_request_files signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491' def signature_request_files(opts) path = "/signature_request/files/#{opts[:signature_request_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]}" + elsif opts[:get_data_uri] + separator = opts[:file_type].nil? ? '?' : '&' + path = path + "#{separator}get_data_uri=#{opts[:get_data_uri]}" end get(path)[:body] end - # # Creates a new SignatureRequest with the submitted documents to be signed in an embedded iFrame. - # If form_fields_per_document is not specified or use_text_tags is not enabled, a signature page will be affixed at the end - # and all signers will be required to add their signature there. - # Note that embedded signature requests can only be signed in embedded iFrames whereas normal signature requests can only be signed on HelloSign.com. - # See our Embedded Signing Walkthrough for more information on Embedded Signing: https://app.hellosign.com/api/embeddedSigningWalkthrough - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) + # If form_fields_per_document is not specified or use_text_tags is not enabled, a signature page will be affixed at the end. + # See our Embedded Signing Walkthrough for more information on Embedded Signing: https://app.hellosign.com/api/embeddedSigningWalkthrough. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) # @option opts [String] client_id The API App Client ID associated with the this embedded SignatureRequest. # @option opts [Array] files 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. # @option opts [Array] file_urls 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. - # @option opts [String] title The title you want to assign to the SignatureRequest. (optional) - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [Array] signers List of signers, each item is a Hash with these keys: - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :order (Integer) The order the signers are required to sign in (optional) - # * :pin (Integer) The 4- to 12-character access code that will secure this signer's signature page. You must have a business plan to use this feature. (optional) + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [Array] signers Sets a list of signers, each item is a Hash with these keys: + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * order (Integer) The order the signers are required to sign in (optional) + # * pin (Integer) Secures the SignatureRequest using this 4-12 character access code. A business plan is required to use this feature. (optional) + # @option opts [Array] attachments Sets a list of attachments signers can upload + # * name (String) Attachment name + # * instructions (String) Instructions for uploading the attachment. (optional) + # * signer_index (Integer) The signer's unique number. + # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional) # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest - # * :editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) - # * :required (Boolean) Determines if the field is required or not. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # * editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) + # * required (Boolean) Determines if the field is required or not. (optional) # @option opts [Array] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional) # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional) # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional) @@ -347,102 +424,134 @@ def signature_request_files(opts) # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional) # @option opts [Array] form_fields_per_document The fields that should appear on the document. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest + # # @example # request = @client.create_embedded_signature_request( - # :test_mode => 1, - # :allow_decline => 1, - # :client_id => 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', - # :title => 'NDA with Acme Co.', - # :subject => 'The NDA we talked about', - # :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # allow_decline: 1, + # client_id: 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', + # title: 'NDA with Acme Co.', + # subject: 'The NDA we talked about', + # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [{ - # :email_address => 'jack@example.com', - # :name => 'Jack', - # :order => 0, - # },{ - # :email_address => 'jill@example.com', - # :name => 'Jill', - # :order => 1, + # signers: [ + # { + # email_address: 'jack@example.com', + # name: 'Jack', + # order: 0, + # }, + # { + # email_address: 'jill@example.com', + # name: 'Jill', + # order: 1, + # } + # ], + # attachments: [{ + # name: 'Passport', + # instructions: 'Upload your US Passport', + # signer_index: 0, + # required: true + # }, + # { + # name: 'Driver's License', + # instructions: 'Upload your CA Driver's License', + # signer_index: 1, + # required: false # } # ], - # :cc_email_addresses => ['lawyer@example.com', 'lawyer@example2.com'], - # :files => ['NDA.pdf', 'AppendixA.pdf'] + # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'], + # files: ['NDA.pdf', 'AppendixA.pdf'], + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } # ) - # def create_embedded_signature_request(opts) opts[:client_id] ||= self.client_id prepare_files opts prepare_signers opts prepare_form_fields opts prepare_custom_fields opts + prepare_attachments opts - HelloSign::Resource::SignatureRequest.new post('/signature_request/create_embedded', :body => opts) + HelloSign::Resource::SignatureRequest.new post('/signature_request/create_embedded', body: opts) end - # # Creates a new SignatureRequest based on the given Template to be signed in an embedded iFrame. - # Note that embedded signature requests can only be signed in embedded iFrames whereas normal signature requests can only be signed on HelloSign. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) + # See our Embedded Signing Walkthrough for more information on Embedded Signing: https://app.hellosign.com/api/embeddedSigningWalkthrough. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) # @option opts [String] client_id The API App Client ID associated with the this embedded SignatureRequest. # @option opts [String] template_id The Template ID to use when creating the SignatureRequest. # * Use template_ids[%i%] if using multiple templates, replacing %i% with an integer to indicate the order of the Templates - # @option opts [String] title The title you want to assign to the SignatureRequest. (optional) - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [Array] signers List of signers - # * :role (String) The signer role indicated on the Template. Note that the role name is case sensitive. - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :pin (Integer) The 4- to 12-character access code that will secure this signer's signature page. You must have a business plan to use this feature. (optional) + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [Array] signers Sets a list of signers, each item is a Hash with these keys: + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * order (Integer) The order the signers are required to sign in (optional) + # * pin (Integer) Secures the SignatureRequest using this 4-12 character access code. A business plan is required to use this feature. (optional) # @option opts [Array] ccs The individual(s) to be CC'd on the SignatureRequest. Required when a CC role exists for the Template. - # * :role (String) The CC role indicated on the Template. Note that the role name is case sensitive. - # * :email_address (String) CC Recipient's email address + # * role (String) The CC role indicated on the Template. Note that the role name is case sensitive. + # * email_address (String) CC Recipient's email address # @option opts [Array] custom_fields An array of custom merge fields, representing those present in the Template. (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. - # * :editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) - # * :required (Boolean) Determines if the field is required or not. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # * editor (String) The signer name indicated on the Text Tag or form_fields_per_document that can edit the value of the field. (optional) + # * required (Boolean) Determines if the field is required or not. (optional) # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional) # @option opts [Array] files Use files to indicate the uploaded file(s) to append to the SignatureRequest. (optional) # @option opts [Array] file_urls Use file_urls to have HelloSign download the file(s) to append to the SignatureRequest. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest + # # @example # request = @client.create_embedded_signature_request_with_template( - # :test_mode => 1, - # :allow_decline => 1, - # :client_id => 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', - # :template_id => 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', - # :title => 'Purchase Order', - # :subject => 'Purchase Order', - # :message => 'Glad we could come to an agreement.', - # :files => ['NDA.pdf', 'AppendixA.pdf'], - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # allow_decline: 1, + # client_id: 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', + # template_id: 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', + # title: 'Purchase Order', + # subject: 'Purchase Order', + # message: 'Glad we could come to an agreement.', + # files: ['NDA.pdf', 'AppendixA.pdf'], + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [ + # signers: [ # { - # :email_address => 'george@example.com', - # :name => 'George', - # :role => 'Client' + # email_address: 'george@example.com', + # name: 'George', + # role: 'Client' # } # ], - # :ccs => [ + # ccs: [ # { - # :email_address =>'accounting@example.com', - # :role => "Accounting" + # email_address: 'accounting@example.com', + # role: 'Accounting' # } # ], - # :custom_fields => { - # :Cost => '$20,000' - # } + # custom_fields: { + # Cost: '$20,000' + # }, + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } # ) # def create_embedded_signature_request_with_template(opts) @@ -453,26 +562,26 @@ def create_embedded_signature_request_with_template(opts) prepare_custom_fields opts prepare_files opts - HelloSign::Resource::SignatureRequest.new post('/signature_request/create_embedded_with_template', :body => opts) + HelloSign::Resource::SignatureRequest.new post('/signature_request/create_embedded_with_template', body: opts) end - # # Updates the email address on a SignatureRequest. # @option opts [String] signature_request_id The ID of the SignatureRequest to update. # @option opts [String] signature_id The Signature ID of the recipient to update. # @option opts [String] email_address The new email address of the recipient. # + # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest + # # @example # @client.update_signature_request( - # :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491', - # :signature_id => '5064ca698bde9581ad75f6d62450eb4b', - # :email_address => 'newEmail@example.com' + # signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491', + # signature_id: '5064ca698bde9581ad75f6d62450eb4b', + # email_address: 'newEmail@example.com' # ) - def update_signature_request(opts) signature_request_id = opts.delete(:signature_request_id) path = "/signature_request/update/#{signature_request_id}" - HelloSign::Resource::SignatureRequest.new post(path, :body => opts) + HelloSign::Resource::SignatureRequest.new post(path, body: opts) end end end diff --git a/lib/hello_sign/api/team.rb b/lib/hello_sign/api/team.rb index 6b00285..c45f2b6 100644 --- a/lib/hello_sign/api/team.rb +++ b/lib/hello_sign/api/team.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,23 +19,21 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - # # Contains all the API calls for the Team resource. # Take a look at our API Documentation on the Team Resource (https://app.hellosign.com/api/reference#Team) # for more information about this. # # @author [hellosign] - # + module Team - # - # Returns information about your Team as well as a list of its members. + + # Returns member list and information about your Team. # If you do not belong to a Team, HelloSign::Error::NotFound will be raised # - # @return [HelloSign::Resource::Team] your current Team + # @return [HelloSign::Resource::Team] Current Team # # @example # team = @client.get_team @@ -44,41 +41,39 @@ def get_team HelloSign::Resource::Team.new get('/team') end - # - # Creates a new Team and makes you a member. You must not currently belong to a Team to invoke. + # Creates a new Team and adds you as a member. You must not currently belong to a Team. # @option opts [String] name The name of the Team. # - # @return [HelloSign::Resource::Team] new created Team object + # @return [HelloSign::Resource::Team] a Team # # @example - # team = @client.create_team :name => 'Team America World Police' + # team = @client.create_team name: 'Team America World Police' def create_team(opts) - HelloSign::Resource::Team.new post('/team/create', :body => opts) + HelloSign::Resource::Team.new post('/team/create', body: opts) end - # # Updates the name of your Team. # @option opts [String] name The name of your Team. # - # @return [HelloSign::Resource::Team] a Team object + # @return [HelloSign::Resource::Team] # # @example - # team = @client.update_team :name => 'New Team Name' + # team = @client.update_team name: 'New Team Name' def update_team(opts) - HelloSign::Resource::Team.new post('/team', :body => opts) + HelloSign::Resource::Team.new post('/team', body: opts) end - # # Deletes your Team. Can only be invoked with a Team with one member (yourself). # + # @return [HTTP::Status] 200 OK + # # @example # team = @client.destroy_team def destroy_team post('/team/destroy') end - # - # Adds or invites a user (specified using the email_address parameter) to the Team. + # Adds or invites a user to the Team. # If the user does not currently have a HelloSign Account, a new one will be created for them. # If the user currently has a paid subscription, they will be emailed an invitation to join the Team. # If a user is already a part of a Team, a "team_invite_failed" error will be returned. @@ -86,26 +81,26 @@ def destroy_team # @option opts [String] email_address The user's email address to invite to your Team. # Note: The account_id prevails if both email_address and acccount_id are provided. # - # @return [HelloSign::Resource::Team] updated Team object + # @return [HelloSign::Resource::Team] a Team # # @example - # team = @client.add_member_to_team :email_address => 'george@example.com' + # team = @client.add_member_to_team email_address: 'george@example.com' def add_member_to_team(opts) - HelloSign::Resource::Team.new post('/team/add_member', :body => opts) + HelloSign::Resource::Team.new post('/team/add_member', body: opts) end - # # Removes a user from the Team. If the user had an outstanding invitation to your Team, the original invitation will expire. # @option opts [String] account_id The user's Account ID to remove from the Team. # @option opts [String] email_address The user's email address to remove from your Team. # @option opts [String] new_owner_email_address The Account's email address to receive all documents, API Apps (if applicable), and API key from removed account. (optional) # Note: The account_id prevails if both email_address and acccount_id are provided. # - # @return [HelloSign::Resource::Team] updated Team object + # @return [HelloSign::Resource::Team] updated Team + # # @example - # team = @client.remove_member_from_team :email_address => 'george@example.com' + # team = @client.remove_member_from_team email_address: 'george@example.com' def remove_member_from_team(opts) - HelloSign::Resource::Team.new post('/team/remove_member', :body => opts) + HelloSign::Resource::Team.new post('/team/remove_member', body: opts) end end end diff --git a/lib/hello_sign/api/template.rb b/lib/hello_sign/api/template.rb index 0f50311..1683175 100644 --- a/lib/hello_sign/api/template.rb +++ b/lib/hello_sign/api/template.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,56 +19,49 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api - - # # Contains all the API calls for the Template resource. # Take a look at our API Documentation for Templates (https://app.hellosign.com/api/reference#Template) # for more information about this. # # @author [hellosign] - # + module Template + # Retrieves the Template with the given ID. + # @option opts [String] template_id The ID of the Template to retrieve. # - # Retrieves the Template specified by the id parameter. - # @option opts [String] template_id The Template ID to retrieve. - # - # @return [HelloSign::Resource::Template] a Template object + # @return [HelloSign::Resource::Template] a Template # # @example - # template = @client.get_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35' - # + # template = @client.get_template template_id: 'f57db65d3f933b5316d398057a36176831451a35' def get_template(opts) HelloSign::Resource::Template.new get("/template/#{opts[:template_id]}") end - # # Deletes the specified Template. - # @option opts [String] template_id The Template ID to delete. + # @option opts [String] template_id The ID of the Template to delete. # - # @example - # template = @client.delete_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35' + # @return [HTTP::Status] 200 OK # + # @example + # template = @client.delete_template template_id: 'f57db65d3f933b5316d398057a36176831451a35' def delete_template(opts) post("/template/delete/#{opts[:template_id]}") end - # # Retrieves the Templates for the accessible by the current user. - # - # @option opts [String] acount_id The Account ID to return Templates for and must be a team member. Use "all" for all team members. Defaults to current account. (optional) + # @option opts [String] account_id The Account ID to return Templates for. Use "all" for all team members. Defaults to current account. (optional) # @option opts [Integer] page Sets the page number of the list to return. Defaults to 1. (optional) # @option opts [Integer] page_size Determines the number of Templates returned per page. Defaults to 20. (optional) # @option opts [String] query Search terms and/or fields to filter the Templates. (optional) # - # @return [HelloSign::Resource::ResourceArray] a ResourceArray object - # @example - # templates = @client.get_templates :page => 1 + # @return [HelloSign::Resource::ResourceArray] a ResourceArray # + # @example + # templates = @client.get_templates page: 1 def get_templates(opts={}) path = '/template/list' opts[:query] = create_search_string(opts[:query]) if opts[:query] @@ -78,44 +70,39 @@ def get_templates(opts={}) HelloSign::Resource::ResourceArray.new get(path, opts), 'templates', HelloSign::Resource::Template end - # # Gives the specified Account access to a Template. The Account must be part of your Team. - # # @option opts [String] template_id The Template ID to give access to. # @option opts [String] account_id The Account ID to receive access to the Template. # @option opts [String] email_address The email address of the Account to receive access to the Template. # Note: The account_id prevails if both email_address and acccount_id are provided. # - # @return [Template] a Template object - # @example - # templates = @client.add_user_to_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => 'george@example.com' + # @return [HelloSign::Resource::Template] a Template # + # @example + # templates = @client.add_user_to_template template_id: 'f57db65d3f933b5316d398057a36176831451a35', email_address: 'george@example.com' 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) + HelloSign::Resource::Template.new post(path, body: opts) end - # # Removes the specified Account access to the specified Template. - # # @option opts [String] template_id The Template ID to remove access to. # @option opts [String] account_id The Account ID to remove access to the Template. # @option opts [String] email_address The email address of the Account to remove access to the Template. # Note: The account_id prevails if both email_address and acccount_id are provided. # - # @return [Template] a Template object - # @example - # templates = @client.remove_user_from_template :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :email_address => 'george@example.com' + # @return [HelloSign::Resource::Template] a Template # + # @example + # templates = @client.remove_user_from_template template_id: 'f57db65d3f933b5316d398057a36176831451a35', email_address: 'george@example.com' 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) + HelloSign::Resource::Template.new post(path, body: opts) end - # - # Creates a new embedded template draft object that can be launched in an iFrame using the claim_url. + # Creates a new Embedded Template draft object that can be launched in an iFrame using the claim_url. # @option opts [Boolean] test_mode 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) # @option opts [String] client_id The API App Client ID associated with the Template draft. (optional) # @option opts [Array] files 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. @@ -124,61 +111,83 @@ def remove_user_from_template(opts) # @option opts [String] subject The default Template title alias. (optional) # @option opts [String] message The default message in the email that will be sent to the signer(s). (optional) # @option opts [Array] signers 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) + # * name (String) Signer role name + # * order (Integer) The order the signer role is required to sign in. (optional) + # @option opts [Array] attachments Sets a list of attachments signers can upload + # * name (String) Attachment name + # * instructions (String) Instructions for uploading the attachment. (optional) + # * signer_index (Integer) The signer's unique number. + # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional) # @option opts [Array] cc_roles The CC roles that must be assigned when using the Template to create a SignatureRequest. (optional) # @option opts [String] merge_fields 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" + # * name (String) Merge field name + # * type (String) Field type - either "text" or "checkbox" # @option opts [Boolean] skip_me_now Sets the "Me (Now)" option for the Template preparer. Defaults to 0. (optional) # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional) # @option opts [Hash] metadata Key-value data attached to the Template and all SignatureRequests created from the Template. (optional) # @option opts [Boolean] allow_reassign Sets the ability for signers to reassign the SignatureRequest to other signers. Defaults to 0. (optional) # - # @example create_embedded_draft + # @return [HelloSign::Resource::Template] a Template + # + # @example # template_draft = @client.create_embedded_template_draft( - # :test_mode => 1, - # :subject => 'The NDA we talked about', - # :requester_email_address => requester@example.com", - # :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 + # test_mode: 1, + # subject: 'The NDA we talked about', + # requester_email_address: 'requester@example.com', + # 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' + # attachments: [{ + # name: 'Passport', + # instructions: 'Upload your US Passport', + # signer_index: 0, + # required: true + # }, + # { + # name: 'Driver's License', + # instructions: 'Upload your CA Driver's License', + # signer_index: 1, + # required: false + # } + # ], + # cc_roles: ['HRManager'], + # files: ['NDA.pdf', 'AppendixA.pdf'], + # merge_fields: '[ + # { + # name: 'contract_id', + # type: 'text' + # }, + # { + # name: 'purchase_price', + # order: 'text' # } # ]' # ) - # 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) + prepare_attachments opts + HelloSign::Resource::TemplateDraft.new post("/template/create_embedded_draft", body: opts) end - # # Downloads the original files of a specified Template. - # # @option opts [String] template_id The Template ID to retrieve. # @option opts [String] file_type Determines the format of the file - either 'pdf' or 'zip' depending on the file type desired. Defaults to pdf. (optional) # @option opts [Boolean] get_url 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) # # @return a PDF or Zip - # @example - # templates = @client.get_template_files :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :file_type => 'zip' # + # @example + # file = @client.get_template_files template_id: 'f57db65d3f933b5316d398057a36176831451a35', file_type: 'zip' def get_template_files(opts) path = "/template/files/#{opts[:template_id]}" if opts[:file_type] @@ -192,26 +201,26 @@ def get_template_files(opts) get(path) end - # # Overlays a new file with the overlay of the specified Template. - # # @option opts [String] template_id The Template ID to update. # @option opts [Array] files 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. # @option opts [Array] file_urls 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. # @option opts [String] subject The updated default Template title alias. (optional) # @option opts [String] message The updated default message in the email that will be sent to the signer(s). (optional) - # @option opts [String] client_id The API App Client ID associated with the Template draft. (optional) - # @option opts [Boolean] test_mode 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) + # @option opts [String] client_id The API App Client ID associated with the Template. (optional) + # @option opts [Boolean] test_mode Indicates if this is a test Template. SignatureRequests using this Template will not be legally binding if set to 1. Defaults to 0. (optional) # # @return a Template ID + # # @example - # templates = @client.update_template_files :template_id => 'f57db65d3f933b5316d398057a36176831451a35', :file => '@NDA.pdf' + # templates = @client.update_template_files template_id: 'f57db65d3f933b5316d398057a36176831451a35', file: '@NDA.pdf' # 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) + + HelloSign::Resource::Template.new post(path, body: opts) end end end diff --git a/lib/hello_sign/api/unclaimed_draft.rb b/lib/hello_sign/api/unclaimed_draft.rb index ebea50e..bdabbb0 100644 --- a/lib/hello_sign/api/unclaimed_draft.rb +++ b/lib/hello_sign/api/unclaimed_draft.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,41 +19,42 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Api + # Contains all the API calls for the UnclaimedDraft resource. + # Take a look at our API documentation for creating UnclaimedDrafts (https://app.hellosign.com/api/reference#UnclaimedDraft) + # for more information about this. + # + # @author [hellosign] - # - # Contains all the API calls for the UnclaimedDraft resource. - # Take a look at our API documentation for creating UnclaimedDrafts (https://app.hellosign.com/api/reference#UnclaimedDraft) - # for more information about this. - # - # @author [hellosign] - # - module UnclaimedDraft + module UnclaimedDraft - # # Creates a new UnclaimedDraft that can be claimed using the claim_url. # The first authenticated user to access the claim_url claims the Draft and will be shown either the "Sign and send" or the "Request signature" page with the Draft loaded. # Subsequent access to the claim_url will result in a 404 not found error. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) - # @option opts [Array] files 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. - # @option opts [Array] file_urls 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. - # @option opts [String] type The type of UnclaimedDraft to create. Use "send_document" to create a claimable file, and "request_signature" for a claimable signature request. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [Array] files Specifies the file path(s) to send for the SignatureRequest. + # @option opts [Array] file_urls Specifies the URL(s) for the file(s) to send for the SignatureRequest. + # @option opts [String] type The type of UnclaimedDraft to create. Use "send_document" to create a claimable file, and "request_signature" for a claimable SignatureRequest. # * For "send_document," only the file parameter is required. # * For "request_signature," then signer name and email_address are required. # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [Array] signers List of signers, each item is a Hash with these keys: (optional) - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :order (Integer) The order the signers are required to sign in (optional) + # @option opts [Array] signers Sets a list of signers, each item is a Hash with these keys: + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * order (Integer) The order the signers are required to sign in (optional) + # @option opts [Array] attachments Sets a list of attachments signers can upload + # * name (String) Attachment name + # * instructions (String) Instructions for uploading the attachment. (optional) + # * signer_index (Integer) The signer's unique number. + # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional) # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. - # @option opts [Array] cc_email_addresses The email addresses that should be CCed. (optional) - # @option opts [String] signing_redirect_url The URL you want the signer(s) redirected to after they successfully sign. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # @option opts [Array] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional) # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional) # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional) @@ -62,71 +62,97 @@ module UnclaimedDraft # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional) # @option opts [Array] form_fields_per_document The fields that should appear on the document. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # - # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft object + # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft # # @example type: send_document # unclaimed_draft = @client.create_unclaimed_draft( - # :test_mode => 1, - # :files => ['NDA.pdf', 'AppendixA.pdf'] + # test_mode: 1, + # files: ['NDA.pdf', 'AppendixA.pdf'] # ) + # # @example type: request_signature # unclaimed_draft = @client.create_unclaimed_draft( - # :test_mode => 1, - # :type => 'request_signature', - # :subject => 'The NDA we talked about', - # :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # type: 'request_signature', + # subject: 'The NDA we talked about', + # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [{ - # :email_address => 'jack@example.com', - # :name => 'Jack', - # :order => 0 - # },{ - # :email_address => 'jill@example.com', - # :name => 'Jill', - # :order => 1 + # signers: [ + # { + # email_address: 'jack@example.com', + # name: 'Jack', + # order: 0 + # }, + # { + # email_address: 'jill@example.com', + # name: 'Jill', + # order: 1 # } # ], - # :cc_email_addresses => ['lawyer@example.com', 'lawyer@example2.com'], - # :files => ['NDA.pdf', 'AppendixA.pdf'] + # attachments: [{ + # name: 'Passport', + # instructions: 'Upload your US Passport', + # signer_index: 0, + # required: true + # }, + # { + # name: 'Driver's License', + # instructions: 'Upload your CA Driver's License', + # signer_index: 1, + # required: false + # } + # ], + # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'], + # files: ['NDA.pdf', 'AppendixA.pdf'], + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } # ) # def create_unclaimed_draft opts prepare_files opts + prepare_signers opts prepare_form_fields opts prepare_custom_fields opts + prepare_attachments opts - if opts[:type] == 'request_signature' - prepare_signers opts - end - - HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create', :body => opts) + HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create', body: opts) end - # - # Creates a new Embedded UnclaimedDraft object that can be launched in an iFrame using the claim_url. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) - # @option opts [String] client_id The API App Client ID associated with the UnclaimedDraft. - # @option opts [Array] files 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. - # @option opts [Array] file_urls 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. + # Creates a new Embedded UnclaimedDraft that can be opened in an embedded iFrame. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [String] client_id The API App Client ID associated with this Embedded UnclaimedDraft. + # @option opts [Array] files 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. + # @option opts [Array] file_urls 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. # @option opts [String] requester_email_address The email address of the requester, if "request_signature" type. # @option opts [String] type The type of UnclaimedDraft to create. Use "send_document" to create a claimable file, and "request_signature" for a claimable signature request. # * For "send_document," only the file parameter is required. # * For "request_signature," then signer name and email_address are required. - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) - # @option opts [Array] signers List of signers, each item is a Hash with these keys: (optional) - # * :name (String) Signer's name - # * :email_address (String) Signer's email address - # * :order (Integer) The order the signers are required to sign in (optional) - # @option opts [Array] cc_email_addresses The email addresses that should be CCed. (optional) - # @option opts [String] signing_redirect_url The URL you want the signer redirected to after they successfully sign. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) + # @option opts [Array] signers Sets a list of signers, each item is a Hash with these keys: + # * name (String) Signer's name + # * email_address (String) Signer's email address + # * order (Integer) The order the signers are required to sign in (optional) + # @option opts [Array] attachments Sets a list of attachments signers can upload + # * name (String) Attachment name + # * instructions (String) Instructions for uploading the attachment. (optional) + # * signer_index (Integer) The signer's unique number. + # * required (Boolean) Determines if the signer is required to upload this attachment. Defaults to 0. (Optional) + # @option opts [Array] cc_email_addresses The email addresses that should be CCed on the SignatureRequest. (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) # @option opts [Array] custom_fields An array of custom merge fields, representing those present on the document with Text Tags or form_fields_per_document (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. # @option opts [Boolean] use_text_tags Indicates whether the SignatureRequest should have Text Tags enabled. Defaults to 0. (optional) # @option opts [Boolean] hide_text_tags Indicates whether the Text Tags should be removed automatically. Note that this is not the preferred method. Defaults to 0. (optional) # @option opts [Boolean] use_preexisting_fields Sets the detection of predefined PDF fields. Defaults to 0. (optional) @@ -136,108 +162,134 @@ def create_unclaimed_draft opts # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional) # @option opts [Array] form_fields_per_document The fields that should appear on the document. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # - # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft object + # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft # - # @example request_signature + # @example type: request_signature # unclaimed_draft = @client.create_embedded_unclaimed_draft( - # :test_mode => 1, - # :type => 'request_signature', - # :subject => 'The NDA we talked about', - # :requester_email_address => requester@example.com", - # :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # type: 'request_signature', + # subject: 'The NDA we talked about', + # requester_email_address: 'requester@example.com', + # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [{ - # :email_address => 'jack@example.com', - # :name => 'Jack', - # :order => 0 - # },{ - # :email_address => 'jill@example.com', - # :name => 'Jill', - # :order => 1 + # signers: [ + # { + # email_address: 'jack@example.com', + # name: 'Jack', + # order: 0 + # }, + # { + # email_address: 'jill@example.com', + # name: 'Jill', + # order: 1 + # } + # ], + # attachments: [{ + # name: 'Passport', + # instructions: 'Upload your US Passport', + # signer_index: 0, + # required: true + # }, + # { + # name: 'Driver's License', + # instructions: 'Upload your CA Driver's License', + # signer_index: 1, + # required: false # } # ], - # :cc_email_addresses => ['lawyer@example.com', 'lawyer@example2.com'], - # :files => ['NDA.pdf', 'AppendixA.pdf'] + # cc_email_addresses: ['lawyer@example.com', 'lawyer@example2.com'], + # files: ['NDA.pdf', 'AppendixA.pdf'], + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } # ) - # def create_embedded_unclaimed_draft(opts) opts[:client_id] ||= self.client_id prepare_files opts + prepare_signers opts prepare_form_fields opts prepare_custom_fields opts + prepare_attachments opts - if opts[:type] == 'request_signature' || opts[:type] == 'send_document' - prepare_signers opts - end - - HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded', :body => opts) + HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded', body: opts) end - # - # Creates a new Embedded UnclaimedDraft object from a Template that can be launched in an iFrame using the claim_url. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) + # Creates a new Embedded UnclaimedDraft from a Template that can be opened in an embedded iFrame. + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) # @option opts [String] client_id The API App Client ID associated with the UnclaimedDraft. # @option opts [String] template_id The Template ID to use when creating the UnclaimedDraft. # * Use template_ids[%i%] if using multiple templates, replacing %i% with an integer to indicate the order of the Templates # @option opts [String] requester_email_address The email address of the requester, if "request_signature" type. - # @option opts [String] title The title you want to assign to the SignatureRequest. (optional) - # @option opts [String] subject The subject in the email that will be sent to the signer(s). (optional) - # @option opts [String] message The custom message in the email that will be sent to the signer(s). (optional) + # @option opts [String] title Assigns a title to the SignatureRequest. (optional) + # @option opts [String] subject Sets the subject in the email sent to the signer(s). (optional) + # @option opts [String] message Sets the message in the email sent to the signer(s). (optional) # @option opts [Array] signers List of signers - # * :role (String) The signer role indicated on the Template. Note that the role name is case sensitive. - # * :name (String) Signer's name - # * :email_address (String) Signer's email address + # * role (String) The signer role indicated on the Template. + # * name (String) Signer's name + # * email_address (String) Signer's email address # @option opts [Array] ccs The individual(s) to be CC'd on the SignatureRequest. Required when a CC role exists for the Template. - # * :role (String) The CC role indicated on the Template. Note that the role name is case sensitive. - # * :email_address (String) CC Recipient's email address - # @option opts [String] signing_redirect_url The URL you want the signer redirected to after they successfully sign. (optional) - # @option opts [String] requesting_redirect_url The URL you want the requester redirected to after they successfully request a SignatureRequest. (optional) + # * role (String) The CC role indicated on the Template. Note that the role name is case sensitive. + # * email_address (String) CC Recipient's email address + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) + # @option opts [String] requesting_redirect_url Redirects the requester to this URL after sending a SignatureRequest. (optional) # @option opts [Hash] metadata Key-value data attached to the SignatureRequest. (optional) # @option opts [Array] custom_fields An array of custom merge fields, representing those present in the Template. (optional) - # * :name (String) Custom field name or "Field Label" - # * :value (String) The value of the field. This data will appear on the SignatureRequest. - # @option opts [Array] files Use files to indicate the uploaded file(s) to append to the SignatureRequest. (optional) - # @option opts [Array] file_urls Use file_urls to have HelloSign download the file(s) to append to the SignatureRequest. (optional) + # * name (String) Custom field name or "Field Label" + # * value (String) The value of the field. This data will appear on the SignatureRequest. + # @option opts [Array] files Specifies the file path(s) to append to the SignatureRequest. (optional) + # @option opts [Array] file_urls Specifies the URL(s) for the file(s) to append to the SignatureRequest. (optional) # @option opts [Boolean] skip_me_now Disables the "Me (Now)" option for the preparer. Not available for type "send_document." Defaults to 0. (optional) # @option opts [Boolean] allow_decline Allows signers to decline the SignatureRequest. Defaults to 0. (optional) # @option opts [Boolean] allow_reassign Allows signers to reassign the SignatureRequest to another signer. Defaults to 0. (optional) + # @option opts [Hash] signing_options Specifies the types allowed for creating a signature. (optional) # - # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft object + # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft # - # @example request_signature + # @example type: request_signature # unclaimed_draft = @client.create_embedded_unclaimed_draft_with_template( - # :test_mode => 1, - # :subject => 'The NDA we talked about', - # :template_id => 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', - # :requester_email_address => requester@example.com", - # :message => 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', - # :files => ['NDA.pdf', 'AppendixA.pdf'], - # :metadata => { - # :client_id => '1234', - # :custom_text => 'NDA #9' + # test_mode: 1, + # subject: 'The NDA we talked about', + # template_id: 'c26b8a16784a872da37ea946b9ddec7c1e11dff6', + # requester_email_address: 'requester@example.com', + # message: 'Please sign this NDA and then we can discuss more. Let me know if you have any questions.', + # files: ['NDA.pdf', 'AppendixA.pdf'], + # metadata: { + # client_id: '1234', + # custom_text: 'NDA #9' # }, - # :signers => [ + # signers: [ # { - # :email_address => 'george@example.com', - # :name => 'George', - # :role => 'Client' + # email_address: 'george@example.com', + # name: 'George', + # role: 'Client' # } # ], - # :ccs => [ + # ccs: [ # { - # :email_address =>'accounting@example.com', - # :role => "Accounting" + # email_address:'accounting@example.com', + # role: 'Accounting' # } # ], - # :custom_fields => { - # :Cost => '$20,000' - # } + # custom_fields: { + # Cost: '$20,000' + # }, + # signing_options: { + # draw: true, + # type: true, + # upload: false, + # phone: true, + # default: 'phone' + # } # ) - # def create_embedded_unclaimed_draft_with_template(opts) opts[:client_id] ||= self.client_id prepare_signers opts @@ -245,32 +297,31 @@ def create_embedded_unclaimed_draft_with_template(opts) prepare_ccs opts prepare_templates opts prepare_files opts - HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded_with_template', :body => opts) + + HelloSign::Resource::UnclaimedDraft.new post('/unclaimed_draft/create_embedded_with_template', body: opts) end - # - # Creates a new SignatureRequest from an Embedded UnclaimedDraft. This UnclaimedDraft can be - # edited using the claim_url. + # Creates a new SignatureRequest from an Embedded UnclaimedDraft. # @option opts [String] signature_request_id The SignatureRequest ID to edit and resend. # @option opts [String] client_id The API App Client ID associated with the UnclaimedDraft. - # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. A boolean value is also accepted. Defaults to 0. (optional) - # @option opts [String] requesting_redirect_url The URL you want the requester redirected to after they successfully request a SignatureRequest. (optional) - # @option opts [String] signing_redirect_url The URL you want the signer redirected to after they successfully sign. (optional) + # @option opts [Boolean] test_mode Indicates if this is a test SignatureRequest, it will not be legally binding if set to 1. Defaults to 0. (optional) + # @option opts [String] requesting_redirect_url Redirects the requester to this URL after sending a SignatureRequest. (optional) + # @option opts [String] signing_redirect_url Redirects the signer(s) to this URL after completing the SignatureRequest. (optional) # @option opts [Boolean] is_for_embedded_signing Enable the UnclaimedDraft to be used for an Embedded SignatureRequest. Defaults to 0. (optional) # - # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft object + # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft # # @example # unclaimed_draft = @client.edit_and_resend_unclaimed_draft( - # :signature_request_id => '75cdf7dc8b323d43b347e4a3614d1f822bd09491', - # :test_mode => 1, - # :client_id => 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', + # signature_request_id: '75cdf7dc8b323d43b347e4a3614d1f822bd09491', + # test_mode: 1, + # client_id: 'b6b8e7deaf8f0b95c029dca049356d4a2cf9710a', # ) - # def edit_and_resend_unclaimed_draft(opts) signature_request_id = opts.delete(:signature_request_id) path = "/unclaimed_draft/edit_and_resend/#{signature_request_id}" - HelloSign::Resource::UnclaimedDraft.new post(path, :body => opts) + + HelloSign::Resource::UnclaimedDraft.new post(path, body: opts) end end end diff --git a/lib/hello_sign/client.rb b/lib/hello_sign/client.rb index 99a7f5a..68075de 100644 --- a/lib/hello_sign/client.rb +++ b/lib/hello_sign/client.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# require 'faraday' require 'multi_json' @@ -32,13 +30,10 @@ require 'logger' module HelloSign - # + # You'll need the HelloSign::Client to do just about everything, from creating # signatures to updating account information. # - # @example - # client = HelloSign::Client.new :email_address => "me@example.com", :password => "mypassword" - # # @author [hellosign] class Client include Api::Account @@ -49,6 +44,7 @@ class Client include Api::Embedded include Api::OAuth include Api::ApiApp + include Api::BulkSendJob attr_accessor :end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :logging, :log_level, :proxy_uri, :proxy_user, :proxy_pass, :timeout @@ -67,13 +63,18 @@ class Client 503 => Error::ServiceUnavailable } - # # Initiates a new HelloSign Client - # @option opts [String] email_address The account's email address. (optional) # @option opts [String] password The account's password, if authenticating with an email_address. (optional) # @option opts [String] api_key The account's API key. + # # @return [HelloSign::Client] a new HelloSign::Client + # + # @example Authenticating with username and password + # client = HelloSign::Client.new email_address: 'me@example.com', password: 'mypassword' + # + # @example Authenticating with API key + # client = HelloSign::Client.new api_key: '1234567890123456789012345678901234567890123456789012345678901234' def initialize(opts={}) options = HelloSign.options.merge(opts) HelloSign::Configuration::VALID_OPTIONS_KEYS.each do |key| @@ -81,11 +82,9 @@ def initialize(opts={}) end end - # # Makes an HTTP GET request - # @param path [String] Relative path of the request. + # @param path [String] Relative path of the request. # @option options [Hash] params Params of the URL. - # def get(path, options={}) response = request(path, :get, options) validate response @@ -93,12 +92,10 @@ def get(path, options={}) data = { headers: response.headers, body: parsed_response } end - # # Makes an HTTP POST request - # @param path [String] Relative path of the request. + # @param path [String] Relative path of the request. # @option options [Hash] params Params of the URL. # @option options [Hash] body Body of the request. - # def post(path, options={}) response = request(path, :post, options) validate response @@ -106,12 +103,10 @@ def post(path, options={}) data = { headers: response.headers, body: parsed_response } end - # # Makes an HTTP PUT request - # @param path [String] Relative path of the request. + # @param path [String] Relative path of the request. # @option options [Hash] params Params of the URL. # @option options [Hash] body Body of the request. - # def put(path, options={}) response = request(path, :put, options) validate response @@ -119,11 +114,9 @@ def put(path, options={}) data = { headers: response.headers, body: parsed_response } end - # - # Make an HTTP DELETE request - # @param path [String] Relative path of the request. + # Makes an HTTP DELETE request + # @param path [String] Relative path of the request. # @option options [Hash] Params of the URL. - # def delete(path, options={}) response = request(path, :delete, options) validate response @@ -277,7 +270,11 @@ def create_search_string(raw_string) end def prepare_signers(opts) - prepare opts, :signers + if opts[:signers] + prepare opts, :signers + elsif opts[:signer_group] + prepare_signer_group opts, :signer_group + end end def prepare_ccs(opts) @@ -292,6 +289,10 @@ def prepare_signer_roles(opts) prepare opts, :signer_roles end + def prepare_attachments(opts) + prepare opts, :attachments + end + def prepare_form_fields(opts) if (opts[:form_fields_per_document] and opts[:form_fields_per_document].is_a? Array) opts[:form_fields_per_document] = MultiJson.dump(opts[:form_fields_per_document]) @@ -313,6 +314,18 @@ def prepare_merge_fields(opts) # ignore if it's already a string, or not present end + def prepare_bulk_signers(opts) + if opts[:signer_file] + file = opts[:signer_file] + mime_type = MIMEfromIO file + opts[:signer_file] = Faraday::UploadIO.new(file, mime_type) + elsif opts[:signer_list] + opts[:signer_list] = MultiJson.dump(opts[:signer_list]) + else + raise HelloSign::Error::NotSupportedType.new "Upload a CSV file or JSON list of signers" + end + end + def prepare(opts, key) return unless opts[key] opts[key].each_with_index do |value, index| @@ -329,5 +342,28 @@ def prepare(opts, key) end opts.delete(key) end + + def prepare_signer_group(opts, key) + opts[key].each_with_index do |value, index| + if value[:role] + group_index_or_role = value[:role] + else + group_index_or_role = index + end + + opts[:"signers[#{group_index_or_role}][group]"] = value[:group_name] + opts[key] = value[:signers] + prepare_signers_for_group(value[:signers], group_index_or_role, opts) + end + opts.delete(key) + end + + def prepare_signers_for_group(signers, group_index_or_role, opts) + signers.each_with_index do |signer, index| + signer.each do |param, data| + opts[:"signers[#{group_index_or_role}][#{index}][#{param}]"] = data + end + end + end end end diff --git a/lib/hello_sign/configuration.rb b/lib/hello_sign/configuration.rb index ed96585..0f04331 100644 --- a/lib/hello_sign/configuration.rb +++ b/lib/hello_sign/configuration.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,21 +19,18 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign - # - # Define config attributes and default values for HelloSign module + + # Defines config attributes and default values for HelloSign module # # @author [hellosign] - # module Configuration DEFAULT_ENDPOINT = 'https://api.hellosign.com' DEFAULT_API_VERSION = '/v3' DEFAULT_OAUTH_ENDPOINT = 'https://app.hellosign.com' VALID_OPTIONS_KEYS = [:end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :log_level, :logging, :proxy_uri, :proxy_user, :proxy_pass, :timeout] - DEFAULT_USER_AGENT = "hellosign-ruby-sdk/" + HelloSign::VERSION attr_accessor *VALID_OPTIONS_KEYS @@ -42,7 +38,7 @@ module Configuration # Sets all configuration options to their default values # when this module is extended. # - # @param base [Object] new module or class extend thid module + # @param base [Object] New module or class extends this module def self.extended(base) base.reset end diff --git a/lib/hello_sign/error.rb b/lib/hello_sign/error.rb index 2e0c88e..ff5030a 100644 --- a/lib/hello_sign/error.rb +++ b/lib/hello_sign/error.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,10 +19,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Error + # Custom error class for rescuing from all HelloSign errors. class Error < StandardError; attr_accessor :request_uri, :response_body, :response_status @@ -43,7 +42,7 @@ def human_readable_message end end - # Raise when attributes are missing. + # Raised when attributes are missing. class MissingAttributes < Error; end # Raised when API endpoint credentials not configured. diff --git a/lib/hello_sign/resource.rb b/lib/hello_sign/resource.rb index 4d35042..680391f 100644 --- a/lib/hello_sign/resource.rb +++ b/lib/hello_sign/resource.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# require 'hello_sign/resource/base_resource' require 'hello_sign/resource/resource_array' @@ -32,3 +30,4 @@ require 'hello_sign/resource/team' require 'hello_sign/resource/unclaimed_draft' require 'hello_sign/resource/api_app' +require 'hello_sign/resource/bulk_send_job' diff --git a/lib/hello_sign/resource/account.rb b/lib/hello_sign/resource/account.rb index a0a22e3..6f4d30d 100644 --- a/lib/hello_sign/resource/account.rb +++ b/lib/hello_sign/resource/account.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Contains information about an Account and its settings. # Take a look at our API Documentation on the Account resource (https://app.hellosign.com/api/reference#Account) # for more information about this. # # @author [hellosign] - # + class Account < BaseResource - # + # Creates a new Account from a hash. If key defined then account data with be the value of hash[key], otherwise the hash itself. # @param hash [Hash] Account's data # @param key [String] (account) key of the hash, point to where Account data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:Account] an Account resource + # @return [HelloSign::Resource::Account] an Account def initialize(hash, key='account') super end diff --git a/lib/hello_sign/resource/api_app.rb b/lib/hello_sign/resource/api_app.rb index cb55766..357e1ff 100644 --- a/lib/hello_sign/resource/api_app.rb +++ b/lib/hello_sign/resource/api_app.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2015 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Contains information about the ApiApp resource. # Take a look at our API Documentation for ApiApps (https://app.hellosign.com/api/reference#ApiApp) # for more information about this. # # @author [hellosign] - # + class ApiApp < BaseResource - # + # Creates a new ApiApp from a hash. If a key is defined then ApiApp data with be the value of hash[key], otherwise the hash itself. # @param hash [Hash] ApiApp data # @param key [String] (api_app) key of the hash, point to where ApiApp data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:ApiApp] an ApiApp resource + # @return [HelloSign::Resource::ApiApp] an ApiApp def initialize(hash, key='api_app') super end diff --git a/lib/hello_sign/resource/base_resource.rb b/lib/hello_sign/resource/base_resource.rb index 2a9aa73..8c8788e 100644 --- a/lib/hello_sign/resource/base_resource.rb +++ b/lib/hello_sign/resource/base_resource.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,20 +19,18 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Stores the value of a hash. Use missing_method to create method to access it like an object # # @author [hellosign] - # + class BaseResource attr_reader :data, :raw_data, :warnings, :headers - # - # recursively convert hash data into BaseResource. + + # Converts hash data recursively into BaseResource. # # @param hash [Hash] Data of the resource # @param key [String] (nil) Key of the hash, point to where resource data is. If nil, then the hash itself. @@ -58,15 +55,14 @@ def initialize(hash, key=nil) end end - # - # Magic method, give class dynamic methods based on hash keys. + # Magic method, gives class dynamic methods based on hash keys. # If initialized hash has a key which matches the method name, return value of that key. # Otherwise, return nil. # # @param method [Symbol] Method's name # # @example - # resource = BaseResource.new :email_address => "me@example.com" + # resource = BaseResource.new email_address: "me@example.com" # resource.email_address => "me@example.com" # resource.not_in_hash_keys => nil def method_missing(method) diff --git a/lib/hello_sign/resource/bulk_send_job.rb b/lib/hello_sign/resource/bulk_send_job.rb new file mode 100644 index 0000000..414f502 --- /dev/null +++ b/lib/hello_sign/resource/bulk_send_job.rb @@ -0,0 +1,43 @@ +# The MIT License (MIT) +# +# Copyright (C) 2014 hellosign.com +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +module HelloSign + module Resource + # Contains information about a BulkSendJob. + # Take a look at our API Documentation on BulkSendJobs (https://app.hellosign.com/api/reference#BulkSendJob) + # for more information about this. + # + # @author [hellosign] + + class BulkSendJob < BaseResource + + # Creates a new BulkSendJob from a hash. If a key is defined then account data with be the value of hash[key], otherwise the hash itself. + # @param hash [Hash] BulkSendJob's data + # @param key [String] (bulk_send_job) Key of the hash, point to where BulkSendJob data is. If nil, then the hash itself. + # + # @return [HelloSign::Resource::BulkSendJob] a BulkSendJob + def initialize(hash, key='bulk_send_job') + super + end + end + end +end diff --git a/lib/hello_sign/resource/embedded.rb b/lib/hello_sign/resource/embedded.rb index b1c23ee..3417adb 100644 --- a/lib/hello_sign/resource/embedded.rb +++ b/lib/hello_sign/resource/embedded.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # - # An object that contains necessary information to set up Embedded signing. + # Contains information about Embedded workflows. # Take a look at our Embedded Signing Walkthrough (https://app.hellosign.com/api/embeddedSigningWalkthrough) # for more information about this. # # @author [hellosign] - # + class Embedded < BaseResource + + # Creates a new Embedded resource from a hash. If a key is defined then embedded data with be the value of hash[key], otherwise the hash itself. + # @param hash [Hash] Embedded's data + # @param key [String] (embedded) Key of the hash, point to where Embedded data is. If nil, then the hash itself. # - # create a new Embedded resource from a hash. If a key is defined then embedded data with be the value of hash[key], otherwise the hash itself. - # @param hash [Hash] Embedded's data - # @param key [String] (embedded) Key of the hash, point to where Embedded data is. If nil, then the hash itself. - # - # @return [HelloSign::Resource:Embedded] an Embedded resource + # @return [HelloSign::Resource::Embedded] an Embedded resource def initialize(hash, key='embedded') super end diff --git a/lib/hello_sign/resource/resource_array.rb b/lib/hello_sign/resource/resource_array.rb index de38ee2..3ad2d1b 100644 --- a/lib/hello_sign/resource/resource_array.rb +++ b/lib/hello_sign/resource/resource_array.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,25 +19,23 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Stores an array of HelloSign BaseResource with paging information # # @author [hellosign] - # + class ResourceArray < Array attr_reader :page, :num_pages, :num_results, :page_size, :warnings, :headers, :list_info, :data + + # Creates a new ResourceArray from a hash # - # create a new ResourceArray from a hash - # - # @param hash [Hash] Data of the array. - # @param key [String] Key of the hash, point to where resource array data is. - # @param resource_class [Class] a ResourceClass object inherited from BaseResource. Uses the created array item from hash[key]. + # @param hash [Hash] Data of the array. + # @param key [String] Key of the hash, point to where resource array data is. + # @param resource_class [Class] a ResourceClass object inherited from BaseResource. Uses the created array item from hash[key]. # - # @return [type] [description] + # @return [HelloSign::Resource::ResourceArray] a ResourceArray def initialize(hash, key, resource_class) @headers = hash[:headers] @data = hash[:body] diff --git a/lib/hello_sign/resource/signature_request.rb b/lib/hello_sign/resource/signature_request.rb index c6234fc..5b15966 100644 --- a/lib/hello_sign/resource/signature_request.rb +++ b/lib/hello_sign/resource/signature_request.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # - # Contains information regarding documents that need to be signed. - # Take a look at our API Documentation for sending Signature Requests (https://app.hellosign.com/api/reference#SignatureRequest) + # Contains information about a SignatureRequest. + # Take a look at our API Documentation for Signature Requests (https://app.hellosign.com/api/reference#SignatureRequest) # for more information about this. # # @author [hellosign] - # + class SignatureRequest < BaseResource - # - # create a new SignatureRequest from a hash. If a key is defined then account data with be the value of hash[key], otherwise the hash itself. + + # Creates a new SignatureRequest from a hash. If a key is defined then account data with be the value of hash[key], otherwise the hash itself. # @param hash [Hash] SignatureRequest's data # @param key [String] (signature_request) Key of the hash, point to where SignatureRequest data is. If nil, then the hash itself. # - # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest resource + # @return [HelloSign::Resource::SignatureRequest] a SignatureRequest def initialize(hash, key='signature_request') super end diff --git a/lib/hello_sign/resource/team.rb b/lib/hello_sign/resource/team.rb index 12ad79d..add79d4 100644 --- a/lib/hello_sign/resource/team.rb +++ b/lib/hello_sign/resource/team.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # # Contains information about a Team and its members. # Take a look at our API Documentation on the Team Resource (https://app.hellosign.com/api/reference#Team) # for more information about this. # # @author [hellosign] - # + class Team < BaseResource - # + # Creates a new Team from a hash. If a key is defined then team data with be the value of hash[key], otherwise the hash itself. # @param hash [Hash] Team's data # @param key [String] (team) Key of the hash, point to where Team data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:Team] a Team resource + # @return [HelloSign::Resource::Team] a Team def initialize(hash, key='team') super end diff --git a/lib/hello_sign/resource/template.rb b/lib/hello_sign/resource/template.rb index 157d69b..2c10b3a 100644 --- a/lib/hello_sign/resource/template.rb +++ b/lib/hello_sign/resource/template.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # - # Contains information about the templates you and your team have created + # Contains information about Templates. # Take a look at our API Documentation for Templates (https://app.hellosign.com/api/reference#Template) # for more information about this. # # @author [hellosign] - # + class Template < BaseResource - # - # Creates a new Template from a hash. If a key is defined then template data will be the value of hash[key], otherwise the hash itself. + + # Creates a new Template from a hash. If a key is defined then Template data will be the value of hash[key], otherwise the hash itself. # @param hash [Hash] Template's data # @param key [String] (template) Key of the hash, point to where Template data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:Team] a Template resource + # @return [HelloSign::Resource::Template] a Template def initialize(hash, key='template') super end diff --git a/lib/hello_sign/resource/template_draft.rb b/lib/hello_sign/resource/template_draft.rb index 7370905..4beff37 100644 --- a/lib/hello_sign/resource/template_draft.rb +++ b/lib/hello_sign/resource/template_draft.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,24 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - # - # A group of documents that a user can take ownership of by going to the claim_url. + # Contains information about a TemplateDraft. # Take a look at our API Documentation for Templates (https://app.hellosign.com/api/reference#Template) # for more information about this. # # @author [hellosign] - # + class TemplateDraft < BaseResource - # + # Creates a new TemplateDraft from a hash. If a key is defined then TemplateDraft data will be the value of hash[key], otherwise the hash itself. # @param hash [Hash] TemplateDraft's data # @param key [String] (template_draft) Key of the hash, point to where TemplateDraft data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:Team] a Team resource + # @return [HelloSign::Resource::TemplateDraft] a TemplateDraft def initialize(hash, key='template') super end diff --git a/lib/hello_sign/resource/unclaimed_draft.rb b/lib/hello_sign/resource/unclaimed_draft.rb index 1e8050d..5ecc7ed 100644 --- a/lib/hello_sign/resource/unclaimed_draft.rb +++ b/lib/hello_sign/resource/unclaimed_draft.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,26 +19,22 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign module Resource - - # - # A group of documents that a user can take ownership of by going to the claim_url. - # Take a look at our API documentation for creating UnclaimedDrafts (https://app.hellosign.com/api/reference#UnclaimedDraft) + # Contains information about an UnclaimedDraft. + # Take a look at our API documentation for the UnclaimedDraft resource (https://app.hellosign.com/api/reference#UnclaimedDraft) # for more information about this. # # @author [hellosign] - # + class UnclaimedDraft < BaseResource - # - # create a new UnclaimedDraft from a hash. If a key is defined then UnclaimedDraft data with be the value of hash[key], otherwise the hash itself. + # Creates a new UnclaimedDraft from a hash. If a key is defined then UnclaimedDraft data with be the value of hash[key], otherwise the hash itself. # @param hash [Hash] UnclaimedDraft's data # @param key [String] (unclaimed_draft) Key of the hash, point to where UnclaimedDraft data is. If nil, then the hash itself. # - # @return [HelloSign::Resource:Team] an UnclaimedDraft resource + # @return [HelloSign::Resource::UnclaimedDraft] an UnclaimedDraft def initialize(hash, key='unclaimed_draft') super end diff --git a/lib/hello_sign/version.rb b/lib/hello_sign/version.rb index e3e107e..95daefe 100644 --- a/lib/hello_sign/version.rb +++ b/lib/hello_sign/version.rb @@ -1,4 +1,3 @@ -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -20,8 +19,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# module HelloSign - VERSION = '3.7.5' + VERSION = '3.7.6' end diff --git a/spec/fixtures/api_app.json b/spec/fixtures/api_app.json index 305753d..8a347fd 100644 --- a/spec/fixtures/api_app.json +++ b/spec/fixtures/api_app.json @@ -1,16 +1,16 @@ { "api_app": { - "client_id" : "5e365c014bea2e9a05a9d0834f3e7ca4", - "created_at" : 1438030211, - "name" : "Hodor", - "domain" : "hodor.com", - "callback_url" : null, - "owner_account" : { - "account_id" : "626e28a7781d6d12bd830220488a45e9ef3378ab", - "email_address" : "hello@example.com" + "client_id": "5e365c014bea2e9a05a9d0834f3e7ca4", + "created_at": 1438030211, + "name": "Hodor", + "domain": "hodor.com", + "callback_url": null, + "owner_account": { + "account_id": "626e28a7781d6d12bd830220488a45e9ef3378ab", + "email_address": "hello@example.com" }, - "is_approved" : false, - "oauth" : null + "is_approved": false, + "oauth": null } } diff --git a/spec/fixtures/bulk_send_job.json b/spec/fixtures/bulk_send_job.json new file mode 100644 index 0000000..bb3c534 --- /dev/null +++ b/spec/fixtures/bulk_send_job.json @@ -0,0 +1,88 @@ +{ + "bulk_send_job": { + "bulk_send_job_id": "af299494bdcad318b4856aa34aa263dbdaaee9ab", + "total": 3, + "is_creator": true, + "created_at": 1536784104 + }, + "list_info": { + "page": 1, + "num_pages": 1, + "num_results": 2, + "page_size": 20 + }, + "signature_requests": [ + { + "signature_request_id": "76cdec91655d6b26e403e8c10c1def40c26510ok", + "test_mode": true, + "title": "Please sign", + "original_title": "Please sign", + "subject": "This requires your signature", + "message": null, + "metadata": {}, + "is_complete": false, + "is_declined": false, + "has_error": false, + "custom_fields": [], + "response_data": [], + "signing_url": "https://app.hellosign.com/sign/76cdec91655d6b26e403e8c10c1def40c26510ok", + "signing_redirect_url": null, + "final_copy_uri": "/v3/signature_request/final_copy/76cdec91655d6b26e403e8c10c1def40c26510ok", + "files_url": "https://api.hellosign.com/v3/signature_request/files/76cdec91655d6b26e403e8c10c1def40c26510ok", + "details_url": "https://app.hellosign.com/home/manage?guid=76cdec91655d6b26e403e8c10c1def40c26510ok", + "requester_email_address": "requester@example.com", + "signatures": [ + { + "signature_id": "1ccd835c064c4d7936012840924c0528", + "has_pin": false, + "signer_email_address": "bulksend1@example.com", + "signer_name": "George Signer", + "order": null, + "status_code": "signed", + "signed_at": 1542665401, + "last_viewed_at": 1542665391, + "last_reminded_at": null, + "error": null + } + ], + "cc_email_addresses": [], + "bulk_send_job_id": "af299494bdcad318b4856aa34aa263dbdaaee9ab" + }, + { + "signature_request_id": "b2c5c3dfc5ac596e02b7c615b59314b7948abc88", + "test_mode": true, + "title": "Please sign", + "original_title": "Please sign", + "subject": "This requires your signature", + "message": null, + "metadata": {}, + "is_complete": false, + "is_declined": false, + "has_error": false, + "custom_fields": [], + "response_data": [], + "signing_url": "https://app.hellosign.com/sign/b2c5c3dfc5ac596e02b7c615b59314b7948abc88", + "signing_redirect_url": null, + "final_copy_uri": "/v3/signature_request/final_copy/b2c5c3dfc5ac596e02b7c615b59314b7948abc88", + "files_url": "https://api.hellosign.com/v3/signature_request/files/b2c5c3dfc5ac596e02b7c615b59314b7948abc88", + "details_url": "https://app.hellosign.com/home/manage?guid=b2c5c3dfc5ac596e02b7c615b59314b7948abc88", + "requester_email_address": "requester@example.com", + "signatures": [ + { + "signature_id": "2ad95d666374efcfb2bf299855591738", + "has_pin": false, + "signer_email_address": "bulksend2@example.com", + "signer_name": "Mary Signer", + "order": null, + "status_code": "awaiting_signature", + "signed_at": null, + "last_viewed_at": null, + "last_reminded_at": null, + "error": null + } + ], + "cc_email_addresses": [], + "bulk_send_job_id": "af299494bdcad318b4856aa34aa263dbdaaee9ab" + } + ] +} diff --git a/spec/fixtures/bulk_send_jobs.json b/spec/fixtures/bulk_send_jobs.json new file mode 100644 index 0000000..dccae50 --- /dev/null +++ b/spec/fixtures/bulk_send_jobs.json @@ -0,0 +1,22 @@ +{ + "list_info": { + "page": 1, + "num_pages": 1, + "num_results": 2, + "page_size": 20 + }, + "bulk_send_jobs": [ + { + "bulk_send_job_id": "af299494bdcad318b4856aa34aa263dbdaaee9ab", + "total": 2, + "is_creator": true, + "created_at": 1542664362 + }, + { + "bulk_send_job_id": "d74f731b24b00fe6a61083bcff11d0aepl5bf927", + "total": 3, + "is_creator": true, + "created_at": 1542655564 + } + ] +} diff --git a/spec/hello_sign/api/account_spec.rb b/spec/hello_sign/api/account_spec.rb index 768c4df..1bfe439 100644 --- a/spec/hello_sign/api/account_spec.rb +++ b/spec/hello_sign/api/account_spec.rb @@ -23,7 +23,7 @@ describe '#create_account' do before do stub_post('/account/create', 'account') - @body = { :email_address => 'test@example.com' } + @body = { email_address: 'test@example.com' } @account = HelloSign.create_account @body end diff --git a/spec/hello_sign/api/bulk_send_job_spec.rb b/spec/hello_sign/api/bulk_send_job_spec.rb new file mode 100644 index 0000000..196cfb2 --- /dev/null +++ b/spec/hello_sign/api/bulk_send_job_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe HelloSign::Api::BulkSendJob do + describe '#get_bulk_send_job' do + before do + stub_get('/bulk_send_job/1', 'bulk_send_job') + @bulk_send = HelloSign.get_bulk_send_job :bulk_send_job_id => 1 + end + + it 'should get the correct resource' do + expect(a_get('/bulk_send_job/1')).to have_been_made + end + + it 'should return response headers' do + expect(@bulk_send.headers).to_not be_nil + end + + it 'should return a Bulk Send Job' do + expect(@bulk_send).to be_an HelloSign::Resource::BulkSendJob + end + end + + describe '#get_bulk_send_jobs' do + before do + stub_get('/bulk_send_job/list', 'bulk_send_jobs') + @bulk_send_jobs = HelloSign.get_bulk_send_jobs({}) + end + + it 'should get the correct resource' do + expect(a_get('/bulk_send_job/list')).to have_been_made + end + + it 'returns reponse headers' do + expect(@bulk_send_jobs.headers).to_not be_nil + end + + it 'should return a ResourceArray' do + expect(@bulk_send_jobs).to be_an HelloSign::Resource::ResourceArray + end + + it 'each of Array is a BulkSendJob' do + expect(@bulk_send_jobs[0]).to be_an HelloSign::Resource::BulkSendJob + end + + it 'should return list_info as a BaseResource in results' do + expect(@bulk_send_jobs[0].list_info).to be_an HelloSign::Resource::BaseResource + end + + it 'should return page numbers as an integer' do + expect(@bulk_send_jobs[0].list_info.page).to be_an Integer + end + end +end diff --git a/spec/hello_sign_spec.rb b/spec/hello_sign_spec.rb index 8d23584..b5d58e7 100644 --- a/spec/hello_sign_spec.rb +++ b/spec/hello_sign_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper' -# # The MIT License (MIT) -# +# # Copyright (C) 2014 hellosign.com -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights @@ -22,7 +21,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# describe HelloSign do after { HelloSign.reset } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5bf77a5..aac0740 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,6 @@ # loaded once. # -# # The MIT License (MIT) # # Copyright (C) 2014 hellosign.com @@ -26,7 +25,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -# if ENV['TRAVIS'] require 'coveralls'