0.1.9 • Published 6 months ago

trovir-javascript-sdk v0.1.9

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

TROVIR JAVASCRIPT SDK

Installing

npm install trovir-javascript-sdk

All responses format

{
	error:  if an error has occurred, more information will be here.  if no error, value will be null 
	status: status code of request.  200 if OK.  4XX if a permission/authorization issue.  5XX if error
	data: all data from response will be here. actual format will vary depending on the request.
}

GET FILES

  • @return {Object} data.error - if an error has occurred, more information will be here. if no error, value will be null
  • @return {Object} data.status - status code of request. 200 if OK. 4XX if a permission/authorization issue. 5XX if error
  • @return {Object} data.files.id - unique identifier of file
  • @return {Object} data.files.name - name of file
  • @return {Object} data.files.size - size of file in bytes
  • @return {Object} data.files.created_date - date file was added to Trovir
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFiles();

if (!res.error) {
	console.log('res.data',res.data.files);
} else {
	console.log('res.error', res.error);
}

UPLOAD FILE

  • @return {string} id - id of file that was uploaded
const body = {
	base64: BASE64_ENCODED_FILE,
	mime_type: 'application/pdf',
	name: 'file_name',
	lastModified: '2023-08-31 03:00:00'
}

const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.uploadFile(body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

GET FILE

This retrieves the information about a single file

const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFile(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

GET FILE LINK

This retrieves a link to the raw file that was originally uploaded

  • @return {string} url - path to file
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileLink(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

GET FILE STATUS

This retrieves the status of file processing

  • @return {string} status - current status of the file
  • @return {Object} history - status history for the file. includes the status and timestamp of when it was in the status
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileStatus(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

GET FILE CONTENT

This retrieves the extracted content of the file

const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getFileContent(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

RECLASSIFY FILE

This overrides how a file was classified.

const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const body = { override_record_type: new_record_type_id }
const res = await trovir_client.reclassifyFile(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

ASK QUESTION OF FILE

Ask a user-defined question using the file for context

const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const body = { prompt: 'My question', json_response: true, json_keys: [ 'field1','field2'] }
const res = await trovir_client.fileAskQuestion(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

DELETE FILE

Delete a file from Trovir

const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.fileDelete(my_file_id);

if (!res.error) {
	console.log('res.data',res.data);
} else {
	console.log('res.error', res.error);
}

GET RECORD TYPES

Retrieve the list of record types available within Trovir.

  • @return {Object} record_types.id - id of record type
  • @return {Object} record_types.name - name of record type
const my_file_id = 'TESTING';
const trovir_client = new TrovirSDK({developer_key: MY-DEVKEY-HERE });
const res = await trovir_client.getRecordTypes(my_file_id,body);

if (!res.error) {
	console.log('res.data',res.data.record_types);
} else {
	console.log('res.error', res.error);
}
0.1.8

6 months ago

0.1.7

6 months ago

0.1.9

6 months ago

0.1.6

6 months ago

0.1.5

7 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago