-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Support sign template * Update type field
- Loading branch information
1 parent
e156e9c
commit 18d3413
Showing
17 changed files
with
475 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Sign Templates | ||
|
||
<!-- TODO autogenerate description --> | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
|
||
- [Get sign template by ID](#get-sign-template-by-id) | ||
- [List sign templates](#list-sign-templates) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
<!-- TODO autogenerate --> | ||
|
||
## Get sign template by ID | ||
|
||
Gets a sign template by ID [`signTemplates.getById(options, callback)`](http://opensource.box.com/box-node-sdk/jsdoc/SignTemplatesManager.html#getById) | ||
method. | ||
|
||
<!-- sample get_sign_templates_id --> | ||
|
||
```js | ||
const sr = await client.signTemplates.getById({ | ||
sign_request_id: 12345, | ||
}); | ||
console.log( | ||
`Sign request id ${sr.id} contains ${sr.source_files.length} files` | ||
); | ||
``` | ||
|
||
## List sign templates | ||
|
||
Gets sign templates created by a user [`signTemplates.getAll(options, callback)`](http://opensource.box.com/box-node-sdk/jsdoc/SignTemplatesManager.html#getAll) | ||
method. | ||
|
||
<!-- sample get_sign_templates --> | ||
|
||
```js | ||
const result = await client.signTemplates.getAll(); | ||
console.log(`There are ${result.count} sign templates`); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import BoxClient from '../box-client'; | ||
import urlPath from '../util/url-path'; | ||
import * as schemas from '../schemas'; | ||
/** | ||
* Simple manager for interacting with all Sign Templates endpoints and actions. | ||
*/ | ||
class SignTemplatesManager { | ||
client: BoxClient; | ||
/** | ||
* @param {BoxClient} client The Box API Client that is responsible for making calls to the API | ||
*/ | ||
constructor(client: BoxClient) { | ||
this.client = client; | ||
} | ||
/** | ||
* Get Box Sign template by ID | ||
* | ||
* Fetches details of a specific Box Sign template. | ||
* @param {object} options Options for the request | ||
* @param {string} options.template_id The ID of a Box Sign template. | ||
* @param {Function} [callback] Passed the result if successful, error otherwise | ||
* @returns {Promise<schemas.SignTemplate>} A promise resolving to the result or rejecting with an error | ||
*/ | ||
getById( | ||
options: { | ||
/** | ||
* The ID of a Box Sign template. | ||
*/ | ||
readonly template_id: string; | ||
}, | ||
callback?: Function | ||
): Promise<schemas.SignTemplate> { | ||
const { template_id: templateId, ...queryParams } = options, | ||
apiPath = urlPath('sign_templates', templateId), | ||
params = { | ||
qs: queryParams, | ||
}; | ||
return this.client.wrapWithDefaultHandler(this.client.get)( | ||
apiPath, | ||
params, | ||
callback | ||
); | ||
} | ||
/** | ||
* List Box Sign templates | ||
* | ||
* Gets Box Sign templates created by a user. | ||
* @param {object} [options] Options for the request | ||
* @param {string} [options.marker] Defines the position marker at which to begin returning results. This is used when paginating using marker-based pagination. This requires `usemarker` to be set to `true`. | ||
* @param {number} [options.limit] The maximum number of items to return per page. | ||
* @param {Function} [callback] Passed the result if successful, error otherwise | ||
* @returns {Promise<schemas.SignTemplates>} A promise resolving to the result or rejecting with an error | ||
*/ | ||
getAll( | ||
options?: { | ||
/** | ||
* Defines the position marker at which to begin returning results. This is | ||
* used when paginating using marker-based pagination. | ||
* | ||
* This requires `usemarker` to be set to `true`. | ||
*/ | ||
readonly marker?: string; | ||
/** | ||
* The maximum number of items to return per page. | ||
*/ | ||
readonly limit?: number; | ||
}, | ||
callback?: Function | ||
): Promise<schemas.SignTemplates> { | ||
const { ...queryParams } = options, | ||
apiPath = urlPath('sign_templates'), | ||
params = { | ||
qs: queryParams, | ||
}; | ||
return this.client.wrapWithDefaultHandler(this.client.get)( | ||
apiPath, | ||
params, | ||
callback | ||
); | ||
} | ||
} | ||
export = SignTemplatesManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as schemas from '.'; | ||
/** | ||
* Box Sign template | ||
* | ||
* A Box Sign template object | ||
*/ | ||
export interface SignTemplate { | ||
/** | ||
* object type | ||
* Example: sign-template | ||
*/ | ||
type?: 'sign-template'; | ||
/** | ||
* Template identifier. | ||
* Example: 4206996024-14944f75-c34b-478a-95a1-264b1ff80d35 | ||
*/ | ||
id?: string; | ||
/** | ||
* The name of the template. | ||
* Example: Official contract | ||
*/ | ||
name?: string; | ||
/** | ||
* Subject of signature request email. This is cleaned by sign request. If this field is not passed, a default subject will be used. | ||
* Example: Sign Request from Acme | ||
*/ | ||
email_subject?: string; | ||
/** | ||
* Message to include in signature request email. The field is cleaned through sanitization of specific characters. However, some html tags are allowed. Links included in the message are also converted to hyperlinks in the email. The message may contain the following html tags including `a`, `abbr`, `acronym`, `b`, `blockquote`, `code`, `em`, `i`, `ul`, `li`, `ol`, and `strong`. Be aware that when the text to html ratio is too high, the email may end up in spam filters. Custom styles on these tags are not allowed. If this field is not passed, a default message will be used. | ||
* Example: Hello! Please sign the document below | ||
*/ | ||
email_message?: string; | ||
/** | ||
* Set the number of days after which the created signature request will automatically expire if not completed. By default, we do not apply any expiration date on signature requests, and the signature request does not expire. | ||
* Example: 2 | ||
*/ | ||
days_valid?: number; | ||
/** | ||
* The destination folder to place final, signed document and signing | ||
* log. Only `ID` and `type` fields are required. The root folder, | ||
* folder ID `0`, cannot be used. | ||
*/ | ||
parent_folder?: schemas.FolderMini; | ||
/** | ||
* List of files to create a signing document from. Only the ID and type fields are required for each file. | ||
*/ | ||
source_files?: schemas.FileMini[]; | ||
/** | ||
* Indicates if the template input fields are editable or not. | ||
*/ | ||
are_fields_locked?: boolean; | ||
/** | ||
* Indicates if the template document options are editable or not, for example renaming the document. | ||
* Example: true | ||
*/ | ||
are_options_locked?: boolean; | ||
/** | ||
* Indicates if the template signers are editable or not. | ||
*/ | ||
are_recipients_locked?: boolean; | ||
/** | ||
* Indicates if the template email settings are editable or not. | ||
* Example: true | ||
*/ | ||
are_email_settings_locked?: boolean; | ||
/** | ||
* Indicates if the template files are editable or not. This includes deleting or renaming template files. | ||
* Example: true | ||
*/ | ||
are_files_locked?: boolean; | ||
/** | ||
* Array of signers for the template. | ||
*/ | ||
signers?: schemas.TemplateSigner[]; | ||
/** | ||
* Additional information on which fields are required and which fields are not editable. | ||
*/ | ||
additional_info?: object; | ||
/** | ||
* Box's ready-sign link feature enables you to create a link to a signature request that you've created from a template. Use this link when you want to post a signature request on a public form — such as an email, social media post, or web page — without knowing who the signers will be. Note: The ready-sign link feature is limited to Enterprise Plus customers and not available to Box Verified Enterprises. | ||
*/ | ||
ready_sign_link?: object; | ||
/** | ||
* Custom branding applied to notifications | ||
* and signature requests. | ||
*/ | ||
custom_branding?: object; | ||
} |
Oops, something went wrong.