ClientContext

ClientContext

Represents the execution context of an Operation. An execution context typically consists of the desired authentication credentials and client configurations such as timeouts. Currently, it is set up using a JSON config file which is received as part of DC Services SDK On-boarding.

For each set of authentication credentials, a ClientContext instance can be reused across operations.

Sample Usage:


const clientContext = DCServicesSdk.ClientContext.createFromFile('dc-services-sdk-config.json'),
       createPDFOperation = DCServicesSdk.CreatePDF.Operation.createNew(),
       input = DCServicesSdk.FileRef.createFromLocalFile('files/resources/createPDFInput.docx');

 createPDFOperation.setInput(input);

 createPDFOperation.execute(clientContext)
     .then(result => result.saveAsFile('output/createPDFFromZip.pdf'))
     .catch(err => console.log(err));

Methods

(static) createFromFile(filePath) → {ClientContext}

Creates a context instance using the provided JSON config file path.

Parameters:
Name Type Description
filePath string

Path of the config JSON file.

Throws:

Will throw an error if the provided config file is not found.

Returns:

A ClientContext instance.

Type
ClientContext

withAuthentication(authentication) → {ClientContext}

Creates a copy of this ClientContext with the provided Authentication instance. This can be used to provide the authentication credentials at runtime, without storing them in a config file.

Parameters:
Name Type Description
authentication Authentication

An Authentication instance.

Returns:

A new ClientContext instance.

Type
ClientContext