@itentialopensource/adapter-microsoft_dynamics
Version:
This adapter integrates with system described as: Microsoft Dynamics 365: Business Applications
31,637 lines • 1.51 MB
JavaScript
/* @copyright Itential, LLC 2019 (pre-modifications) */
/* eslint import/no-dynamic-require: warn */
/* eslint object-curly-newline: warn */
// Set globals
/* global log */
/* Required libraries. */
const path = require('path');
/* Fetch in the other needed components for the this Adaptor */
const AdapterBaseCl = require(path.join(__dirname, 'adapterBase.js'));
/**
* This is the adapter/interface into Microsoft_dynamics
*/
/* GENERAL ADAPTER FUNCTIONS */
class MicrosoftDynamics extends AdapterBaseCl {
/**
* MicrosoftDynamics Adapter
* @constructor
*/
/* Working on changing the way we do Emit methods due to size and time constrainsts
constructor(prongid, properties) {
// Instantiate the AdapterBase super class
super(prongid, properties);
const restFunctionNames = this.iapGetAdapterWorkflowFunctions();
// Dynamically bind emit functions
for (let i = 0; i < restFunctionNames.length; i += 1) {
// Bind function to have name fnNameEmit for fnName
const version = restFunctionNames[i].match(/__v[0-9]+/);
const baseFnName = restFunctionNames[i].replace(/__v[0-9]+/, '');
const fnNameEmit = version ? `${baseFnName}Emit${version}` : `${baseFnName}Emit`;
this[fnNameEmit] = function (...args) {
// extract the callback
const callback = args[args.length - 1];
// slice the callback from args so we can insert our own
const functionArgs = args.slice(0, args.length - 1);
// create a random name for the listener
const eventName = `${restFunctionNames[i]}:${Math.random().toString(36)}`;
// tell the calling class to start listening
callback({ event: eventName, status: 'received' });
// store parent for use of this context later
const parent = this;
// store emission function
const func = function (val, err) {
parent.removeListener(eventName, func);
parent.emit(eventName, val, err);
};
// Use apply to call the function in a specific context
this[restFunctionNames[i]].apply(this, functionArgs.concat([func])); // eslint-disable-line prefer-spread
};
}
// Uncomment if you have things to add to the constructor like using your own properties.
// Otherwise the constructor in the adapterBase will be used.
// Capture my own properties - they need to be defined in propertiesSchema.json
// if (this.allProps && this.allProps.myownproperty) {
// mypropvariable = this.allProps.myownproperty;
// }
}
*/
/**
* @callback healthCallback
* @param {Object} reqObj - the request to send into the healthcheck
* @param {Callback} callback - The results of the call
*/
healthCheck(reqObj, callback) {
// you can modify what is passed into the healthcheck by changing things in the newReq
let newReq = null;
if (reqObj) {
newReq = Object.assign(...reqObj);
}
super.healthCheck(newReq, callback);
}
/**
* @iapGetAdapterWorkflowFunctions
*/
iapGetAdapterWorkflowFunctions(inIgnore) {
let myIgnore = [
'healthCheck',
'iapGetAdapterWorkflowFunctions',
'hasEntities',
'getAuthorization'
];
if (!inIgnore && Array.isArray(inIgnore)) {
myIgnore = inIgnore;
} else if (!inIgnore && typeof inIgnore === 'string') {
myIgnore = [inIgnore];
}
// The generic adapter functions should already be ignored (e.g. healthCheck)
// you can add specific methods that you do not want to be workflow functions to ignore like below
// myIgnore.push('myMethodNotInWorkflow');
return super.iapGetAdapterWorkflowFunctions(myIgnore);
}
/**
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
* allows customers to make changes to adapter configuration without having to be on the
* file system.
*
* @function iapUpdateAdapterConfiguration
* @param {string} configFile - the name of the file being updated (required)
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
* @param {boolean} replace - true to replace entire mock data, false to merge/append
* @param {Callback} callback - The results of the call
*/
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
const meth = 'adapter-iapUpdateAdapterConfiguration';
const origin = `${this.id}-${meth}`;
log.trace(origin);
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
}
/**
* @summary Suspends adapter
*
* @function iapSuspendAdapter
* @param {Callback} callback - callback function
*/
iapSuspendAdapter(mode, callback) {
const meth = 'adapter-iapSuspendAdapter';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapSuspendAdapter(mode, callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary Unsuspends adapter
*
* @function iapUnsuspendAdapter
* @param {Callback} callback - callback function
*/
iapUnsuspendAdapter(callback) {
const meth = 'adapter-iapUnsuspendAdapter';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapUnsuspendAdapter(callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary Get the Adapter Queue
*
* @function iapGetAdapterQueue
* @param {Callback} callback - callback function
*/
iapGetAdapterQueue(callback) {
const meth = 'adapter-iapGetAdapterQueue';
const origin = `${this.id}-${meth}`;
log.trace(origin);
return super.iapGetAdapterQueue(callback);
}
/* SCRIPT CALLS */
/**
* See if the API path provided is found in this adapter
*
* @function iapFindAdapterPath
* @param {string} apiPath - the api path to check on
* @param {Callback} callback - The results of the call
*/
iapFindAdapterPath(apiPath, callback) {
const meth = 'adapter-iapFindAdapterPath';
const origin = `${this.id}-${meth}`;
log.trace(origin);
super.iapFindAdapterPath(apiPath, callback);
}
/**
* @summary Runs troubleshoot scripts for adapter
*
* @function iapTroubleshootAdapter
* @param {Object} props - the connection, healthcheck and authentication properties
*
* @param {boolean} persistFlag - whether the adapter properties should be updated
* @param {Callback} callback - The results of the call
*/
iapTroubleshootAdapter(props, persistFlag, callback) {
const meth = 'adapter-iapTroubleshootAdapter';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary runs healthcheck script for adapter
*
* @function iapRunAdapterHealthcheck
* @param {Adapter} adapter - adapter instance to troubleshoot
* @param {Callback} callback - callback function
*/
iapRunAdapterHealthcheck(callback) {
const meth = 'adapter-iapRunAdapterHealthcheck';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapRunAdapterHealthcheck(this, callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary runs connectivity check script for adapter
*
* @function iapRunAdapterConnectivity
* @param {Callback} callback - callback function
*/
iapRunAdapterConnectivity(callback) {
const meth = 'adapter-iapRunAdapterConnectivity';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapRunAdapterConnectivity(callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary runs basicGet script for adapter
*
* @function iapRunAdapterBasicGet
* @param {Callback} callback - callback function
*/
iapRunAdapterBasicGet(callback) {
const meth = 'adapter-iapRunAdapterBasicGet';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapRunAdapterBasicGet(callback);
} catch (error) {
log.error(`${origin}: ${error}`);
return callback(null, error);
}
}
/**
* @summary moves entites into Mongo DB
*
* @function iapMoveAdapterEntitiesToDB
* @param {getCallback} callback - a callback function to return the result (Generics)
* or the error
*/
iapMoveAdapterEntitiesToDB(callback) {
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapMoveAdapterEntitiesToDB(callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Deactivate adapter tasks
*
* @function iapDeactivateTasks
*
* @param {Array} tasks - List of tasks to deactivate
* @param {Callback} callback
*/
iapDeactivateTasks(tasks, callback) {
const meth = 'adapter-iapDeactivateTasks';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapDeactivateTasks(tasks, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Activate adapter tasks that have previously been deactivated
*
* @function iapActivateTasks
*
* @param {Array} tasks - List of tasks to activate
* @param {Callback} callback
*/
iapActivateTasks(tasks, callback) {
const meth = 'adapter-iapActivateTasks';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapActivateTasks(tasks, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/* CACHE CALLS */
/**
* @summary Populate the cache for the given entities
*
* @function iapPopulateEntityCache
* @param {String/Array of Strings} entityType - the entity type(s) to populate
* @param {Callback} callback - whether the cache was updated or not for each entity type
*
* @returns status of the populate
*/
iapPopulateEntityCache(entityTypes, callback) {
const meth = 'adapter-iapPopulateEntityCache';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapPopulateEntityCache(entityTypes, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Retrieves data from cache for specified entity type
*
* @function iapRetrieveEntitiesCache
* @param {String} entityType - entity of which to retrieve
* @param {Object} options - settings of which data to return and how to return it
* @param {Callback} callback - the data if it was retrieved
*/
iapRetrieveEntitiesCache(entityType, options, callback) {
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapRetrieveEntitiesCache(entityType, options, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/* BROKER CALLS */
/**
* @summary Determines if this adapter supports any in a list of entities
*
* @function hasEntities
* @param {String} entityType - the entity type to check for
* @param {Array} entityList - the list of entities we are looking for
*
* @param {Callback} callback - A map where the entity is the key and the
* value is true or false
*/
hasEntities(entityType, entityList, callback) {
const meth = 'adapter-hasEntities';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.hasEntities(entityType, entityList, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Get Appliance that match the deviceName
*
* @function getDevice
* @param {String} deviceName - the deviceName to find (required)
*
* @param {getCallback} callback - a callback function to return the result
* (appliance) or the error
*/
getDevice(deviceName, callback) {
const meth = 'adapter-getDevice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.getDevice(deviceName, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Get Appliances that match the filter
*
* @function getDevicesFiltered
* @param {Object} options - the data to use to filter the appliances (optional)
*
* @param {getCallback} callback - a callback function to return the result
* (appliances) or the error
*/
getDevicesFiltered(options, callback) {
const meth = 'adapter-getDevicesFiltered';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.getDevicesFiltered(options, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Gets the status for the provided appliance
*
* @function isAlive
* @param {String} deviceName - the deviceName of the appliance. (required)
*
* @param {configCallback} callback - callback function to return the result
* (appliance isAlive) or the error
*/
isAlive(deviceName, callback) {
const meth = 'adapter-isAlive';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.isAlive(deviceName, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Gets a config for the provided Appliance
*
* @function getConfig
* @param {String} deviceName - the deviceName of the appliance. (required)
* @param {String} format - the desired format of the config. (optional)
*
* @param {configCallback} callback - callback function to return the result
* (appliance config) or the error
*/
getConfig(deviceName, format, callback) {
const meth = 'adapter-getConfig';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.getConfig(deviceName, format, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* @summary Gets the device count from the system
*
* @function iapGetDeviceCount
*
* @param {getCallback} callback - callback function to return the result
* (count) or the error
*/
iapGetDeviceCount(callback) {
const meth = 'adapter-iapGetDeviceCount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapGetDeviceCount(callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
/**
* Makes the requested generic call
*
* @function iapExpandedGenericAdapterRequest
* @param {Object} metadata - metadata for the call (optional).
* Can be a stringified Object.
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
* @param {Object} pathVars - the parameters to be put within the url path (optional).
* Can be a stringified Object.
* @param {Object} queryData - the parameters to be put on the url (optional).
* Can be a stringified Object.
* @param {Object} requestBody - the body to add to the request (optional).
* Can be a stringified Object.
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
* Can be a stringified Object.
* @param {getCallback} callback - a callback function to return the result (Generics)
* or the error
*/
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
const meth = 'adapter-iapExpandedGenericAdapterRequest';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* Makes the requested generic call
*
* @function genericAdapterRequest
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
* @param {Object} queryData - the parameters to be put on the url (optional).
* Can be a stringified Object.
* @param {Object} requestBody - the body to add to the request (optional).
* Can be a stringified Object.
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
* Can be a stringified Object.
* @param {getCallback} callback - a callback function to return the result (Generics)
* or the error
*/
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
const meth = 'adapter-genericAdapterRequest';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/**
* Makes the requested generic call with no base path or version
*
* @function genericAdapterRequestNoBasePath
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
* @param {Object} queryData - the parameters to be put on the url (optional).
* Can be a stringified Object.
* @param {Object} requestBody - the body to add to the request (optional).
* Can be a stringified Object.
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
* Can be a stringified Object.
* @param {getCallback} callback - a callback function to return the result (Generics)
* or the error
*/
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
const meth = 'adapter-genericAdapterRequestNoBasePath';
const origin = `${this.id}-${meth}`;
log.trace(origin);
try {
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
} catch (err) {
log.error(`${origin}: ${err}`);
return callback(null, err);
}
}
/* INVENTORY CALLS */
/**
* @summary run the adapter lint script to return the results.
*
* @function iapRunAdapterLint
* @param {Callback} callback - callback function
*/
iapRunAdapterLint(callback) {
const meth = 'adapter-iapRunAdapterLint';
const origin = `${this.id}-${meth}`;
log.trace(origin);
return super.iapRunAdapterLint(callback);
}
/**
* @summary run the adapter test scripts (baseunit and unit) to return the results.
* can not run integration as there can be implications with that.
*
* @function iapRunAdapterTests
* @param {Callback} callback - callback function
*/
iapRunAdapterTests(callback) {
const meth = 'adapter-iapRunAdapterTests';
const origin = `${this.id}-${meth}`;
log.trace(origin);
return super.iapRunAdapterTests(callback);
}
/**
* @summary provide inventory information abbout the adapter
*
* @function iapGetAdapterInventory
* @param {Callback} callback - callback function
*/
iapGetAdapterInventory(callback) {
const meth = 'adapter-iapGetAdapterInventory';
const origin = `${this.id}-${meth}`;
log.trace(origin);
return super.iapGetAdapterInventory(callback);
}
/**
* @callback healthCallback
* @param {Object} result - the result of the get request (contains an id and a status)
*/
/**
* @callback getCallback
* @param {Object} result - the result of the get request (entity/ies)
* @param {String} error - any error that occurred
*/
/**
* @callback createCallback
* @param {Object} item - the newly created entity
* @param {String} error - any error that occurred
*/
/**
* @callback updateCallback
* @param {String} status - the status of the update action
* @param {String} error - any error that occurred
*/
/**
* @callback deleteCallback
* @param {String} status - the status of the delete action
* @param {String} error - any error that occurred
*/
/**
* @function listCompanies
* @pronghornType method
* @name listCompanies
* @summary listCompanies
*
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCompanies
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCompanies(top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCompanies';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Company', 'listCompanies', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCompanies'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCompany
* @pronghornType method
* @name getCompany
* @summary getCompany
*
* @param {string} companyId - (v1.0) id for company
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCompany
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCompany(companyId, select, callback) {
const meth = 'adapter-getCompany';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Company', 'getCompany', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCompany'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listItems
* @pronghornType method
* @name listItems
* @summary listItems
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listItems
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listItems(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listItems';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Item', 'listItems', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listItems'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postItem
* @pronghornType method
* @name postItem
* @summary postItem
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postItem(companyId, body, callback) {
const meth = 'adapter-postItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Item', 'postItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getItem
* @pronghornType method
* @name getItem
* @summary getItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getItem(companyId, itemId, expand, select, callback) {
const meth = 'adapter-getItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Item', 'getItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteItem
* @pronghornType method
* @name deleteItem
* @summary deleteItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteItem(companyId, itemId, callback) {
const meth = 'adapter-deleteItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Item', 'deleteItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchItem
* @pronghornType method
* @name patchItem
* @summary patchItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchItem(companyId, itemId, body, callback) {
const meth = 'adapter-patchItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Item', 'patchItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPictureForItem
* @pronghornType method
* @name listPictureForItem
* @summary listPictureForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPictureForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPictureForItem(companyId, itemId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPictureForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'listPictureForItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPictureForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPictureForItem
* @pronghornType method
* @name getPictureForItem
* @summary getPictureForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} pictureId - (v1.0) id for picture
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPictureForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPictureForItem(companyId, itemId, pictureId, select, callback) {
const meth = 'adapter-getPictureForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'getPictureForItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPictureForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePictureForItem
* @pronghornType method
* @name deletePictureForItem
* @summary deletePictureForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} pictureId - (v1.0) id for picture
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePictureForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePictureForItem(companyId, itemId, pictureId, callback) {
const meth = 'adapter-deletePictureForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'deletePictureForItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePictureForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPictureForItem
* @pronghornType method
* @name patchPictureForItem
* @summary patchPictureForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} pictureId - (v1.0) id for picture
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPictureForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPictureForItem(companyId, itemId, pictureId, body, callback) {
const meth = 'adapter-patchPictureForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `picture(${pictureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'patchPictureForItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPictureForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPicture
* @pronghornType method
* @name listPicture
* @summary listPicture
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPicture
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPicture(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPicture';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'listPicture', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPicture'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPicture
* @pronghornType method
* @name getPicture
* @summary getPicture
*
* @param {string} companyId - (v1.0) id for company
* @param {string} pictureId - (v1.0) id for picture
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPicture
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPicture(companyId, pictureId, select, callback) {
const meth = 'adapter-getPicture';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'getPicture', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPicture'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePicture
* @pronghornType method
* @name deletePicture
* @summary deletePicture
*
* @param {string} companyId - (v1.0) id for company
* @param {string} pictureId - (v1.0) id for picture
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePicture
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePicture(companyId, pictureId, callback) {
const meth = 'adapter-deletePicture';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'deletePicture', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePicture'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPicture
* @pronghornType method
* @name patchPicture
* @summary patchPicture
*
* @param {string} companyId - (v1.0) id for company
* @param {string} pictureId - (v1.0) id for picture
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPicture
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPicture(companyId, pictureId, body, callback) {
const meth = 'adapter-patchPicture';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `picture(${pictureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'patchPicture', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPicture'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPictureForCustomer
* @pronghornType method
* @name listPictureForCustomer
* @summary listPictureForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPictureForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPictureForCustomer(companyId, customerId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPictureForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'listPictureForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPictureForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPictureForCustomer
* @pronghornType method
* @name getPictureForCustomer
* @summary getPictureForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} pictureId - (v1.0) id for picture
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPictureForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPictureForCustomer(companyId, customerId, pictureId, select, callback) {
const meth = 'adapter-getPictureForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'getPictureForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPictureForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePictureForCustomer
* @pronghornType method
* @name deletePictureForCustomer
* @summary deletePictureForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} pictureId - (v1.0) id for picture
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePictureForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePictureForCustomer(companyId, customerId, pictureId, callback) {
const meth = 'adapter-deletePictureForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'deletePictureForCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePictureForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPictureForCustomer
* @pronghornType method
* @name patchPictureForCustomer
* @summary patchPictureForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} pictureId - (v1.0) id for picture
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPictureForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPictureForCustomer(companyId, customerId, pictureId, body, callback) {
const meth = 'adapter-patchPictureForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `picture(${pictureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'patchPictureForCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPictureForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPictureForVendor
* @pronghornType method
* @name listPictureForVendor
* @summary listPictureForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPictureForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPictureForVendor(companyId, vendorId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPictureForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'listPictureForVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPictureForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPictureForVendor
* @pronghornType method
* @name getPictureForVendor
* @summary getPictureForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} pictureId - (v1.0) id for picture
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPictureForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPictureForVendor(companyId, vendorId, pictureId, select, callback) {
const meth = 'adapter-getPictureForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'getPictureForVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPictureForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePictureForVendor
* @pronghornType method
* @name deletePictureForVendor
* @summary deletePictureForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} pictureId - (v1.0) id for picture
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePictureForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePictureForVendor(companyId, vendorId, pictureId, callback) {
const meth = 'adapter-deletePictureForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'deletePictureForVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePictureForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPictureForVendor
* @pronghornType method
* @name patchPictureForVendor
* @summary patchPictureForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} pictureId - (v1.0) id for picture
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPictureForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPictureForVendor(companyId, vendorId, pictureId, body, callback) {
const meth = 'adapter-patchPictureForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `picture(${pictureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'patchPictureForVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPictureForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPictureForEmployee
* @pronghornType method
* @name listPictureForEmployee
* @summary listPictureForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPictureForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPictureForEmployee(companyId, employeeId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPictureForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'listPictureForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPictureForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPictureForEmployee
* @pronghornType method
* @name getPictureForEmployee
* @summary getPictureForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} pictureId - (v1.0) id for picture
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPictureForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPictureForEmployee(companyId, employeeId, pictureId, select, callback) {
const meth = 'adapter-getPictureForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'getPictureForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPictureForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePictureForEmployee
* @pronghornType method
* @name deletePictureForEmployee
* @summary deletePictureForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} pictureId - (v1.0) id for picture
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePictureForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePictureForEmployee(companyId, employeeId, pictureId, callback) {
const meth = 'adapter-deletePictureForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `picture(${pictureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'deletePictureForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePictureForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPictureForEmployee
* @pronghornType method
* @name patchPictureForEmployee
* @summary patchPictureForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} pictureId - (v1.0) id for picture
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPictureForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPictureForEmployee(companyId, employeeId, pictureId, body, callback) {
const meth = 'adapter-patchPictureForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pictureId === undefined || pictureId === null || pictureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pictureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `picture(${pictureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Picture', 'patchPictureForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPictureForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDefaultDimensionsForItem
* @pronghornType method
* @name listDefaultDimensionsForItem
* @summary listDefaultDimensionsForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDefaultDimensionsForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDefaultDimensionsForItem(companyId, itemId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDefaultDimensionsForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'listDefaultDimensionsForItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDefaultDimensionsForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDefaultDimensionsForItem
* @pronghornType method
* @name postDefaultDimensionsForItem
* @summary postDefaultDimensionsForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDefaultDimensionsForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDefaultDimensionsForItem(companyId, itemId, body, callback) {
const meth = 'adapter-postDefaultDimensionsForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'postDefaultDimensionsForItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDefaultDimensionsForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDefaultDimensionsForItem
* @pronghornType method
* @name getDefaultDimensionsForItem
* @summary getDefaultDimensionsForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDefaultDimensionsForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDefaultDimensionsForItem(companyId, itemId, defaultDimensionsParentId, defaultDimensionsDimensionId, expand, select, callback) {
const meth = 'adapter-getDefaultDimensionsForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'getDefaultDimensionsForItem', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDefaultDimensionsForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDefaultDimensionsForItem
* @pronghornType method
* @name deleteDefaultDimensionsForItem
* @summary deleteDefaultDimensionsForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDefaultDimensionsForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDefaultDimensionsForItem(companyId, itemId, defaultDimensionsParentId, defaultDimensionsDimensionId, callback) {
const meth = 'adapter-deleteDefaultDimensionsForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'deleteDefaultDimensionsForItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDefaultDimensionsForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDefaultDimensionsForItem
* @pronghornType method
* @name patchDefaultDimensionsForItem
* @summary patchDefaultDimensionsForItem
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemId - (v1.0) id for item
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDefaultDimensionsForItem
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDefaultDimensionsForItem(companyId, itemId, defaultDimensionsParentId, defaultDimensionsDimensionId, body, callback) {
const meth = 'adapter-patchDefaultDimensionsForItem';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemId === undefined || itemId === null || itemId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `items(${itemId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'patchDefaultDimensionsForItem', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDefaultDimensionsForItem'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDefaultDimensions
* @pronghornType method
* @name listDefaultDimensions
* @summary listDefaultDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDefaultDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDefaultDimensions(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDefaultDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'listDefaultDimensions', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDefaultDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDefaultDimensions
* @pronghornType method
* @name postDefaultDimensions
* @summary postDefaultDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDefaultDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDefaultDimensions(companyId, body, callback) {
const meth = 'adapter-postDefaultDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'postDefaultDimensions', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDefaultDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDefaultDimensions
* @pronghornType method
* @name getDefaultDimensions
* @summary getDefaultDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDefaultDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDefaultDimensions(companyId, defaultDimensionsParentId, defaultDimensionsDimensionId, expand, select, callback) {
const meth = 'adapter-getDefaultDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'getDefaultDimensions', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDefaultDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDefaultDimensions
* @pronghornType method
* @name deleteDefaultDimensions
* @summary deleteDefaultDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDefaultDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDefaultDimensions(companyId, defaultDimensionsParentId, defaultDimensionsDimensionId, callback) {
const meth = 'adapter-deleteDefaultDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'deleteDefaultDimensions', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDefaultDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDefaultDimensions
* @pronghornType method
* @name patchDefaultDimensions
* @summary patchDefaultDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDefaultDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDefaultDimensions(companyId, defaultDimensionsParentId, defaultDimensionsDimensionId, body, callback) {
const meth = 'adapter-patchDefaultDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'patchDefaultDimensions', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDefaultDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDefaultDimensionsForCustomer
* @pronghornType method
* @name listDefaultDimensionsForCustomer
* @summary listDefaultDimensionsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDefaultDimensionsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDefaultDimensionsForCustomer(companyId, customerId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDefaultDimensionsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'listDefaultDimensionsForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDefaultDimensionsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDefaultDimensionsForCustomer
* @pronghornType method
* @name postDefaultDimensionsForCustomer
* @summary postDefaultDimensionsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDefaultDimensionsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDefaultDimensionsForCustomer(companyId, customerId, body, callback) {
const meth = 'adapter-postDefaultDimensionsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'postDefaultDimensionsForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDefaultDimensionsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDefaultDimensionsForCustomer
* @pronghornType method
* @name getDefaultDimensionsForCustomer
* @summary getDefaultDimensionsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDefaultDimensionsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDefaultDimensionsForCustomer(companyId, customerId, defaultDimensionsParentId, defaultDimensionsDimensionId, expand, select, callback) {
const meth = 'adapter-getDefaultDimensionsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'getDefaultDimensionsForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDefaultDimensionsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDefaultDimensionsForCustomer
* @pronghornType method
* @name deleteDefaultDimensionsForCustomer
* @summary deleteDefaultDimensionsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDefaultDimensionsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDefaultDimensionsForCustomer(companyId, customerId, defaultDimensionsParentId, defaultDimensionsDimensionId, callback) {
const meth = 'adapter-deleteDefaultDimensionsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'deleteDefaultDimensionsForCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDefaultDimensionsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDefaultDimensionsForCustomer
* @pronghornType method
* @name patchDefaultDimensionsForCustomer
* @summary patchDefaultDimensionsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDefaultDimensionsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDefaultDimensionsForCustomer(companyId, customerId, defaultDimensionsParentId, defaultDimensionsDimensionId, body, callback) {
const meth = 'adapter-patchDefaultDimensionsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'patchDefaultDimensionsForCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDefaultDimensionsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDefaultDimensionsForVendor
* @pronghornType method
* @name listDefaultDimensionsForVendor
* @summary listDefaultDimensionsForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDefaultDimensionsForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDefaultDimensionsForVendor(companyId, vendorId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDefaultDimensionsForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'listDefaultDimensionsForVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDefaultDimensionsForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDefaultDimensionsForVendor
* @pronghornType method
* @name postDefaultDimensionsForVendor
* @summary postDefaultDimensionsForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDefaultDimensionsForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDefaultDimensionsForVendor(companyId, vendorId, body, callback) {
const meth = 'adapter-postDefaultDimensionsForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'postDefaultDimensionsForVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDefaultDimensionsForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDefaultDimensionsForVendor
* @pronghornType method
* @name getDefaultDimensionsForVendor
* @summary getDefaultDimensionsForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDefaultDimensionsForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDefaultDimensionsForVendor(companyId, vendorId, defaultDimensionsParentId, defaultDimensionsDimensionId, expand, select, callback) {
const meth = 'adapter-getDefaultDimensionsForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'getDefaultDimensionsForVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDefaultDimensionsForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDefaultDimensionsForVendor
* @pronghornType method
* @name deleteDefaultDimensionsForVendor
* @summary deleteDefaultDimensionsForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDefaultDimensionsForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDefaultDimensionsForVendor(companyId, vendorId, defaultDimensionsParentId, defaultDimensionsDimensionId, callback) {
const meth = 'adapter-deleteDefaultDimensionsForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'deleteDefaultDimensionsForVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDefaultDimensionsForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDefaultDimensionsForVendor
* @pronghornType method
* @name patchDefaultDimensionsForVendor
* @summary patchDefaultDimensionsForVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDefaultDimensionsForVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDefaultDimensionsForVendor(companyId, vendorId, defaultDimensionsParentId, defaultDimensionsDimensionId, body, callback) {
const meth = 'adapter-patchDefaultDimensionsForVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'patchDefaultDimensionsForVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDefaultDimensionsForVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDefaultDimensionsForEmployee
* @pronghornType method
* @name listDefaultDimensionsForEmployee
* @summary listDefaultDimensionsForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDefaultDimensionsForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDefaultDimensionsForEmployee(companyId, employeeId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDefaultDimensionsForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'listDefaultDimensionsForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDefaultDimensionsForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDefaultDimensionsForEmployee
* @pronghornType method
* @name postDefaultDimensionsForEmployee
* @summary postDefaultDimensionsForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDefaultDimensionsForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDefaultDimensionsForEmployee(companyId, employeeId, body, callback) {
const meth = 'adapter-postDefaultDimensionsForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'postDefaultDimensionsForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDefaultDimensionsForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDefaultDimensionsForEmployee
* @pronghornType method
* @name getDefaultDimensionsForEmployee
* @summary getDefaultDimensionsForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDefaultDimensionsForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDefaultDimensionsForEmployee(companyId, employeeId, defaultDimensionsParentId, defaultDimensionsDimensionId, expand, select, callback) {
const meth = 'adapter-getDefaultDimensionsForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'getDefaultDimensionsForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDefaultDimensionsForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDefaultDimensionsForEmployee
* @pronghornType method
* @name deleteDefaultDimensionsForEmployee
* @summary deleteDefaultDimensionsForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDefaultDimensionsForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDefaultDimensionsForEmployee(companyId, employeeId, defaultDimensionsParentId, defaultDimensionsDimensionId, callback) {
const meth = 'adapter-deleteDefaultDimensionsForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'deleteDefaultDimensionsForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDefaultDimensionsForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDefaultDimensionsForEmployee
* @pronghornType method
* @name patchDefaultDimensionsForEmployee
* @summary patchDefaultDimensionsForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} defaultDimensionsParentId - (v1.0) parentId for defaultDimensions
* @param {string} defaultDimensionsDimensionId - (v1.0) dimensionId for defaultDimensions
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDefaultDimensionsForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDefaultDimensionsForEmployee(companyId, employeeId, defaultDimensionsParentId, defaultDimensionsDimensionId, body, callback) {
const meth = 'adapter-patchDefaultDimensionsForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsParentId === undefined || defaultDimensionsParentId === null || defaultDimensionsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (defaultDimensionsDimensionId === undefined || defaultDimensionsDimensionId === null || defaultDimensionsDimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['defaultDimensionsDimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `defaultDimensions(${defaultDimensionsParentId},${defaultDimensionsDimensionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DefaultDimensions', 'patchDefaultDimensionsForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDefaultDimensionsForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomers
* @pronghornType method
* @name listCustomers
* @summary listCustomers
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomers
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomers(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listCustomers';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Customer', 'listCustomers', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomers'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCustomer
* @pronghornType method
* @name postCustomer
* @summary postCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCustomer(companyId, body, callback) {
const meth = 'adapter-postCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Customer', 'postCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomer
* @pronghornType method
* @name getCustomer
* @summary getCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomer(companyId, customerId, expand, select, callback) {
const meth = 'adapter-getCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Customer', 'getCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCustomer
* @pronghornType method
* @name deleteCustomer
* @summary deleteCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCustomer(companyId, customerId, callback) {
const meth = 'adapter-deleteCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Customer', 'deleteCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCustomer
* @pronghornType method
* @name patchCustomer
* @summary patchCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCustomer(companyId, customerId, body, callback) {
const meth = 'adapter-patchCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Customer', 'patchCustomer', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerFinancialDetailsForCustomer
* @pronghornType method
* @name listCustomerFinancialDetailsForCustomer
* @summary listCustomerFinancialDetailsForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerFinancialDetailsForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerFinancialDetailsForCustomer(companyId, customerId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCustomerFinancialDetailsForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerFinancialDetail', 'listCustomerFinancialDetailsForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerFinancialDetailsForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerFinancialDetailForCustomer
* @pronghornType method
* @name getCustomerFinancialDetailForCustomer
* @summary getCustomerFinancialDetailForCustomer
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerId - (v1.0) id for customer
* @param {string} customerFinancialDetailId - (v1.0) id for customerFinancialDetail
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerFinancialDetailForCustomer
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerFinancialDetailForCustomer(companyId, customerId, customerFinancialDetailId, select, callback) {
const meth = 'adapter-getCustomerFinancialDetailForCustomer';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerId === undefined || customerId === null || customerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerFinancialDetailId === undefined || customerFinancialDetailId === null || customerFinancialDetailId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerFinancialDetailId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customers(${customerId})`, `customerFinancialDetails(${customerFinancialDetailId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerFinancialDetail', 'getCustomerFinancialDetailForCustomer', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerFinancialDetailForCustomer'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerFinancialDetails
* @pronghornType method
* @name listCustomerFinancialDetails
* @summary listCustomerFinancialDetails
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerFinancialDetails
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerFinancialDetails(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCustomerFinancialDetails';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerFinancialDetail', 'listCustomerFinancialDetails', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerFinancialDetails'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerFinancialDetail
* @pronghornType method
* @name getCustomerFinancialDetail
* @summary getCustomerFinancialDetail
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerFinancialDetailId - (v1.0) id for customerFinancialDetail
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerFinancialDetail
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerFinancialDetail(companyId, customerFinancialDetailId, select, callback) {
const meth = 'adapter-getCustomerFinancialDetail';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerFinancialDetailId === undefined || customerFinancialDetailId === null || customerFinancialDetailId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerFinancialDetailId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerFinancialDetails(${customerFinancialDetailId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerFinancialDetail', 'getCustomerFinancialDetail', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerFinancialDetail'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listVendors
* @pronghornType method
* @name listVendors
* @summary listVendors
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listVendors
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listVendors(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listVendors';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Vendor', 'listVendors', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listVendors'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postVendor
* @pronghornType method
* @name postVendor
* @summary postVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postVendor(companyId, body, callback) {
const meth = 'adapter-postVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Vendor', 'postVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getVendor
* @pronghornType method
* @name getVendor
* @summary getVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getVendor(companyId, vendorId, expand, select, callback) {
const meth = 'adapter-getVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Vendor', 'getVendor', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteVendor
* @pronghornType method
* @name deleteVendor
* @summary deleteVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteVendor(companyId, vendorId, callback) {
const meth = 'adapter-deleteVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Vendor', 'deleteVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchVendor
* @pronghornType method
* @name patchVendor
* @summary patchVendor
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorId - (v1.0) id for vendor
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchVendor
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchVendor(companyId, vendorId, body, callback) {
const meth = 'adapter-patchVendor';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorId === undefined || vendorId === null || vendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendors(${vendorId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Vendor', 'patchVendor', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchVendor'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCompanyInformation
* @pronghornType method
* @name listCompanyInformation
* @summary listCompanyInformation
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCompanyInformation
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCompanyInformation(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCompanyInformation';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CompanyInformation', 'listCompanyInformation', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCompanyInformation'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCompanyInformation
* @pronghornType method
* @name getCompanyInformation
* @summary getCompanyInformation
*
* @param {string} companyId - (v1.0) id for company
* @param {string} companyInformationId - (v1.0) id for companyInformation
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCompanyInformation
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCompanyInformation(companyId, companyInformationId, select, callback) {
const meth = 'adapter-getCompanyInformation';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (companyInformationId === undefined || companyInformationId === null || companyInformationId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyInformationId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `companyInformation(${companyInformationId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CompanyInformation', 'getCompanyInformation', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCompanyInformation'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCompanyInformation
* @pronghornType method
* @name patchCompanyInformation
* @summary patchCompanyInformation
*
* @param {string} companyId - (v1.0) id for company
* @param {string} companyInformationId - (v1.0) id for companyInformation
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCompanyInformation
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCompanyInformation(companyId, companyInformationId, body, callback) {
const meth = 'adapter-patchCompanyInformation';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (companyInformationId === undefined || companyInformationId === null || companyInformationId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyInformationId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `companyInformation(${companyInformationId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CompanyInformation', 'patchCompanyInformation', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCompanyInformation'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesInvoices
* @pronghornType method
* @name listSalesInvoices
* @summary listSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesInvoices(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'listSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesInvoice
* @pronghornType method
* @name postSalesInvoice
* @summary postSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesInvoice(companyId, body, callback) {
const meth = 'adapter-postSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'postSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesInvoice
* @pronghornType method
* @name getSalesInvoice
* @summary getSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesInvoice(companyId, salesInvoiceId, expand, select, callback) {
const meth = 'adapter-getSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'getSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesInvoice
* @pronghornType method
* @name deleteSalesInvoice
* @summary deleteSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesInvoice(companyId, salesInvoiceId, callback) {
const meth = 'adapter-deleteSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'deleteSalesInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesInvoice
* @pronghornType method
* @name patchSalesInvoice
* @summary patchSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesInvoice(companyId, salesInvoiceId, body, callback) {
const meth = 'adapter-patchSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'patchSalesInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function cancelAndSendActionSalesInvoices
* @pronghornType method
* @name cancelAndSendActionSalesInvoices
* @summary cancelAndSendActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /cancelAndSendActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
cancelAndSendActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-cancelAndSendActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'cancelAndSendActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['cancelAndSendActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function cancelActionSalesInvoices
* @pronghornType method
* @name cancelActionSalesInvoices
* @summary cancelActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /cancelActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
cancelActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-cancelActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'cancelActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['cancelActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function makeCorrectiveCreditMemoActionSalesInvoices
* @pronghornType method
* @name makeCorrectiveCreditMemoActionSalesInvoices
* @summary makeCorrectiveCreditMemoActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /makeCorrectiveCreditMemoActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
makeCorrectiveCreditMemoActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-makeCorrectiveCreditMemoActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'makeCorrectiveCreditMemoActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['makeCorrectiveCreditMemoActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postAndSendActionSalesInvoices
* @pronghornType method
* @name postAndSendActionSalesInvoices
* @summary postAndSendActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postAndSendActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postAndSendActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-postAndSendActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'postAndSendActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postAndSendActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postActionSalesInvoices
* @pronghornType method
* @name postActionSalesInvoices
* @summary postActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-postActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'postActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function sendActionSalesInvoices
* @pronghornType method
* @name sendActionSalesInvoices
* @summary sendActionSalesInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /sendActionSalesInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
sendActionSalesInvoices(companyId, salesInvoiceId, callback) {
const meth = 'adapter-sendActionSalesInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoice', 'sendActionSalesInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['sendActionSalesInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesInvoiceLinesForSalesInvoice
* @pronghornType method
* @name listSalesInvoiceLinesForSalesInvoice
* @summary listSalesInvoiceLinesForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesInvoiceLinesForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesInvoiceLinesForSalesInvoice(companyId, salesInvoiceId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesInvoiceLinesForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'listSalesInvoiceLinesForSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesInvoiceLinesForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesInvoiceLineForSalesInvoice
* @pronghornType method
* @name postSalesInvoiceLineForSalesInvoice
* @summary postSalesInvoiceLineForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesInvoiceLineForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesInvoiceLineForSalesInvoice(companyId, salesInvoiceId, body, callback) {
const meth = 'adapter-postSalesInvoiceLineForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'postSalesInvoiceLineForSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesInvoiceLineForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesInvoiceLineForSalesInvoice
* @pronghornType method
* @name getSalesInvoiceLineForSalesInvoice
* @summary getSalesInvoiceLineForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesInvoiceLineForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesInvoiceLineForSalesInvoice(companyId, salesInvoiceId, salesInvoiceLineId, expand, select, callback) {
const meth = 'adapter-getSalesInvoiceLineForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'getSalesInvoiceLineForSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesInvoiceLineForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesInvoiceLineForSalesInvoice
* @pronghornType method
* @name deleteSalesInvoiceLineForSalesInvoice
* @summary deleteSalesInvoiceLineForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesInvoiceLineForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesInvoiceLineForSalesInvoice(companyId, salesInvoiceId, salesInvoiceLineId, callback) {
const meth = 'adapter-deleteSalesInvoiceLineForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'deleteSalesInvoiceLineForSalesInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesInvoiceLineForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesInvoiceLineForSalesInvoice
* @pronghornType method
* @name patchSalesInvoiceLineForSalesInvoice
* @summary patchSalesInvoiceLineForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesInvoiceLineForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesInvoiceLineForSalesInvoice(companyId, salesInvoiceId, salesInvoiceLineId, body, callback) {
const meth = 'adapter-patchSalesInvoiceLineForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'patchSalesInvoiceLineForSalesInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesInvoiceLineForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesInvoiceLines
* @pronghornType method
* @name listSalesInvoiceLines
* @summary listSalesInvoiceLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesInvoiceLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesInvoiceLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesInvoiceLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'listSalesInvoiceLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesInvoiceLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesInvoiceLine
* @pronghornType method
* @name postSalesInvoiceLine
* @summary postSalesInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesInvoiceLine(companyId, body, callback) {
const meth = 'adapter-postSalesInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'postSalesInvoiceLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesInvoiceLine
* @pronghornType method
* @name getSalesInvoiceLine
* @summary getSalesInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesInvoiceLine(companyId, salesInvoiceLineId, expand, select, callback) {
const meth = 'adapter-getSalesInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'getSalesInvoiceLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesInvoiceLine
* @pronghornType method
* @name deleteSalesInvoiceLine
* @summary deleteSalesInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesInvoiceLine(companyId, salesInvoiceLineId, callback) {
const meth = 'adapter-deleteSalesInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'deleteSalesInvoiceLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesInvoiceLine
* @pronghornType method
* @name patchSalesInvoiceLine
* @summary patchSalesInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceLineId - (v1.0) id for salesInvoiceLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesInvoiceLine(companyId, salesInvoiceLineId, body, callback) {
const meth = 'adapter-patchSalesInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceLineId === undefined || salesInvoiceLineId === null || salesInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoiceLines('${salesInvoiceLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesInvoiceLine', 'patchSalesInvoiceLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPdfDocumentForSalesInvoice
* @pronghornType method
* @name listPdfDocumentForSalesInvoice
* @summary listPdfDocumentForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPdfDocumentForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPdfDocumentForSalesInvoice(companyId, salesInvoiceId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPdfDocumentForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'listPdfDocumentForSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPdfDocumentForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPdfDocumentForSalesInvoice
* @pronghornType method
* @name getPdfDocumentForSalesInvoice
* @summary getPdfDocumentForSalesInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesInvoiceId - (v1.0) id for salesInvoice
* @param {string} pdfDocumentId - (v1.0) id for pdfDocument
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPdfDocumentForSalesInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPdfDocumentForSalesInvoice(companyId, salesInvoiceId, pdfDocumentId, select, callback) {
const meth = 'adapter-getPdfDocumentForSalesInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesInvoiceId === undefined || salesInvoiceId === null || salesInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pdfDocumentId === undefined || pdfDocumentId === null || pdfDocumentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pdfDocumentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesInvoices(${salesInvoiceId})`, `pdfDocument(${pdfDocumentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'getPdfDocumentForSalesInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPdfDocumentForSalesInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPdfDocument
* @pronghornType method
* @name listPdfDocument
* @summary listPdfDocument
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPdfDocument
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPdfDocument(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPdfDocument';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'listPdfDocument', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPdfDocument'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPdfDocument
* @pronghornType method
* @name getPdfDocument
* @summary getPdfDocument
*
* @param {string} companyId - (v1.0) id for company
* @param {string} pdfDocumentId - (v1.0) id for pdfDocument
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPdfDocument
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPdfDocument(companyId, pdfDocumentId, select, callback) {
const meth = 'adapter-getPdfDocument';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pdfDocumentId === undefined || pdfDocumentId === null || pdfDocumentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pdfDocumentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `pdfDocument(${pdfDocumentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'getPdfDocument', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPdfDocument'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPdfDocumentForSalesQuote
* @pronghornType method
* @name listPdfDocumentForSalesQuote
* @summary listPdfDocumentForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPdfDocumentForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPdfDocumentForSalesQuote(companyId, salesQuoteId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPdfDocumentForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'listPdfDocumentForSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPdfDocumentForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPdfDocumentForSalesQuote
* @pronghornType method
* @name getPdfDocumentForSalesQuote
* @summary getPdfDocumentForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {string} pdfDocumentId - (v1.0) id for pdfDocument
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPdfDocumentForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPdfDocumentForSalesQuote(companyId, salesQuoteId, pdfDocumentId, select, callback) {
const meth = 'adapter-getPdfDocumentForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pdfDocumentId === undefined || pdfDocumentId === null || pdfDocumentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pdfDocumentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`, `pdfDocument(${pdfDocumentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'getPdfDocumentForSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPdfDocumentForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPdfDocumentForSalesCreditMemo
* @pronghornType method
* @name listPdfDocumentForSalesCreditMemo
* @summary listPdfDocumentForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPdfDocumentForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPdfDocumentForSalesCreditMemo(companyId, salesCreditMemoId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPdfDocumentForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'listPdfDocumentForSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPdfDocumentForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPdfDocumentForSalesCreditMemo
* @pronghornType method
* @name getPdfDocumentForSalesCreditMemo
* @summary getPdfDocumentForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {string} pdfDocumentId - (v1.0) id for pdfDocument
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPdfDocumentForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPdfDocumentForSalesCreditMemo(companyId, salesCreditMemoId, pdfDocumentId, select, callback) {
const meth = 'adapter-getPdfDocumentForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pdfDocumentId === undefined || pdfDocumentId === null || pdfDocumentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pdfDocumentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`, `pdfDocument(${pdfDocumentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'getPdfDocumentForSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPdfDocumentForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPdfDocumentForPurchaseInvoice
* @pronghornType method
* @name listPdfDocumentForPurchaseInvoice
* @summary listPdfDocumentForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPdfDocumentForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPdfDocumentForPurchaseInvoice(companyId, purchaseInvoiceId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPdfDocumentForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'listPdfDocumentForPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPdfDocumentForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPdfDocumentForPurchaseInvoice
* @pronghornType method
* @name getPdfDocumentForPurchaseInvoice
* @summary getPdfDocumentForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {string} pdfDocumentId - (v1.0) id for pdfDocument
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPdfDocumentForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPdfDocumentForPurchaseInvoice(companyId, purchaseInvoiceId, pdfDocumentId, select, callback) {
const meth = 'adapter-getPdfDocumentForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (pdfDocumentId === undefined || pdfDocumentId === null || pdfDocumentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['pdfDocumentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`, `pdfDocument(${pdfDocumentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PdfDocument', 'getPdfDocumentForPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPdfDocumentForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerPaymentJournals
* @pronghornType method
* @name listCustomerPaymentJournals
* @summary listCustomerPaymentJournals
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerPaymentJournals
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerPaymentJournals(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listCustomerPaymentJournals';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPaymentJournal', 'listCustomerPaymentJournals', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerPaymentJournals'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCustomerPaymentJournal
* @pronghornType method
* @name postCustomerPaymentJournal
* @summary postCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCustomerPaymentJournal(companyId, body, callback) {
const meth = 'adapter-postCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPaymentJournal', 'postCustomerPaymentJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerPaymentJournal
* @pronghornType method
* @name getCustomerPaymentJournal
* @summary getCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerPaymentJournal(companyId, customerPaymentJournalId, expand, select, callback) {
const meth = 'adapter-getCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPaymentJournal', 'getCustomerPaymentJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCustomerPaymentJournal
* @pronghornType method
* @name deleteCustomerPaymentJournal
* @summary deleteCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCustomerPaymentJournal(companyId, customerPaymentJournalId, callback) {
const meth = 'adapter-deleteCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPaymentJournal', 'deleteCustomerPaymentJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCustomerPaymentJournal
* @pronghornType method
* @name patchCustomerPaymentJournal
* @summary patchCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCustomerPaymentJournal(companyId, customerPaymentJournalId, body, callback) {
const meth = 'adapter-patchCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPaymentJournal', 'patchCustomerPaymentJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerPaymentsForCustomerPaymentJournal
* @pronghornType method
* @name listCustomerPaymentsForCustomerPaymentJournal
* @summary listCustomerPaymentsForCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerPaymentsForCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerPaymentsForCustomerPaymentJournal(companyId, customerPaymentJournalId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listCustomerPaymentsForCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'listCustomerPaymentsForCustomerPaymentJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerPaymentsForCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCustomerPaymentForCustomerPaymentJournal
* @pronghornType method
* @name postCustomerPaymentForCustomerPaymentJournal
* @summary postCustomerPaymentForCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCustomerPaymentForCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCustomerPaymentForCustomerPaymentJournal(companyId, customerPaymentJournalId, body, callback) {
const meth = 'adapter-postCustomerPaymentForCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'postCustomerPaymentForCustomerPaymentJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCustomerPaymentForCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerPaymentForCustomerPaymentJournal
* @pronghornType method
* @name getCustomerPaymentForCustomerPaymentJournal
* @summary getCustomerPaymentForCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerPaymentForCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerPaymentForCustomerPaymentJournal(companyId, customerPaymentJournalId, customerPaymentId, expand, select, callback) {
const meth = 'adapter-getCustomerPaymentForCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'getCustomerPaymentForCustomerPaymentJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerPaymentForCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCustomerPaymentForCustomerPaymentJournal
* @pronghornType method
* @name deleteCustomerPaymentForCustomerPaymentJournal
* @summary deleteCustomerPaymentForCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCustomerPaymentForCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCustomerPaymentForCustomerPaymentJournal(companyId, customerPaymentJournalId, customerPaymentId, callback) {
const meth = 'adapter-deleteCustomerPaymentForCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'deleteCustomerPaymentForCustomerPaymentJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCustomerPaymentForCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCustomerPaymentForCustomerPaymentJournal
* @pronghornType method
* @name patchCustomerPaymentForCustomerPaymentJournal
* @summary patchCustomerPaymentForCustomerPaymentJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentJournalId - (v1.0) id for customerPaymentJournal
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCustomerPaymentForCustomerPaymentJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCustomerPaymentForCustomerPaymentJournal(companyId, customerPaymentJournalId, customerPaymentId, body, callback) {
const meth = 'adapter-patchCustomerPaymentForCustomerPaymentJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentJournalId === undefined || customerPaymentJournalId === null || customerPaymentJournalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentJournalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPaymentJournals(${customerPaymentJournalId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'patchCustomerPaymentForCustomerPaymentJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCustomerPaymentForCustomerPaymentJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerPayments
* @pronghornType method
* @name listCustomerPayments
* @summary listCustomerPayments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerPayments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerPayments(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listCustomerPayments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'listCustomerPayments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerPayments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCustomerPayment
* @pronghornType method
* @name postCustomerPayment
* @summary postCustomerPayment
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCustomerPayment
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCustomerPayment(companyId, body, callback) {
const meth = 'adapter-postCustomerPayment';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'postCustomerPayment', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCustomerPayment'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerPayment
* @pronghornType method
* @name getCustomerPayment
* @summary getCustomerPayment
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerPayment
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerPayment(companyId, customerPaymentId, expand, select, callback) {
const meth = 'adapter-getCustomerPayment';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'getCustomerPayment', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerPayment'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCustomerPayment
* @pronghornType method
* @name deleteCustomerPayment
* @summary deleteCustomerPayment
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCustomerPayment
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCustomerPayment(companyId, customerPaymentId, callback) {
const meth = 'adapter-deleteCustomerPayment';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'deleteCustomerPayment', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCustomerPayment'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCustomerPayment
* @pronghornType method
* @name patchCustomerPayment
* @summary patchCustomerPayment
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerPaymentId - (v1.0) id for customerPayment
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCustomerPayment
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCustomerPayment(companyId, customerPaymentId, body, callback) {
const meth = 'adapter-patchCustomerPayment';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerPaymentId === undefined || customerPaymentId === null || customerPaymentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerPaymentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerPayments(${customerPaymentId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerPayment', 'patchCustomerPayment', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCustomerPayment'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAccounts
* @pronghornType method
* @name listAccounts
* @summary listAccounts
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAccounts
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAccounts(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAccounts';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Account', 'listAccounts', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAccounts'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAccount
* @pronghornType method
* @name getAccount
* @summary getAccount
*
* @param {string} companyId - (v1.0) id for company
* @param {string} accountId - (v1.0) id for account
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAccount
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAccount(companyId, accountId, select, callback) {
const meth = 'adapter-getAccount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (accountId === undefined || accountId === null || accountId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['accountId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `accounts(${accountId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Account', 'getAccount', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAccount'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listTaxGroups
* @pronghornType method
* @name listTaxGroups
* @summary listTaxGroups
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listTaxGroups
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listTaxGroups(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listTaxGroups';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxGroup', 'listTaxGroups', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listTaxGroups'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postTaxGroup
* @pronghornType method
* @name postTaxGroup
* @summary postTaxGroup
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postTaxGroup
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postTaxGroup(companyId, body, callback) {
const meth = 'adapter-postTaxGroup';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxGroup', 'postTaxGroup', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postTaxGroup'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getTaxGroup
* @pronghornType method
* @name getTaxGroup
* @summary getTaxGroup
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxGroupId - (v1.0) id for taxGroup
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getTaxGroup
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getTaxGroup(companyId, taxGroupId, select, callback) {
const meth = 'adapter-getTaxGroup';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxGroupId === undefined || taxGroupId === null || taxGroupId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxGroupId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxGroups(${taxGroupId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxGroup', 'getTaxGroup', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTaxGroup'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteTaxGroup
* @pronghornType method
* @name deleteTaxGroup
* @summary deleteTaxGroup
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxGroupId - (v1.0) id for taxGroup
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteTaxGroup
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteTaxGroup(companyId, taxGroupId, callback) {
const meth = 'adapter-deleteTaxGroup';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxGroupId === undefined || taxGroupId === null || taxGroupId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxGroupId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxGroups(${taxGroupId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxGroup', 'deleteTaxGroup', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteTaxGroup'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchTaxGroup
* @pronghornType method
* @name patchTaxGroup
* @summary patchTaxGroup
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxGroupId - (v1.0) id for taxGroup
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchTaxGroup
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchTaxGroup(companyId, taxGroupId, body, callback) {
const meth = 'adapter-patchTaxGroup';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxGroupId === undefined || taxGroupId === null || taxGroupId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxGroupId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxGroups(${taxGroupId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxGroup', 'patchTaxGroup', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchTaxGroup'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listJournals
* @pronghornType method
* @name listJournals
* @summary listJournals
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listJournals
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listJournals(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listJournals';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'listJournals', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listJournals'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postJournal
* @pronghornType method
* @name postJournal
* @summary postJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postJournal(companyId, body, callback) {
const meth = 'adapter-postJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'postJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getJournal
* @pronghornType method
* @name getJournal
* @summary getJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getJournal(companyId, journalId, expand, select, callback) {
const meth = 'adapter-getJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'getJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteJournal
* @pronghornType method
* @name deleteJournal
* @summary deleteJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteJournal(companyId, journalId, callback) {
const meth = 'adapter-deleteJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'deleteJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchJournal
* @pronghornType method
* @name patchJournal
* @summary patchJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchJournal(companyId, journalId, body, callback) {
const meth = 'adapter-patchJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'patchJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postActionJournals
* @pronghornType method
* @name postActionJournals
* @summary postActionJournals
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postActionJournals
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postActionJournals(companyId, journalId, callback) {
const meth = 'adapter-postActionJournals';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Journal', 'postActionJournals', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postActionJournals'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listJournalLinesForJournal
* @pronghornType method
* @name listJournalLinesForJournal
* @summary listJournalLinesForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listJournalLinesForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listJournalLinesForJournal(companyId, journalId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listJournalLinesForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'listJournalLinesForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listJournalLinesForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postJournalLineForJournal
* @pronghornType method
* @name postJournalLineForJournal
* @summary postJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postJournalLineForJournal(companyId, journalId, body, callback) {
const meth = 'adapter-postJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'postJournalLineForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getJournalLineForJournal
* @pronghornType method
* @name getJournalLineForJournal
* @summary getJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getJournalLineForJournal(companyId, journalId, journalLineId, expand, select, callback) {
const meth = 'adapter-getJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'getJournalLineForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteJournalLineForJournal
* @pronghornType method
* @name deleteJournalLineForJournal
* @summary deleteJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteJournalLineForJournal(companyId, journalId, journalLineId, callback) {
const meth = 'adapter-deleteJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'deleteJournalLineForJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchJournalLineForJournal
* @pronghornType method
* @name patchJournalLineForJournal
* @summary patchJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchJournalLineForJournal(companyId, journalId, journalLineId, body, callback) {
const meth = 'adapter-patchJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'patchJournalLineForJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listJournalLines
* @pronghornType method
* @name listJournalLines
* @summary listJournalLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listJournalLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listJournalLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listJournalLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'listJournalLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listJournalLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postJournalLine
* @pronghornType method
* @name postJournalLine
* @summary postJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postJournalLine(companyId, body, callback) {
const meth = 'adapter-postJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'postJournalLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getJournalLine
* @pronghornType method
* @name getJournalLine
* @summary getJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getJournalLine(companyId, journalLineId, expand, select, callback) {
const meth = 'adapter-getJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'getJournalLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteJournalLine
* @pronghornType method
* @name deleteJournalLine
* @summary deleteJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteJournalLine(companyId, journalLineId, callback) {
const meth = 'adapter-deleteJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'deleteJournalLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchJournalLine
* @pronghornType method
* @name patchJournalLine
* @summary patchJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchJournalLine(companyId, journalLineId, body, callback) {
const meth = 'adapter-patchJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('JournalLine', 'patchJournalLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAttachmentsForJournalLineForJournal
* @pronghornType method
* @name listAttachmentsForJournalLineForJournal
* @summary listAttachmentsForJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAttachmentsForJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAttachmentsForJournalLineForJournal(companyId, journalId, journalLineId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAttachmentsForJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'listAttachmentsForJournalLineForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAttachmentsForJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postAttachmentsForJournalLineForJournal
* @pronghornType method
* @name postAttachmentsForJournalLineForJournal
* @summary postAttachmentsForJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postAttachmentsForJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postAttachmentsForJournalLineForJournal(companyId, journalId, journalLineId, body, callback) {
const meth = 'adapter-postAttachmentsForJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'postAttachmentsForJournalLineForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postAttachmentsForJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAttachmentsForJournalLineForJournal
* @pronghornType method
* @name getAttachmentsForJournalLineForJournal
* @summary getAttachmentsForJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAttachmentsForJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAttachmentsForJournalLineForJournal(companyId, journalId, journalLineId, attachmentsParentId, attachmentsId, select, callback) {
const meth = 'adapter-getAttachmentsForJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'getAttachmentsForJournalLineForJournal', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAttachmentsForJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteAttachmentsForJournalLineForJournal
* @pronghornType method
* @name deleteAttachmentsForJournalLineForJournal
* @summary deleteAttachmentsForJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteAttachmentsForJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteAttachmentsForJournalLineForJournal(companyId, journalId, journalLineId, attachmentsParentId, attachmentsId, callback) {
const meth = 'adapter-deleteAttachmentsForJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'deleteAttachmentsForJournalLineForJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteAttachmentsForJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchAttachmentsForJournalLineForJournal
* @pronghornType method
* @name patchAttachmentsForJournalLineForJournal
* @summary patchAttachmentsForJournalLineForJournal
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalId - (v1.0) id for journal
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchAttachmentsForJournalLineForJournal
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchAttachmentsForJournalLineForJournal(companyId, journalId, journalLineId, attachmentsParentId, attachmentsId, body, callback) {
const meth = 'adapter-patchAttachmentsForJournalLineForJournal';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalId === undefined || journalId === null || journalId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journals(${journalId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'patchAttachmentsForJournalLineForJournal', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchAttachmentsForJournalLineForJournal'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAttachmentsForJournalLine
* @pronghornType method
* @name listAttachmentsForJournalLine
* @summary listAttachmentsForJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAttachmentsForJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAttachmentsForJournalLine(companyId, journalLineId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAttachmentsForJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'listAttachmentsForJournalLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAttachmentsForJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postAttachmentsForJournalLine
* @pronghornType method
* @name postAttachmentsForJournalLine
* @summary postAttachmentsForJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postAttachmentsForJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postAttachmentsForJournalLine(companyId, journalLineId, body, callback) {
const meth = 'adapter-postAttachmentsForJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'postAttachmentsForJournalLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postAttachmentsForJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAttachmentsForJournalLine
* @pronghornType method
* @name getAttachmentsForJournalLine
* @summary getAttachmentsForJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAttachmentsForJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAttachmentsForJournalLine(companyId, journalLineId, attachmentsParentId, attachmentsId, select, callback) {
const meth = 'adapter-getAttachmentsForJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'getAttachmentsForJournalLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAttachmentsForJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteAttachmentsForJournalLine
* @pronghornType method
* @name deleteAttachmentsForJournalLine
* @summary deleteAttachmentsForJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteAttachmentsForJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteAttachmentsForJournalLine(companyId, journalLineId, attachmentsParentId, attachmentsId, callback) {
const meth = 'adapter-deleteAttachmentsForJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'deleteAttachmentsForJournalLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteAttachmentsForJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchAttachmentsForJournalLine
* @pronghornType method
* @name patchAttachmentsForJournalLine
* @summary patchAttachmentsForJournalLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} journalLineId - (v1.0) id for journalLine
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchAttachmentsForJournalLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchAttachmentsForJournalLine(companyId, journalLineId, attachmentsParentId, attachmentsId, body, callback) {
const meth = 'adapter-patchAttachmentsForJournalLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (journalLineId === undefined || journalLineId === null || journalLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['journalLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `journalLines(${journalLineId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'patchAttachmentsForJournalLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchAttachmentsForJournalLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAttachments
* @pronghornType method
* @name listAttachments
* @summary listAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAttachments(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'listAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postAttachments
* @pronghornType method
* @name postAttachments
* @summary postAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postAttachments(companyId, body, callback) {
const meth = 'adapter-postAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'postAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAttachments
* @pronghornType method
* @name getAttachments
* @summary getAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAttachments(companyId, attachmentsParentId, attachmentsId, select, callback) {
const meth = 'adapter-getAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'getAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteAttachments
* @pronghornType method
* @name deleteAttachments
* @summary deleteAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteAttachments(companyId, attachmentsParentId, attachmentsId, callback) {
const meth = 'adapter-deleteAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'deleteAttachments', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchAttachments
* @pronghornType method
* @name patchAttachments
* @summary patchAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {string} attachmentsParentId - (v1.0) parentId for attachments
* @param {string} attachmentsId - (v1.0) id for attachments
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchAttachments(companyId, attachmentsParentId, attachmentsId, body, callback) {
const meth = 'adapter-patchAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsParentId === undefined || attachmentsParentId === null || attachmentsParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (attachmentsId === undefined || attachmentsId === null || attachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['attachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `attachments(${attachmentsParentId},${attachmentsId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Attachments', 'patchAttachments', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listEmployees
* @pronghornType method
* @name listEmployees
* @summary listEmployees
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listEmployees
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listEmployees(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listEmployees';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Employee', 'listEmployees', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listEmployees'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postEmployee
* @pronghornType method
* @name postEmployee
* @summary postEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postEmployee(companyId, body, callback) {
const meth = 'adapter-postEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Employee', 'postEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getEmployee
* @pronghornType method
* @name getEmployee
* @summary getEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getEmployee(companyId, employeeId, expand, select, callback) {
const meth = 'adapter-getEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Employee', 'getEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteEmployee
* @pronghornType method
* @name deleteEmployee
* @summary deleteEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteEmployee(companyId, employeeId, callback) {
const meth = 'adapter-deleteEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Employee', 'deleteEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchEmployee
* @pronghornType method
* @name patchEmployee
* @summary patchEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchEmployee(companyId, employeeId, body, callback) {
const meth = 'adapter-patchEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Employee', 'patchEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listTimeRegistrationEntriesForEmployee
* @pronghornType method
* @name listTimeRegistrationEntriesForEmployee
* @summary listTimeRegistrationEntriesForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listTimeRegistrationEntriesForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listTimeRegistrationEntriesForEmployee(companyId, employeeId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listTimeRegistrationEntriesForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'listTimeRegistrationEntriesForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listTimeRegistrationEntriesForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postTimeRegistrationEntryForEmployee
* @pronghornType method
* @name postTimeRegistrationEntryForEmployee
* @summary postTimeRegistrationEntryForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postTimeRegistrationEntryForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postTimeRegistrationEntryForEmployee(companyId, employeeId, body, callback) {
const meth = 'adapter-postTimeRegistrationEntryForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'postTimeRegistrationEntryForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postTimeRegistrationEntryForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getTimeRegistrationEntryForEmployee
* @pronghornType method
* @name getTimeRegistrationEntryForEmployee
* @summary getTimeRegistrationEntryForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getTimeRegistrationEntryForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getTimeRegistrationEntryForEmployee(companyId, employeeId, timeRegistrationEntryId, expand, select, callback) {
const meth = 'adapter-getTimeRegistrationEntryForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'getTimeRegistrationEntryForEmployee', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTimeRegistrationEntryForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteTimeRegistrationEntryForEmployee
* @pronghornType method
* @name deleteTimeRegistrationEntryForEmployee
* @summary deleteTimeRegistrationEntryForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteTimeRegistrationEntryForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteTimeRegistrationEntryForEmployee(companyId, employeeId, timeRegistrationEntryId, callback) {
const meth = 'adapter-deleteTimeRegistrationEntryForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'deleteTimeRegistrationEntryForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteTimeRegistrationEntryForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchTimeRegistrationEntryForEmployee
* @pronghornType method
* @name patchTimeRegistrationEntryForEmployee
* @summary patchTimeRegistrationEntryForEmployee
*
* @param {string} companyId - (v1.0) id for company
* @param {string} employeeId - (v1.0) id for employee
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchTimeRegistrationEntryForEmployee
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchTimeRegistrationEntryForEmployee(companyId, employeeId, timeRegistrationEntryId, body, callback) {
const meth = 'adapter-patchTimeRegistrationEntryForEmployee';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (employeeId === undefined || employeeId === null || employeeId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['employeeId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `employees(${employeeId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'patchTimeRegistrationEntryForEmployee', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchTimeRegistrationEntryForEmployee'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listTimeRegistrationEntries
* @pronghornType method
* @name listTimeRegistrationEntries
* @summary listTimeRegistrationEntries
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listTimeRegistrationEntries
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listTimeRegistrationEntries(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listTimeRegistrationEntries';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'listTimeRegistrationEntries', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listTimeRegistrationEntries'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postTimeRegistrationEntry
* @pronghornType method
* @name postTimeRegistrationEntry
* @summary postTimeRegistrationEntry
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postTimeRegistrationEntry
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postTimeRegistrationEntry(companyId, body, callback) {
const meth = 'adapter-postTimeRegistrationEntry';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'postTimeRegistrationEntry', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postTimeRegistrationEntry'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getTimeRegistrationEntry
* @pronghornType method
* @name getTimeRegistrationEntry
* @summary getTimeRegistrationEntry
*
* @param {string} companyId - (v1.0) id for company
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getTimeRegistrationEntry
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getTimeRegistrationEntry(companyId, timeRegistrationEntryId, expand, select, callback) {
const meth = 'adapter-getTimeRegistrationEntry';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'getTimeRegistrationEntry', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTimeRegistrationEntry'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteTimeRegistrationEntry
* @pronghornType method
* @name deleteTimeRegistrationEntry
* @summary deleteTimeRegistrationEntry
*
* @param {string} companyId - (v1.0) id for company
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteTimeRegistrationEntry
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteTimeRegistrationEntry(companyId, timeRegistrationEntryId, callback) {
const meth = 'adapter-deleteTimeRegistrationEntry';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'deleteTimeRegistrationEntry', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteTimeRegistrationEntry'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchTimeRegistrationEntry
* @pronghornType method
* @name patchTimeRegistrationEntry
* @summary patchTimeRegistrationEntry
*
* @param {string} companyId - (v1.0) id for company
* @param {string} timeRegistrationEntryId - (v1.0) id for timeRegistrationEntry
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchTimeRegistrationEntry
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchTimeRegistrationEntry(companyId, timeRegistrationEntryId, body, callback) {
const meth = 'adapter-patchTimeRegistrationEntry';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (timeRegistrationEntryId === undefined || timeRegistrationEntryId === null || timeRegistrationEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['timeRegistrationEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `timeRegistrationEntries(${timeRegistrationEntryId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TimeRegistrationEntry', 'patchTimeRegistrationEntry', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchTimeRegistrationEntry'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listGeneralLedgerEntries
* @pronghornType method
* @name listGeneralLedgerEntries
* @summary listGeneralLedgerEntries
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listGeneralLedgerEntries
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listGeneralLedgerEntries(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listGeneralLedgerEntries';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntry', 'listGeneralLedgerEntries', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listGeneralLedgerEntries'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getGeneralLedgerEntry
* @pronghornType method
* @name getGeneralLedgerEntry
* @summary getGeneralLedgerEntry
*
* @param {string} companyId - (v1.0) id for company
* @param {number} generalLedgerEntryId - (v1.0) id for generalLedgerEntry
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getGeneralLedgerEntry
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getGeneralLedgerEntry(companyId, generalLedgerEntryId, expand, select, callback) {
const meth = 'adapter-getGeneralLedgerEntry';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryId === undefined || generalLedgerEntryId === null || generalLedgerEntryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `generalLedgerEntries(${generalLedgerEntryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntry', 'getGeneralLedgerEntry', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getGeneralLedgerEntry'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCurrencies
* @pronghornType method
* @name listCurrencies
* @summary listCurrencies
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCurrencies
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCurrencies(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCurrencies';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Currency', 'listCurrencies', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCurrencies'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCurrency
* @pronghornType method
* @name postCurrency
* @summary postCurrency
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCurrency
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCurrency(companyId, body, callback) {
const meth = 'adapter-postCurrency';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Currency', 'postCurrency', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCurrency'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCurrency
* @pronghornType method
* @name getCurrency
* @summary getCurrency
*
* @param {string} companyId - (v1.0) id for company
* @param {string} currencyId - (v1.0) id for currency
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCurrency
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCurrency(companyId, currencyId, select, callback) {
const meth = 'adapter-getCurrency';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (currencyId === undefined || currencyId === null || currencyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['currencyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `currencies(${currencyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Currency', 'getCurrency', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCurrency'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCurrency
* @pronghornType method
* @name deleteCurrency
* @summary deleteCurrency
*
* @param {string} companyId - (v1.0) id for company
* @param {string} currencyId - (v1.0) id for currency
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCurrency
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCurrency(companyId, currencyId, callback) {
const meth = 'adapter-deleteCurrency';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (currencyId === undefined || currencyId === null || currencyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['currencyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `currencies(${currencyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Currency', 'deleteCurrency', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCurrency'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCurrency
* @pronghornType method
* @name patchCurrency
* @summary patchCurrency
*
* @param {string} companyId - (v1.0) id for company
* @param {string} currencyId - (v1.0) id for currency
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCurrency
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCurrency(companyId, currencyId, body, callback) {
const meth = 'adapter-patchCurrency';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (currencyId === undefined || currencyId === null || currencyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['currencyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `currencies(${currencyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Currency', 'patchCurrency', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCurrency'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPaymentMethods
* @pronghornType method
* @name listPaymentMethods
* @summary listPaymentMethods
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPaymentMethods
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPaymentMethods(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPaymentMethods';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentMethod', 'listPaymentMethods', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPaymentMethods'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postPaymentMethod
* @pronghornType method
* @name postPaymentMethod
* @summary postPaymentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postPaymentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postPaymentMethod(companyId, body, callback) {
const meth = 'adapter-postPaymentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentMethod', 'postPaymentMethod', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPaymentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPaymentMethod
* @pronghornType method
* @name getPaymentMethod
* @summary getPaymentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentMethodId - (v1.0) id for paymentMethod
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPaymentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPaymentMethod(companyId, paymentMethodId, select, callback) {
const meth = 'adapter-getPaymentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentMethodId === undefined || paymentMethodId === null || paymentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentMethods(${paymentMethodId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentMethod', 'getPaymentMethod', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPaymentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePaymentMethod
* @pronghornType method
* @name deletePaymentMethod
* @summary deletePaymentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentMethodId - (v1.0) id for paymentMethod
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePaymentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePaymentMethod(companyId, paymentMethodId, callback) {
const meth = 'adapter-deletePaymentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentMethodId === undefined || paymentMethodId === null || paymentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentMethods(${paymentMethodId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentMethod', 'deletePaymentMethod', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePaymentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPaymentMethod
* @pronghornType method
* @name patchPaymentMethod
* @summary patchPaymentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentMethodId - (v1.0) id for paymentMethod
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPaymentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPaymentMethod(companyId, paymentMethodId, body, callback) {
const meth = 'adapter-patchPaymentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentMethodId === undefined || paymentMethodId === null || paymentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentMethods(${paymentMethodId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentMethod', 'patchPaymentMethod', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPaymentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDimensions
* @pronghornType method
* @name listDimensions
* @summary listDimensions
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDimensions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDimensions(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDimensions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Dimension', 'listDimensions', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDimensions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDimension
* @pronghornType method
* @name getDimension
* @summary getDimension
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionId - (v1.0) id for dimension
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDimension
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDimension(companyId, dimensionId, expand, select, callback) {
const meth = 'adapter-getDimension';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionId === undefined || dimensionId === null || dimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensions(${dimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Dimension', 'getDimension', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDimension'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDimensionValuesForDimension
* @pronghornType method
* @name listDimensionValuesForDimension
* @summary listDimensionValuesForDimension
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionId - (v1.0) id for dimension
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDimensionValuesForDimension
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDimensionValuesForDimension(companyId, dimensionId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listDimensionValuesForDimension';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionId === undefined || dimensionId === null || dimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensions(${dimensionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionValue', 'listDimensionValuesForDimension', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDimensionValuesForDimension'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDimensionValueForDimension
* @pronghornType method
* @name getDimensionValueForDimension
* @summary getDimensionValueForDimension
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionId - (v1.0) id for dimension
* @param {string} dimensionValueId - (v1.0) id for dimensionValue
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDimensionValueForDimension
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDimensionValueForDimension(companyId, dimensionId, dimensionValueId, select, callback) {
const meth = 'adapter-getDimensionValueForDimension';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionId === undefined || dimensionId === null || dimensionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionValueId === undefined || dimensionValueId === null || dimensionValueId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionValueId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensions(${dimensionId})`, `dimensionValues(${dimensionValueId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionValue', 'getDimensionValueForDimension', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDimensionValueForDimension'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDimensionValues
* @pronghornType method
* @name listDimensionValues
* @summary listDimensionValues
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDimensionValues
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDimensionValues(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listDimensionValues';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionValue', 'listDimensionValues', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDimensionValues'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDimensionValue
* @pronghornType method
* @name getDimensionValue
* @summary getDimensionValue
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionValueId - (v1.0) id for dimensionValue
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDimensionValue
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDimensionValue(companyId, dimensionValueId, select, callback) {
const meth = 'adapter-getDimensionValue';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionValueId === undefined || dimensionValueId === null || dimensionValueId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionValueId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensionValues(${dimensionValueId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionValue', 'getDimensionValue', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDimensionValue'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listDimensionLines
* @pronghornType method
* @name listDimensionLines
* @summary listDimensionLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listDimensionLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listDimensionLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listDimensionLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionLine', 'listDimensionLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listDimensionLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postDimensionLine
* @pronghornType method
* @name postDimensionLine
* @summary postDimensionLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postDimensionLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postDimensionLine(companyId, body, callback) {
const meth = 'adapter-postDimensionLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionLine', 'postDimensionLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postDimensionLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getDimensionLine
* @pronghornType method
* @name getDimensionLine
* @summary getDimensionLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionLineParentId - (v1.0) parentId for dimensionLine
* @param {string} dimensionLineId - (v1.0) id for dimensionLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getDimensionLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getDimensionLine(companyId, dimensionLineParentId, dimensionLineId, expand, select, callback) {
const meth = 'adapter-getDimensionLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineParentId === undefined || dimensionLineParentId === null || dimensionLineParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineId === undefined || dimensionLineId === null || dimensionLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensionLines(${dimensionLineParentId},${dimensionLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionLine', 'getDimensionLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getDimensionLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteDimensionLine
* @pronghornType method
* @name deleteDimensionLine
* @summary deleteDimensionLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionLineParentId - (v1.0) parentId for dimensionLine
* @param {string} dimensionLineId - (v1.0) id for dimensionLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteDimensionLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteDimensionLine(companyId, dimensionLineParentId, dimensionLineId, callback) {
const meth = 'adapter-deleteDimensionLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineParentId === undefined || dimensionLineParentId === null || dimensionLineParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineId === undefined || dimensionLineId === null || dimensionLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensionLines(${dimensionLineParentId},${dimensionLineId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionLine', 'deleteDimensionLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteDimensionLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchDimensionLine
* @pronghornType method
* @name patchDimensionLine
* @summary patchDimensionLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} dimensionLineParentId - (v1.0) parentId for dimensionLine
* @param {string} dimensionLineId - (v1.0) id for dimensionLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchDimensionLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchDimensionLine(companyId, dimensionLineParentId, dimensionLineId, body, callback) {
const meth = 'adapter-patchDimensionLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineParentId === undefined || dimensionLineParentId === null || dimensionLineParentId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineParentId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (dimensionLineId === undefined || dimensionLineId === null || dimensionLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['dimensionLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `dimensionLines(${dimensionLineParentId},${dimensionLineId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('DimensionLine', 'patchDimensionLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchDimensionLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPaymentTerms
* @pronghornType method
* @name listPaymentTerms
* @summary listPaymentTerms
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPaymentTerms
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPaymentTerms(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listPaymentTerms';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentTerm', 'listPaymentTerms', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPaymentTerms'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postPaymentTerm
* @pronghornType method
* @name postPaymentTerm
* @summary postPaymentTerm
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postPaymentTerm
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postPaymentTerm(companyId, body, callback) {
const meth = 'adapter-postPaymentTerm';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentTerm', 'postPaymentTerm', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPaymentTerm'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPaymentTerm
* @pronghornType method
* @name getPaymentTerm
* @summary getPaymentTerm
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentTermId - (v1.0) id for paymentTerm
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPaymentTerm
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPaymentTerm(companyId, paymentTermId, select, callback) {
const meth = 'adapter-getPaymentTerm';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentTermId === undefined || paymentTermId === null || paymentTermId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentTermId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentTerms(${paymentTermId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentTerm', 'getPaymentTerm', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPaymentTerm'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePaymentTerm
* @pronghornType method
* @name deletePaymentTerm
* @summary deletePaymentTerm
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentTermId - (v1.0) id for paymentTerm
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePaymentTerm
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePaymentTerm(companyId, paymentTermId, callback) {
const meth = 'adapter-deletePaymentTerm';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentTermId === undefined || paymentTermId === null || paymentTermId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentTermId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentTerms(${paymentTermId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentTerm', 'deletePaymentTerm', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePaymentTerm'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPaymentTerm
* @pronghornType method
* @name patchPaymentTerm
* @summary patchPaymentTerm
*
* @param {string} companyId - (v1.0) id for company
* @param {string} paymentTermId - (v1.0) id for paymentTerm
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPaymentTerm
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPaymentTerm(companyId, paymentTermId, body, callback) {
const meth = 'adapter-patchPaymentTerm';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (paymentTermId === undefined || paymentTermId === null || paymentTermId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['paymentTermId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `paymentTerms(${paymentTermId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PaymentTerm', 'patchPaymentTerm', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPaymentTerm'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listShipmentMethods
* @pronghornType method
* @name listShipmentMethods
* @summary listShipmentMethods
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listShipmentMethods
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listShipmentMethods(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listShipmentMethods';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ShipmentMethod', 'listShipmentMethods', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listShipmentMethods'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postShipmentMethod
* @pronghornType method
* @name postShipmentMethod
* @summary postShipmentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postShipmentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postShipmentMethod(companyId, body, callback) {
const meth = 'adapter-postShipmentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ShipmentMethod', 'postShipmentMethod', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postShipmentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getShipmentMethod
* @pronghornType method
* @name getShipmentMethod
* @summary getShipmentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} shipmentMethodId - (v1.0) id for shipmentMethod
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getShipmentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getShipmentMethod(companyId, shipmentMethodId, select, callback) {
const meth = 'adapter-getShipmentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (shipmentMethodId === undefined || shipmentMethodId === null || shipmentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shipmentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `shipmentMethods(${shipmentMethodId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ShipmentMethod', 'getShipmentMethod', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getShipmentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteShipmentMethod
* @pronghornType method
* @name deleteShipmentMethod
* @summary deleteShipmentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} shipmentMethodId - (v1.0) id for shipmentMethod
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteShipmentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteShipmentMethod(companyId, shipmentMethodId, callback) {
const meth = 'adapter-deleteShipmentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (shipmentMethodId === undefined || shipmentMethodId === null || shipmentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shipmentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `shipmentMethods(${shipmentMethodId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ShipmentMethod', 'deleteShipmentMethod', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteShipmentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchShipmentMethod
* @pronghornType method
* @name patchShipmentMethod
* @summary patchShipmentMethod
*
* @param {string} companyId - (v1.0) id for company
* @param {string} shipmentMethodId - (v1.0) id for shipmentMethod
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchShipmentMethod
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchShipmentMethod(companyId, shipmentMethodId, body, callback) {
const meth = 'adapter-patchShipmentMethod';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (shipmentMethodId === undefined || shipmentMethodId === null || shipmentMethodId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['shipmentMethodId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `shipmentMethods(${shipmentMethodId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ShipmentMethod', 'patchShipmentMethod', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchShipmentMethod'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listItemCategories
* @pronghornType method
* @name listItemCategories
* @summary listItemCategories
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listItemCategories
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listItemCategories(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listItemCategories';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ItemCategory', 'listItemCategories', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listItemCategories'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postItemCategory
* @pronghornType method
* @name postItemCategory
* @summary postItemCategory
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postItemCategory
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postItemCategory(companyId, body, callback) {
const meth = 'adapter-postItemCategory';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ItemCategory', 'postItemCategory', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postItemCategory'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getItemCategory
* @pronghornType method
* @name getItemCategory
* @summary getItemCategory
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemCategoryId - (v1.0) id for itemCategory
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getItemCategory
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getItemCategory(companyId, itemCategoryId, select, callback) {
const meth = 'adapter-getItemCategory';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemCategoryId === undefined || itemCategoryId === null || itemCategoryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemCategoryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `itemCategories(${itemCategoryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ItemCategory', 'getItemCategory', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getItemCategory'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteItemCategory
* @pronghornType method
* @name deleteItemCategory
* @summary deleteItemCategory
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemCategoryId - (v1.0) id for itemCategory
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteItemCategory
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteItemCategory(companyId, itemCategoryId, callback) {
const meth = 'adapter-deleteItemCategory';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemCategoryId === undefined || itemCategoryId === null || itemCategoryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemCategoryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `itemCategories(${itemCategoryId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ItemCategory', 'deleteItemCategory', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteItemCategory'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchItemCategory
* @pronghornType method
* @name patchItemCategory
* @summary patchItemCategory
*
* @param {string} companyId - (v1.0) id for company
* @param {string} itemCategoryId - (v1.0) id for itemCategory
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchItemCategory
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchItemCategory(companyId, itemCategoryId, body, callback) {
const meth = 'adapter-patchItemCategory';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (itemCategoryId === undefined || itemCategoryId === null || itemCategoryId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['itemCategoryId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `itemCategories(${itemCategoryId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('ItemCategory', 'patchItemCategory', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchItemCategory'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCashFlowStatement
* @pronghornType method
* @name listCashFlowStatement
* @summary listCashFlowStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCashFlowStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCashFlowStatement(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCashFlowStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CashFlowStatement', 'listCashFlowStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCashFlowStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCashFlowStatement
* @pronghornType method
* @name getCashFlowStatement
* @summary getCashFlowStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} cashFlowStatementLineNumber - (v1.0) lineNumber for cashFlowStatement
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCashFlowStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCashFlowStatement(companyId, cashFlowStatementLineNumber, select, callback) {
const meth = 'adapter-getCashFlowStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (cashFlowStatementLineNumber === undefined || cashFlowStatementLineNumber === null || cashFlowStatementLineNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['cashFlowStatementLineNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `cashFlowStatement(${cashFlowStatementLineNumber})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CashFlowStatement', 'getCashFlowStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCashFlowStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCountriesRegions
* @pronghornType method
* @name listCountriesRegions
* @summary listCountriesRegions
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCountriesRegions
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCountriesRegions(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCountriesRegions';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CountryRegion', 'listCountriesRegions', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCountriesRegions'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postCountryRegion
* @pronghornType method
* @name postCountryRegion
* @summary postCountryRegion
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postCountryRegion
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postCountryRegion(companyId, body, callback) {
const meth = 'adapter-postCountryRegion';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CountryRegion', 'postCountryRegion', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postCountryRegion'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCountryRegion
* @pronghornType method
* @name getCountryRegion
* @summary getCountryRegion
*
* @param {string} companyId - (v1.0) id for company
* @param {string} countryRegionId - (v1.0) id for countryRegion
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCountryRegion
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCountryRegion(companyId, countryRegionId, select, callback) {
const meth = 'adapter-getCountryRegion';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (countryRegionId === undefined || countryRegionId === null || countryRegionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['countryRegionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `countriesRegions(${countryRegionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CountryRegion', 'getCountryRegion', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCountryRegion'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteCountryRegion
* @pronghornType method
* @name deleteCountryRegion
* @summary deleteCountryRegion
*
* @param {string} companyId - (v1.0) id for company
* @param {string} countryRegionId - (v1.0) id for countryRegion
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteCountryRegion
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteCountryRegion(companyId, countryRegionId, callback) {
const meth = 'adapter-deleteCountryRegion';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (countryRegionId === undefined || countryRegionId === null || countryRegionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['countryRegionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `countriesRegions(${countryRegionId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CountryRegion', 'deleteCountryRegion', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteCountryRegion'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchCountryRegion
* @pronghornType method
* @name patchCountryRegion
* @summary patchCountryRegion
*
* @param {string} companyId - (v1.0) id for company
* @param {string} countryRegionId - (v1.0) id for countryRegion
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchCountryRegion
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchCountryRegion(companyId, countryRegionId, body, callback) {
const meth = 'adapter-patchCountryRegion';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (countryRegionId === undefined || countryRegionId === null || countryRegionId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['countryRegionId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `countriesRegions(${countryRegionId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CountryRegion', 'patchCountryRegion', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchCountryRegion'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesOrders
* @pronghornType method
* @name listSalesOrders
* @summary listSalesOrders
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesOrders
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesOrders(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesOrders';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'listSalesOrders', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesOrders'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesOrder
* @pronghornType method
* @name postSalesOrder
* @summary postSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesOrder(companyId, body, callback) {
const meth = 'adapter-postSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'postSalesOrder', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesOrder
* @pronghornType method
* @name getSalesOrder
* @summary getSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesOrder(companyId, salesOrderId, expand, select, callback) {
const meth = 'adapter-getSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'getSalesOrder', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesOrder
* @pronghornType method
* @name deleteSalesOrder
* @summary deleteSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesOrder(companyId, salesOrderId, callback) {
const meth = 'adapter-deleteSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'deleteSalesOrder', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesOrder
* @pronghornType method
* @name patchSalesOrder
* @summary patchSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesOrder(companyId, salesOrderId, body, callback) {
const meth = 'adapter-patchSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'patchSalesOrder', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function shipAndInvoiceActionSalesOrders
* @pronghornType method
* @name shipAndInvoiceActionSalesOrders
* @summary shipAndInvoiceActionSalesOrders
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /shipAndInvoiceActionSalesOrders
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
shipAndInvoiceActionSalesOrders(companyId, salesOrderId, callback) {
const meth = 'adapter-shipAndInvoiceActionSalesOrders';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrder', 'shipAndInvoiceActionSalesOrders', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['shipAndInvoiceActionSalesOrders'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesOrderLinesForSalesOrder
* @pronghornType method
* @name listSalesOrderLinesForSalesOrder
* @summary listSalesOrderLinesForSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesOrderLinesForSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesOrderLinesForSalesOrder(companyId, salesOrderId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesOrderLinesForSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'listSalesOrderLinesForSalesOrder', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesOrderLinesForSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesOrderLineForSalesOrder
* @pronghornType method
* @name postSalesOrderLineForSalesOrder
* @summary postSalesOrderLineForSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesOrderLineForSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesOrderLineForSalesOrder(companyId, salesOrderId, body, callback) {
const meth = 'adapter-postSalesOrderLineForSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'postSalesOrderLineForSalesOrder', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesOrderLineForSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesOrderLineForSalesOrder
* @pronghornType method
* @name getSalesOrderLineForSalesOrder
* @summary getSalesOrderLineForSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesOrderLineForSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesOrderLineForSalesOrder(companyId, salesOrderId, salesOrderLineId, expand, select, callback) {
const meth = 'adapter-getSalesOrderLineForSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'getSalesOrderLineForSalesOrder', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesOrderLineForSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesOrderLineForSalesOrder
* @pronghornType method
* @name deleteSalesOrderLineForSalesOrder
* @summary deleteSalesOrderLineForSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesOrderLineForSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesOrderLineForSalesOrder(companyId, salesOrderId, salesOrderLineId, callback) {
const meth = 'adapter-deleteSalesOrderLineForSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'deleteSalesOrderLineForSalesOrder', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesOrderLineForSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesOrderLineForSalesOrder
* @pronghornType method
* @name patchSalesOrderLineForSalesOrder
* @summary patchSalesOrderLineForSalesOrder
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderId - (v1.0) id for salesOrder
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesOrderLineForSalesOrder
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesOrderLineForSalesOrder(companyId, salesOrderId, salesOrderLineId, body, callback) {
const meth = 'adapter-patchSalesOrderLineForSalesOrder';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderId === undefined || salesOrderId === null || salesOrderId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrders(${salesOrderId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'patchSalesOrderLineForSalesOrder', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesOrderLineForSalesOrder'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesOrderLines
* @pronghornType method
* @name listSalesOrderLines
* @summary listSalesOrderLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesOrderLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesOrderLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesOrderLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'listSalesOrderLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesOrderLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesOrderLine
* @pronghornType method
* @name postSalesOrderLine
* @summary postSalesOrderLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesOrderLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesOrderLine(companyId, body, callback) {
const meth = 'adapter-postSalesOrderLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'postSalesOrderLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesOrderLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesOrderLine
* @pronghornType method
* @name getSalesOrderLine
* @summary getSalesOrderLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesOrderLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesOrderLine(companyId, salesOrderLineId, expand, select, callback) {
const meth = 'adapter-getSalesOrderLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'getSalesOrderLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesOrderLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesOrderLine
* @pronghornType method
* @name deleteSalesOrderLine
* @summary deleteSalesOrderLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesOrderLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesOrderLine(companyId, salesOrderLineId, callback) {
const meth = 'adapter-deleteSalesOrderLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'deleteSalesOrderLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesOrderLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesOrderLine
* @pronghornType method
* @name patchSalesOrderLine
* @summary patchSalesOrderLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesOrderLineId - (v1.0) id for salesOrderLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesOrderLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesOrderLine(companyId, salesOrderLineId, body, callback) {
const meth = 'adapter-patchSalesOrderLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesOrderLineId === undefined || salesOrderLineId === null || salesOrderLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesOrderLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesOrderLines('${salesOrderLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesOrderLine', 'patchSalesOrderLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesOrderLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listRetainedEarningsStatement
* @pronghornType method
* @name listRetainedEarningsStatement
* @summary listRetainedEarningsStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listRetainedEarningsStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listRetainedEarningsStatement(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listRetainedEarningsStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('RetainedEarningsStatement', 'listRetainedEarningsStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listRetainedEarningsStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getRetainedEarningsStatement
* @pronghornType method
* @name getRetainedEarningsStatement
* @summary getRetainedEarningsStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} retainedEarningsStatementLineNumber - (v1.0) lineNumber for retainedEarningsStatement
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getRetainedEarningsStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getRetainedEarningsStatement(companyId, retainedEarningsStatementLineNumber, select, callback) {
const meth = 'adapter-getRetainedEarningsStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (retainedEarningsStatementLineNumber === undefined || retainedEarningsStatementLineNumber === null || retainedEarningsStatementLineNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['retainedEarningsStatementLineNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `retainedEarningsStatement(${retainedEarningsStatementLineNumber})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('RetainedEarningsStatement', 'getRetainedEarningsStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getRetainedEarningsStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listUnitsOfMeasure
* @pronghornType method
* @name listUnitsOfMeasure
* @summary listUnitsOfMeasure
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listUnitsOfMeasure
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listUnitsOfMeasure(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listUnitsOfMeasure';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('UnitOfMeasure', 'listUnitsOfMeasure', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listUnitsOfMeasure'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postUnitOfMeasure
* @pronghornType method
* @name postUnitOfMeasure
* @summary postUnitOfMeasure
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postUnitOfMeasure
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postUnitOfMeasure(companyId, body, callback) {
const meth = 'adapter-postUnitOfMeasure';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('UnitOfMeasure', 'postUnitOfMeasure', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postUnitOfMeasure'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getUnitOfMeasure
* @pronghornType method
* @name getUnitOfMeasure
* @summary getUnitOfMeasure
*
* @param {string} companyId - (v1.0) id for company
* @param {string} unitOfMeasureId - (v1.0) id for unitOfMeasure
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getUnitOfMeasure
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getUnitOfMeasure(companyId, unitOfMeasureId, select, callback) {
const meth = 'adapter-getUnitOfMeasure';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (unitOfMeasureId === undefined || unitOfMeasureId === null || unitOfMeasureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['unitOfMeasureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `unitsOfMeasure(${unitOfMeasureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('UnitOfMeasure', 'getUnitOfMeasure', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getUnitOfMeasure'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteUnitOfMeasure
* @pronghornType method
* @name deleteUnitOfMeasure
* @summary deleteUnitOfMeasure
*
* @param {string} companyId - (v1.0) id for company
* @param {string} unitOfMeasureId - (v1.0) id for unitOfMeasure
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteUnitOfMeasure
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteUnitOfMeasure(companyId, unitOfMeasureId, callback) {
const meth = 'adapter-deleteUnitOfMeasure';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (unitOfMeasureId === undefined || unitOfMeasureId === null || unitOfMeasureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['unitOfMeasureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `unitsOfMeasure(${unitOfMeasureId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('UnitOfMeasure', 'deleteUnitOfMeasure', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteUnitOfMeasure'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchUnitOfMeasure
* @pronghornType method
* @name patchUnitOfMeasure
* @summary patchUnitOfMeasure
*
* @param {string} companyId - (v1.0) id for company
* @param {string} unitOfMeasureId - (v1.0) id for unitOfMeasure
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchUnitOfMeasure
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchUnitOfMeasure(companyId, unitOfMeasureId, body, callback) {
const meth = 'adapter-patchUnitOfMeasure';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (unitOfMeasureId === undefined || unitOfMeasureId === null || unitOfMeasureId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['unitOfMeasureId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `unitsOfMeasure(${unitOfMeasureId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('UnitOfMeasure', 'patchUnitOfMeasure', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchUnitOfMeasure'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAgedAccountsReceivable
* @pronghornType method
* @name listAgedAccountsReceivable
* @summary listAgedAccountsReceivable
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAgedAccountsReceivable
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAgedAccountsReceivable(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAgedAccountsReceivable';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('AgedAccountsReceivable', 'listAgedAccountsReceivable', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAgedAccountsReceivable'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAgedAccountsReceivable
* @pronghornType method
* @name getAgedAccountsReceivable
* @summary getAgedAccountsReceivable
*
* @param {string} companyId - (v1.0) id for company
* @param {string} agedAccountsReceivableCustomerId - (v1.0) customerId for agedAccountsReceivable
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAgedAccountsReceivable
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAgedAccountsReceivable(companyId, agedAccountsReceivableCustomerId, select, callback) {
const meth = 'adapter-getAgedAccountsReceivable';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (agedAccountsReceivableCustomerId === undefined || agedAccountsReceivableCustomerId === null || agedAccountsReceivableCustomerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['agedAccountsReceivableCustomerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `agedAccountsReceivable(${agedAccountsReceivableCustomerId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('AgedAccountsReceivable', 'getAgedAccountsReceivable', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAgedAccountsReceivable'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listAgedAccountsPayable
* @pronghornType method
* @name listAgedAccountsPayable
* @summary listAgedAccountsPayable
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listAgedAccountsPayable
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listAgedAccountsPayable(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listAgedAccountsPayable';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('AgedAccountsPayable', 'listAgedAccountsPayable', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listAgedAccountsPayable'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getAgedAccountsPayable
* @pronghornType method
* @name getAgedAccountsPayable
* @summary getAgedAccountsPayable
*
* @param {string} companyId - (v1.0) id for company
* @param {string} agedAccountsPayableVendorId - (v1.0) vendorId for agedAccountsPayable
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getAgedAccountsPayable
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getAgedAccountsPayable(companyId, agedAccountsPayableVendorId, select, callback) {
const meth = 'adapter-getAgedAccountsPayable';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (agedAccountsPayableVendorId === undefined || agedAccountsPayableVendorId === null || agedAccountsPayableVendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['agedAccountsPayableVendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `agedAccountsPayable(${agedAccountsPayableVendorId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('AgedAccountsPayable', 'getAgedAccountsPayable', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getAgedAccountsPayable'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listBalanceSheet
* @pronghornType method
* @name listBalanceSheet
* @summary listBalanceSheet
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listBalanceSheet
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listBalanceSheet(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listBalanceSheet';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BalanceSheet', 'listBalanceSheet', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listBalanceSheet'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getBalanceSheet
* @pronghornType method
* @name getBalanceSheet
* @summary getBalanceSheet
*
* @param {string} companyId - (v1.0) id for company
* @param {number} balanceSheetLineNumber - (v1.0) lineNumber for balanceSheet
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getBalanceSheet
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getBalanceSheet(companyId, balanceSheetLineNumber, select, callback) {
const meth = 'adapter-getBalanceSheet';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (balanceSheetLineNumber === undefined || balanceSheetLineNumber === null || balanceSheetLineNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['balanceSheetLineNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `balanceSheet(${balanceSheetLineNumber})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BalanceSheet', 'getBalanceSheet', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getBalanceSheet'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listTrialBalance
* @pronghornType method
* @name listTrialBalance
* @summary listTrialBalance
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listTrialBalance
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listTrialBalance(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listTrialBalance';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TrialBalance', 'listTrialBalance', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listTrialBalance'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getTrialBalance
* @pronghornType method
* @name getTrialBalance
* @summary getTrialBalance
*
* @param {string} companyId - (v1.0) id for company
* @param {string} trialBalanceNumber - (v1.0) number for trialBalance
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getTrialBalance
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getTrialBalance(companyId, trialBalanceNumber, expand, select, callback) {
const meth = 'adapter-getTrialBalance';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (trialBalanceNumber === undefined || trialBalanceNumber === null || trialBalanceNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['trialBalanceNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `trialBalance('${trialBalanceNumber}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TrialBalance', 'getTrialBalance', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTrialBalance'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listIncomeStatement
* @pronghornType method
* @name listIncomeStatement
* @summary listIncomeStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listIncomeStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listIncomeStatement(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listIncomeStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('IncomeStatement', 'listIncomeStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listIncomeStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getIncomeStatement
* @pronghornType method
* @name getIncomeStatement
* @summary getIncomeStatement
*
* @param {string} companyId - (v1.0) id for company
* @param {number} incomeStatementLineNumber - (v1.0) lineNumber for incomeStatement
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getIncomeStatement
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getIncomeStatement(companyId, incomeStatementLineNumber, select, callback) {
const meth = 'adapter-getIncomeStatement';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (incomeStatementLineNumber === undefined || incomeStatementLineNumber === null || incomeStatementLineNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['incomeStatementLineNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `incomeStatement(${incomeStatementLineNumber})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('IncomeStatement', 'getIncomeStatement', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getIncomeStatement'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listTaxAreas
* @pronghornType method
* @name listTaxAreas
* @summary listTaxAreas
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listTaxAreas
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listTaxAreas(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listTaxAreas';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxArea', 'listTaxAreas', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listTaxAreas'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postTaxArea
* @pronghornType method
* @name postTaxArea
* @summary postTaxArea
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postTaxArea
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postTaxArea(companyId, body, callback) {
const meth = 'adapter-postTaxArea';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxArea', 'postTaxArea', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postTaxArea'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getTaxArea
* @pronghornType method
* @name getTaxArea
* @summary getTaxArea
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxAreaId - (v1.0) id for taxArea
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getTaxArea
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getTaxArea(companyId, taxAreaId, select, callback) {
const meth = 'adapter-getTaxArea';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxAreaId === undefined || taxAreaId === null || taxAreaId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxAreaId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxAreas(${taxAreaId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxArea', 'getTaxArea', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getTaxArea'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteTaxArea
* @pronghornType method
* @name deleteTaxArea
* @summary deleteTaxArea
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxAreaId - (v1.0) id for taxArea
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteTaxArea
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteTaxArea(companyId, taxAreaId, callback) {
const meth = 'adapter-deleteTaxArea';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxAreaId === undefined || taxAreaId === null || taxAreaId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxAreaId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxAreas(${taxAreaId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxArea', 'deleteTaxArea', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteTaxArea'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchTaxArea
* @pronghornType method
* @name patchTaxArea
* @summary patchTaxArea
*
* @param {string} companyId - (v1.0) id for company
* @param {string} taxAreaId - (v1.0) id for taxArea
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchTaxArea
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchTaxArea(companyId, taxAreaId, body, callback) {
const meth = 'adapter-patchTaxArea';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (taxAreaId === undefined || taxAreaId === null || taxAreaId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['taxAreaId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `taxAreas(${taxAreaId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('TaxArea', 'patchTaxArea', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchTaxArea'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesQuotes
* @pronghornType method
* @name listSalesQuotes
* @summary listSalesQuotes
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesQuotes
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesQuotes(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesQuotes';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'listSalesQuotes', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesQuotes'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesQuote
* @pronghornType method
* @name postSalesQuote
* @summary postSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesQuote(companyId, body, callback) {
const meth = 'adapter-postSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'postSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesQuote
* @pronghornType method
* @name getSalesQuote
* @summary getSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesQuote(companyId, salesQuoteId, expand, select, callback) {
const meth = 'adapter-getSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'getSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesQuote
* @pronghornType method
* @name deleteSalesQuote
* @summary deleteSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesQuote(companyId, salesQuoteId, callback) {
const meth = 'adapter-deleteSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'deleteSalesQuote', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesQuote
* @pronghornType method
* @name patchSalesQuote
* @summary patchSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesQuote(companyId, salesQuoteId, body, callback) {
const meth = 'adapter-patchSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'patchSalesQuote', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function makeInvoiceActionSalesQuotes
* @pronghornType method
* @name makeInvoiceActionSalesQuotes
* @summary makeInvoiceActionSalesQuotes
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /makeInvoiceActionSalesQuotes
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
makeInvoiceActionSalesQuotes(companyId, salesQuoteId, callback) {
const meth = 'adapter-makeInvoiceActionSalesQuotes';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'makeInvoiceActionSalesQuotes', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['makeInvoiceActionSalesQuotes'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function makeOrderActionSalesQuotes
* @pronghornType method
* @name makeOrderActionSalesQuotes
* @summary makeOrderActionSalesQuotes
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /makeOrderActionSalesQuotes
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
makeOrderActionSalesQuotes(companyId, salesQuoteId, callback) {
const meth = 'adapter-makeOrderActionSalesQuotes';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'makeOrderActionSalesQuotes', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['makeOrderActionSalesQuotes'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function sendActionSalesQuotes
* @pronghornType method
* @name sendActionSalesQuotes
* @summary sendActionSalesQuotes
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /sendActionSalesQuotes
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
sendActionSalesQuotes(companyId, salesQuoteId, callback) {
const meth = 'adapter-sendActionSalesQuotes';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuote', 'sendActionSalesQuotes', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['sendActionSalesQuotes'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesQuoteLinesForSalesQuote
* @pronghornType method
* @name listSalesQuoteLinesForSalesQuote
* @summary listSalesQuoteLinesForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesQuoteLinesForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesQuoteLinesForSalesQuote(companyId, salesQuoteId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesQuoteLinesForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'listSalesQuoteLinesForSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesQuoteLinesForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesQuoteLineForSalesQuote
* @pronghornType method
* @name postSalesQuoteLineForSalesQuote
* @summary postSalesQuoteLineForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesQuoteLineForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesQuoteLineForSalesQuote(companyId, salesQuoteId, body, callback) {
const meth = 'adapter-postSalesQuoteLineForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'postSalesQuoteLineForSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesQuoteLineForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesQuoteLineForSalesQuote
* @pronghornType method
* @name getSalesQuoteLineForSalesQuote
* @summary getSalesQuoteLineForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesQuoteLineForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesQuoteLineForSalesQuote(companyId, salesQuoteId, salesQuoteLineId, expand, select, callback) {
const meth = 'adapter-getSalesQuoteLineForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'getSalesQuoteLineForSalesQuote', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesQuoteLineForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesQuoteLineForSalesQuote
* @pronghornType method
* @name deleteSalesQuoteLineForSalesQuote
* @summary deleteSalesQuoteLineForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesQuoteLineForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesQuoteLineForSalesQuote(companyId, salesQuoteId, salesQuoteLineId, callback) {
const meth = 'adapter-deleteSalesQuoteLineForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'deleteSalesQuoteLineForSalesQuote', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesQuoteLineForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesQuoteLineForSalesQuote
* @pronghornType method
* @name patchSalesQuoteLineForSalesQuote
* @summary patchSalesQuoteLineForSalesQuote
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteId - (v1.0) id for salesQuote
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesQuoteLineForSalesQuote
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesQuoteLineForSalesQuote(companyId, salesQuoteId, salesQuoteLineId, body, callback) {
const meth = 'adapter-patchSalesQuoteLineForSalesQuote';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteId === undefined || salesQuoteId === null || salesQuoteId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuotes(${salesQuoteId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'patchSalesQuoteLineForSalesQuote', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesQuoteLineForSalesQuote'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesQuoteLines
* @pronghornType method
* @name listSalesQuoteLines
* @summary listSalesQuoteLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesQuoteLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesQuoteLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesQuoteLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'listSalesQuoteLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesQuoteLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesQuoteLine
* @pronghornType method
* @name postSalesQuoteLine
* @summary postSalesQuoteLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesQuoteLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesQuoteLine(companyId, body, callback) {
const meth = 'adapter-postSalesQuoteLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'postSalesQuoteLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesQuoteLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesQuoteLine
* @pronghornType method
* @name getSalesQuoteLine
* @summary getSalesQuoteLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesQuoteLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesQuoteLine(companyId, salesQuoteLineId, expand, select, callback) {
const meth = 'adapter-getSalesQuoteLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'getSalesQuoteLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesQuoteLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesQuoteLine
* @pronghornType method
* @name deleteSalesQuoteLine
* @summary deleteSalesQuoteLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesQuoteLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesQuoteLine(companyId, salesQuoteLineId, callback) {
const meth = 'adapter-deleteSalesQuoteLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'deleteSalesQuoteLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesQuoteLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesQuoteLine
* @pronghornType method
* @name patchSalesQuoteLine
* @summary patchSalesQuoteLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesQuoteLineId - (v1.0) id for salesQuoteLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesQuoteLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesQuoteLine(companyId, salesQuoteLineId, body, callback) {
const meth = 'adapter-patchSalesQuoteLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesQuoteLineId === undefined || salesQuoteLineId === null || salesQuoteLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesQuoteLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesQuoteLines('${salesQuoteLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesQuoteLine', 'patchSalesQuoteLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesQuoteLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesCreditMemos
* @pronghornType method
* @name listSalesCreditMemos
* @summary listSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesCreditMemos(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'listSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesCreditMemo
* @pronghornType method
* @name postSalesCreditMemo
* @summary postSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesCreditMemo(companyId, body, callback) {
const meth = 'adapter-postSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'postSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesCreditMemo
* @pronghornType method
* @name getSalesCreditMemo
* @summary getSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesCreditMemo(companyId, salesCreditMemoId, expand, select, callback) {
const meth = 'adapter-getSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'getSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesCreditMemo
* @pronghornType method
* @name deleteSalesCreditMemo
* @summary deleteSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesCreditMemo(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-deleteSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'deleteSalesCreditMemo', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesCreditMemo
* @pronghornType method
* @name patchSalesCreditMemo
* @summary patchSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesCreditMemo(companyId, salesCreditMemoId, body, callback) {
const meth = 'adapter-patchSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'patchSalesCreditMemo', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function cancelAndSendActionSalesCreditMemos
* @pronghornType method
* @name cancelAndSendActionSalesCreditMemos
* @summary cancelAndSendActionSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /cancelAndSendActionSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
cancelAndSendActionSalesCreditMemos(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-cancelAndSendActionSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'cancelAndSendActionSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['cancelAndSendActionSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function cancelActionSalesCreditMemos
* @pronghornType method
* @name cancelActionSalesCreditMemos
* @summary cancelActionSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /cancelActionSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
cancelActionSalesCreditMemos(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-cancelActionSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'cancelActionSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['cancelActionSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postAndSendActionSalesCreditMemos
* @pronghornType method
* @name postAndSendActionSalesCreditMemos
* @summary postAndSendActionSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postAndSendActionSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postAndSendActionSalesCreditMemos(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-postAndSendActionSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'postAndSendActionSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postAndSendActionSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postActionSalesCreditMemos
* @pronghornType method
* @name postActionSalesCreditMemos
* @summary postActionSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postActionSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postActionSalesCreditMemos(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-postActionSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'postActionSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postActionSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function sendActionSalesCreditMemos
* @pronghornType method
* @name sendActionSalesCreditMemos
* @summary sendActionSalesCreditMemos
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /sendActionSalesCreditMemos
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
sendActionSalesCreditMemos(companyId, salesCreditMemoId, callback) {
const meth = 'adapter-sendActionSalesCreditMemos';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemo', 'sendActionSalesCreditMemos', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['sendActionSalesCreditMemos'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesCreditMemoLinesForSalesCreditMemo
* @pronghornType method
* @name listSalesCreditMemoLinesForSalesCreditMemo
* @summary listSalesCreditMemoLinesForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesCreditMemoLinesForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesCreditMemoLinesForSalesCreditMemo(companyId, salesCreditMemoId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesCreditMemoLinesForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'listSalesCreditMemoLinesForSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesCreditMemoLinesForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesCreditMemoLineForSalesCreditMemo
* @pronghornType method
* @name postSalesCreditMemoLineForSalesCreditMemo
* @summary postSalesCreditMemoLineForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesCreditMemoLineForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesCreditMemoLineForSalesCreditMemo(companyId, salesCreditMemoId, body, callback) {
const meth = 'adapter-postSalesCreditMemoLineForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'postSalesCreditMemoLineForSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesCreditMemoLineForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesCreditMemoLineForSalesCreditMemo
* @pronghornType method
* @name getSalesCreditMemoLineForSalesCreditMemo
* @summary getSalesCreditMemoLineForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesCreditMemoLineForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesCreditMemoLineForSalesCreditMemo(companyId, salesCreditMemoId, salesCreditMemoLineId, expand, select, callback) {
const meth = 'adapter-getSalesCreditMemoLineForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'getSalesCreditMemoLineForSalesCreditMemo', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesCreditMemoLineForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesCreditMemoLineForSalesCreditMemo
* @pronghornType method
* @name deleteSalesCreditMemoLineForSalesCreditMemo
* @summary deleteSalesCreditMemoLineForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesCreditMemoLineForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesCreditMemoLineForSalesCreditMemo(companyId, salesCreditMemoId, salesCreditMemoLineId, callback) {
const meth = 'adapter-deleteSalesCreditMemoLineForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'deleteSalesCreditMemoLineForSalesCreditMemo', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesCreditMemoLineForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesCreditMemoLineForSalesCreditMemo
* @pronghornType method
* @name patchSalesCreditMemoLineForSalesCreditMemo
* @summary patchSalesCreditMemoLineForSalesCreditMemo
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoId - (v1.0) id for salesCreditMemo
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesCreditMemoLineForSalesCreditMemo
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesCreditMemoLineForSalesCreditMemo(companyId, salesCreditMemoId, salesCreditMemoLineId, body, callback) {
const meth = 'adapter-patchSalesCreditMemoLineForSalesCreditMemo';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoId === undefined || salesCreditMemoId === null || salesCreditMemoId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemos(${salesCreditMemoId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'patchSalesCreditMemoLineForSalesCreditMemo', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesCreditMemoLineForSalesCreditMemo'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listSalesCreditMemoLines
* @pronghornType method
* @name listSalesCreditMemoLines
* @summary listSalesCreditMemoLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listSalesCreditMemoLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listSalesCreditMemoLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listSalesCreditMemoLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'listSalesCreditMemoLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listSalesCreditMemoLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postSalesCreditMemoLine
* @pronghornType method
* @name postSalesCreditMemoLine
* @summary postSalesCreditMemoLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postSalesCreditMemoLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postSalesCreditMemoLine(companyId, body, callback) {
const meth = 'adapter-postSalesCreditMemoLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'postSalesCreditMemoLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postSalesCreditMemoLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getSalesCreditMemoLine
* @pronghornType method
* @name getSalesCreditMemoLine
* @summary getSalesCreditMemoLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getSalesCreditMemoLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getSalesCreditMemoLine(companyId, salesCreditMemoLineId, expand, select, callback) {
const meth = 'adapter-getSalesCreditMemoLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'getSalesCreditMemoLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getSalesCreditMemoLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteSalesCreditMemoLine
* @pronghornType method
* @name deleteSalesCreditMemoLine
* @summary deleteSalesCreditMemoLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteSalesCreditMemoLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteSalesCreditMemoLine(companyId, salesCreditMemoLineId, callback) {
const meth = 'adapter-deleteSalesCreditMemoLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'deleteSalesCreditMemoLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteSalesCreditMemoLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchSalesCreditMemoLine
* @pronghornType method
* @name patchSalesCreditMemoLine
* @summary patchSalesCreditMemoLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} salesCreditMemoLineId - (v1.0) id for salesCreditMemoLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchSalesCreditMemoLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchSalesCreditMemoLine(companyId, salesCreditMemoLineId, body, callback) {
const meth = 'adapter-patchSalesCreditMemoLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (salesCreditMemoLineId === undefined || salesCreditMemoLineId === null || salesCreditMemoLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['salesCreditMemoLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `salesCreditMemoLines('${salesCreditMemoLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('SalesCreditMemoLine', 'patchSalesCreditMemoLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchSalesCreditMemoLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listGeneralLedgerEntryAttachments
* @pronghornType method
* @name listGeneralLedgerEntryAttachments
* @summary listGeneralLedgerEntryAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listGeneralLedgerEntryAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listGeneralLedgerEntryAttachments(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listGeneralLedgerEntryAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntryAttachments', 'listGeneralLedgerEntryAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listGeneralLedgerEntryAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postGeneralLedgerEntryAttachments
* @pronghornType method
* @name postGeneralLedgerEntryAttachments
* @summary postGeneralLedgerEntryAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postGeneralLedgerEntryAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postGeneralLedgerEntryAttachments(companyId, body, callback) {
const meth = 'adapter-postGeneralLedgerEntryAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntryAttachments', 'postGeneralLedgerEntryAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postGeneralLedgerEntryAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getGeneralLedgerEntryAttachments
* @pronghornType method
* @name getGeneralLedgerEntryAttachments
* @summary getGeneralLedgerEntryAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} generalLedgerEntryAttachmentsGeneralLedgerEntryNumber - (v1.0) generalLedgerEntryNumber for generalLedgerEntryAttachments
* @param {string} generalLedgerEntryAttachmentsId - (v1.0) id for generalLedgerEntryAttachments
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getGeneralLedgerEntryAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getGeneralLedgerEntryAttachments(companyId, generalLedgerEntryAttachmentsGeneralLedgerEntryNumber, generalLedgerEntryAttachmentsId, expand, select, callback) {
const meth = 'adapter-getGeneralLedgerEntryAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === undefined || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === null || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsGeneralLedgerEntryNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsId === undefined || generalLedgerEntryAttachmentsId === null || generalLedgerEntryAttachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `generalLedgerEntryAttachments(${generalLedgerEntryAttachmentsGeneralLedgerEntryNumber},${generalLedgerEntryAttachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntryAttachments', 'getGeneralLedgerEntryAttachments', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getGeneralLedgerEntryAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteGeneralLedgerEntryAttachments
* @pronghornType method
* @name deleteGeneralLedgerEntryAttachments
* @summary deleteGeneralLedgerEntryAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} generalLedgerEntryAttachmentsGeneralLedgerEntryNumber - (v1.0) generalLedgerEntryNumber for generalLedgerEntryAttachments
* @param {string} generalLedgerEntryAttachmentsId - (v1.0) id for generalLedgerEntryAttachments
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteGeneralLedgerEntryAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteGeneralLedgerEntryAttachments(companyId, generalLedgerEntryAttachmentsGeneralLedgerEntryNumber, generalLedgerEntryAttachmentsId, callback) {
const meth = 'adapter-deleteGeneralLedgerEntryAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === undefined || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === null || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsGeneralLedgerEntryNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsId === undefined || generalLedgerEntryAttachmentsId === null || generalLedgerEntryAttachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `generalLedgerEntryAttachments(${generalLedgerEntryAttachmentsGeneralLedgerEntryNumber},${generalLedgerEntryAttachmentsId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntryAttachments', 'deleteGeneralLedgerEntryAttachments', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteGeneralLedgerEntryAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchGeneralLedgerEntryAttachments
* @pronghornType method
* @name patchGeneralLedgerEntryAttachments
* @summary patchGeneralLedgerEntryAttachments
*
* @param {string} companyId - (v1.0) id for company
* @param {number} generalLedgerEntryAttachmentsGeneralLedgerEntryNumber - (v1.0) generalLedgerEntryNumber for generalLedgerEntryAttachments
* @param {string} generalLedgerEntryAttachmentsId - (v1.0) id for generalLedgerEntryAttachments
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchGeneralLedgerEntryAttachments
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchGeneralLedgerEntryAttachments(companyId, generalLedgerEntryAttachmentsGeneralLedgerEntryNumber, generalLedgerEntryAttachmentsId, body, callback) {
const meth = 'adapter-patchGeneralLedgerEntryAttachments';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === undefined || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === null || generalLedgerEntryAttachmentsGeneralLedgerEntryNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsGeneralLedgerEntryNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (generalLedgerEntryAttachmentsId === undefined || generalLedgerEntryAttachmentsId === null || generalLedgerEntryAttachmentsId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['generalLedgerEntryAttachmentsId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `generalLedgerEntryAttachments(${generalLedgerEntryAttachmentsGeneralLedgerEntryNumber},${generalLedgerEntryAttachmentsId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('GeneralLedgerEntryAttachments', 'patchGeneralLedgerEntryAttachments', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchGeneralLedgerEntryAttachments'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPurchaseInvoices
* @pronghornType method
* @name listPurchaseInvoices
* @summary listPurchaseInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPurchaseInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPurchaseInvoices(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listPurchaseInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'listPurchaseInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPurchaseInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postPurchaseInvoice
* @pronghornType method
* @name postPurchaseInvoice
* @summary postPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postPurchaseInvoice(companyId, body, callback) {
const meth = 'adapter-postPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'postPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPurchaseInvoice
* @pronghornType method
* @name getPurchaseInvoice
* @summary getPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPurchaseInvoice(companyId, purchaseInvoiceId, expand, select, callback) {
const meth = 'adapter-getPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'getPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePurchaseInvoice
* @pronghornType method
* @name deletePurchaseInvoice
* @summary deletePurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePurchaseInvoice(companyId, purchaseInvoiceId, callback) {
const meth = 'adapter-deletePurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'deletePurchaseInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPurchaseInvoice
* @pronghornType method
* @name patchPurchaseInvoice
* @summary patchPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPurchaseInvoice(companyId, purchaseInvoiceId, body, callback) {
const meth = 'adapter-patchPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'patchPurchaseInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postActionPurchaseInvoices
* @pronghornType method
* @name postActionPurchaseInvoices
* @summary postActionPurchaseInvoices
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postActionPurchaseInvoices
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postActionPurchaseInvoices(companyId, purchaseInvoiceId, callback) {
const meth = 'adapter-postActionPurchaseInvoices';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoice', 'postActionPurchaseInvoices', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postActionPurchaseInvoices'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPurchaseInvoiceLinesForPurchaseInvoice
* @pronghornType method
* @name listPurchaseInvoiceLinesForPurchaseInvoice
* @summary listPurchaseInvoiceLinesForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPurchaseInvoiceLinesForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPurchaseInvoiceLinesForPurchaseInvoice(companyId, purchaseInvoiceId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listPurchaseInvoiceLinesForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'listPurchaseInvoiceLinesForPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPurchaseInvoiceLinesForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postPurchaseInvoiceLineForPurchaseInvoice
* @pronghornType method
* @name postPurchaseInvoiceLineForPurchaseInvoice
* @summary postPurchaseInvoiceLineForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postPurchaseInvoiceLineForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postPurchaseInvoiceLineForPurchaseInvoice(companyId, purchaseInvoiceId, body, callback) {
const meth = 'adapter-postPurchaseInvoiceLineForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'postPurchaseInvoiceLineForPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPurchaseInvoiceLineForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPurchaseInvoiceLineForPurchaseInvoice
* @pronghornType method
* @name getPurchaseInvoiceLineForPurchaseInvoice
* @summary getPurchaseInvoiceLineForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPurchaseInvoiceLineForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPurchaseInvoiceLineForPurchaseInvoice(companyId, purchaseInvoiceId, purchaseInvoiceLineId, expand, select, callback) {
const meth = 'adapter-getPurchaseInvoiceLineForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`, `purchaseInvoiceLines('${purchaseInvoiceId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'getPurchaseInvoiceLineForPurchaseInvoice', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPurchaseInvoiceLineForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePurchaseInvoiceLineForPurchaseInvoice
* @pronghornType method
* @name deletePurchaseInvoiceLineForPurchaseInvoice
* @summary deletePurchaseInvoiceLineForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePurchaseInvoiceLineForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePurchaseInvoiceLineForPurchaseInvoice(companyId, purchaseInvoiceId, purchaseInvoiceLineId, callback) {
const meth = 'adapter-deletePurchaseInvoiceLineForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`, `purchaseInvoiceLines('${purchaseInvoiceId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'deletePurchaseInvoiceLineForPurchaseInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePurchaseInvoiceLineForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPurchaseInvoiceLineForPurchaseInvoice
* @pronghornType method
* @name patchPurchaseInvoiceLineForPurchaseInvoice
* @summary patchPurchaseInvoiceLineForPurchaseInvoice
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceId - (v1.0) id for purchaseInvoice
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPurchaseInvoiceLineForPurchaseInvoice
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPurchaseInvoiceLineForPurchaseInvoice(companyId, purchaseInvoiceId, purchaseInvoiceLineId, body, callback) {
const meth = 'adapter-patchPurchaseInvoiceLineForPurchaseInvoice';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceId === undefined || purchaseInvoiceId === null || purchaseInvoiceId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoices(${purchaseInvoiceId})`, `purchaseInvoiceLines('${purchaseInvoiceId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'patchPurchaseInvoiceLineForPurchaseInvoice', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPurchaseInvoiceLineForPurchaseInvoice'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listPurchaseInvoiceLines
* @pronghornType method
* @name listPurchaseInvoiceLines
* @summary listPurchaseInvoiceLines
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listPurchaseInvoiceLines
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listPurchaseInvoiceLines(companyId, top, skip, limit, filter, expand, select, callback) {
const meth = 'adapter-listPurchaseInvoiceLines';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'listPurchaseInvoiceLines', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listPurchaseInvoiceLines'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postPurchaseInvoiceLine
* @pronghornType method
* @name postPurchaseInvoiceLine
* @summary postPurchaseInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postPurchaseInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postPurchaseInvoiceLine(companyId, body, callback) {
const meth = 'adapter-postPurchaseInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'postPurchaseInvoiceLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postPurchaseInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getPurchaseInvoiceLine
* @pronghornType method
* @name getPurchaseInvoiceLine
* @summary getPurchaseInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {array} [expand] - (v1.0) Entities to expand
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getPurchaseInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getPurchaseInvoiceLine(companyId, purchaseInvoiceLineId, expand, select, callback) {
const meth = 'adapter-getPurchaseInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { expand, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoiceLines('${purchaseInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'getPurchaseInvoiceLine', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getPurchaseInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deletePurchaseInvoiceLine
* @pronghornType method
* @name deletePurchaseInvoiceLine
* @summary deletePurchaseInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deletePurchaseInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deletePurchaseInvoiceLine(companyId, purchaseInvoiceLineId, callback) {
const meth = 'adapter-deletePurchaseInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoiceLines('${purchaseInvoiceLineId}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'deletePurchaseInvoiceLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deletePurchaseInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchPurchaseInvoiceLine
* @pronghornType method
* @name patchPurchaseInvoiceLine
* @summary patchPurchaseInvoiceLine
*
* @param {string} companyId - (v1.0) id for company
* @param {string} purchaseInvoiceLineId - (v1.0) id for purchaseInvoiceLine
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchPurchaseInvoiceLine
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchPurchaseInvoiceLine(companyId, purchaseInvoiceLineId, body, callback) {
const meth = 'adapter-patchPurchaseInvoiceLine';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (purchaseInvoiceLineId === undefined || purchaseInvoiceLineId === null || purchaseInvoiceLineId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['purchaseInvoiceLineId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `purchaseInvoiceLines('${purchaseInvoiceLineId}')`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('PurchaseInvoiceLine', 'patchPurchaseInvoiceLine', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchPurchaseInvoiceLine'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listProjects
* @pronghornType method
* @name listProjects
* @summary listProjects
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listProjects
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listProjects(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listProjects';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Project', 'listProjects', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listProjects'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postProject
* @pronghornType method
* @name postProject
* @summary postProject
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postProject
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postProject(companyId, body, callback) {
const meth = 'adapter-postProject';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Project', 'postProject', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postProject'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getProject
* @pronghornType method
* @name getProject
* @summary getProject
*
* @param {string} companyId - (v1.0) id for company
* @param {string} projectId - (v1.0) id for project
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getProject
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getProject(companyId, projectId, select, callback) {
const meth = 'adapter-getProject';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (projectId === undefined || projectId === null || projectId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['projectId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `projects(${projectId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Project', 'getProject', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getProject'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteProject
* @pronghornType method
* @name deleteProject
* @summary deleteProject
*
* @param {string} companyId - (v1.0) id for company
* @param {string} projectId - (v1.0) id for project
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteProject
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteProject(companyId, projectId, callback) {
const meth = 'adapter-deleteProject';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (projectId === undefined || projectId === null || projectId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['projectId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `projects(${projectId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Project', 'deleteProject', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteProject'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchProject
* @pronghornType method
* @name patchProject
* @summary patchProject
*
* @param {string} companyId - (v1.0) id for company
* @param {string} projectId - (v1.0) id for project
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchProject
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchProject(companyId, projectId, body, callback) {
const meth = 'adapter-patchProject';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (projectId === undefined || projectId === null || projectId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['projectId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `projects(${projectId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('Project', 'patchProject', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchProject'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listBankAccounts
* @pronghornType method
* @name listBankAccounts
* @summary listBankAccounts
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listBankAccounts
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listBankAccounts(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listBankAccounts';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BankAccount', 'listBankAccounts', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listBankAccounts'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function postBankAccount
* @pronghornType method
* @name postBankAccount
* @summary postBankAccount
*
* @param {string} companyId - (v1.0) id for company
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /postBankAccount
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
postBankAccount(companyId, body, callback) {
const meth = 'adapter-postBankAccount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BankAccount', 'postBankAccount', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postBankAccount'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getBankAccount
* @pronghornType method
* @name getBankAccount
* @summary getBankAccount
*
* @param {string} companyId - (v1.0) id for company
* @param {string} bankAccountId - (v1.0) id for bankAccount
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getBankAccount
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getBankAccount(companyId, bankAccountId, select, callback) {
const meth = 'adapter-getBankAccount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (bankAccountId === undefined || bankAccountId === null || bankAccountId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['bankAccountId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `bankAccounts(${bankAccountId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BankAccount', 'getBankAccount', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getBankAccount'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function deleteBankAccount
* @pronghornType method
* @name deleteBankAccount
* @summary deleteBankAccount
*
* @param {string} companyId - (v1.0) id for company
* @param {string} bankAccountId - (v1.0) id for bankAccount
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /deleteBankAccount
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
deleteBankAccount(companyId, bankAccountId, callback) {
const meth = 'adapter-deleteBankAccount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (bankAccountId === undefined || bankAccountId === null || bankAccountId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['bankAccountId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `bankAccounts(${bankAccountId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BankAccount', 'deleteBankAccount', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['deleteBankAccount'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function patchBankAccount
* @pronghornType method
* @name patchBankAccount
* @summary patchBankAccount
*
* @param {string} companyId - (v1.0) id for company
* @param {string} bankAccountId - (v1.0) id for bankAccount
* @param {object} body - body param
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /patchBankAccount
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
patchBankAccount(companyId, bankAccountId, body, callback) {
const meth = 'adapter-patchBankAccount';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (bankAccountId === undefined || bankAccountId === null || bankAccountId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['bankAccountId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (body === undefined || body === null || body === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['body'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = {};
const queryParams = {};
const pathVars = [`companies(${companyId})`, `bankAccounts(${bankAccountId})`];
const bodyVars = body;
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// if you want to expose addlHeaders to workflow, add it to the method signature here and in pronghorn.json
let thisHeaderData = null;
// if the additional headers was passed in as a string parse the json into an object
if (thisHeaderData !== null && thisHeaderData.constructor === String) {
try {
// parse the additional headers object that was passed in
thisHeaderData = JSON.parse(thisHeaderData);
} catch (err) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'addlHeaders string must be a stringified JSON', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
} else if (thisHeaderData === null) {
thisHeaderData = { ifMatch: '' };
}
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams,
addlHeaders: thisHeaderData
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('BankAccount', 'patchBankAccount', reqObj, false, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['patchBankAccount'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listCustomerSales
* @pronghornType method
* @name listCustomerSales
* @summary listCustomerSales
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listCustomerSales
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listCustomerSales(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listCustomerSales';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerSale', 'listCustomerSales', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listCustomerSales'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getCustomerSale
* @pronghornType method
* @name getCustomerSale
* @summary getCustomerSale
*
* @param {string} companyId - (v1.0) id for company
* @param {string} customerSaleCustomerId - (v1.0) customerId for customerSale
* @param {string} customerSaleCustomerNumber - (v1.0) customerNumber for customerSale
* @param {string} customerSaleName - (v1.0) name for customerSale
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getCustomerSale
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getCustomerSale(companyId, customerSaleCustomerId, customerSaleCustomerNumber, customerSaleName, select, callback) {
const meth = 'adapter-getCustomerSale';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerSaleCustomerId === undefined || customerSaleCustomerId === null || customerSaleCustomerId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerSaleCustomerId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerSaleCustomerNumber === undefined || customerSaleCustomerNumber === null || customerSaleCustomerNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerSaleCustomerNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (customerSaleName === undefined || customerSaleName === null || customerSaleName === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['customerSaleName'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `customerSales(${customerSaleCustomerId},'${customerSaleCustomerNumber}','${customerSaleName}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('CustomerSale', 'getCustomerSale', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getCustomerSale'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function listVendorPurchases
* @pronghornType method
* @name listVendorPurchases
* @summary listVendorPurchases
*
* @param {string} companyId - (v1.0) id for company
* @param {number} [top] - (v1.0) Number of items to return from the top of the list
* @param {number} [skip] - (v1.0) Number of items to skip from the list
* @param {number} [limit] - (v1.0) Number of items to return from the list
* @param {string} [filter] - (v1.0) Filtering expression
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /listVendorPurchases
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
listVendorPurchases(companyId, top, skip, limit, filter, select, callback) {
const meth = 'adapter-listVendorPurchases';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { top, skip, limit, filter, select };
const queryParams = {};
const pathVars = [`companies(${companyId})`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('VendorPurchase', 'listVendorPurchases', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['listVendorPurchases'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
/**
* @function getVendorPurchase
* @pronghornType method
* @name getVendorPurchase
* @summary getVendorPurchase
*
* @param {string} companyId - (v1.0) id for company
* @param {string} vendorPurchaseVendorId - (v1.0) vendorId for vendorPurchase
* @param {string} vendorPurchaseVendorNumber - (v1.0) vendorNumber for vendorPurchase
* @param {string} vendorPurchaseName - (v1.0) name for vendorPurchase
* @param {array} [select] - (v1.0) Selected properties to be retrieved
* @param {getCallback} callback - a callback function to return the result
* @return {object} results - An object containing the response of the action
*
* @route {POST} /getVendorPurchase
* @roles admin
* @task true
*/
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
getVendorPurchase(companyId, vendorPurchaseVendorId, vendorPurchaseVendorNumber, vendorPurchaseName, select, callback) {
const meth = 'adapter-getVendorPurchase';
const origin = `${this.id}-${meth}`;
log.trace(origin);
if (this.suspended && this.suspendMode === 'error') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU VALIDATE DATA */
if (companyId === undefined || companyId === null || companyId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['companyId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorPurchaseVendorId === undefined || vendorPurchaseVendorId === null || vendorPurchaseVendorId === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorPurchaseVendorId'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorPurchaseVendorNumber === undefined || vendorPurchaseVendorNumber === null || vendorPurchaseVendorNumber === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorPurchaseVendorNumber'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
if (vendorPurchaseName === undefined || vendorPurchaseName === null || vendorPurchaseName === '') {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['vendorPurchaseName'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
const queryParamsAvailable = { select };
const queryParams = {};
const pathVars = [`companies(${companyId})`, `vendorPurchases(${vendorPurchaseVendorId},'${vendorPurchaseVendorNumber}','${vendorPurchaseName}')`];
const bodyVars = {};
// loop in template. long callback arg name to avoid identifier conflicts
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
}
});
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders, authData, callProperties, filter, priority, event
// see adapter code documentation for more information on the request object's fields
const reqObj = {
payload: bodyVars,
uriPathVars: pathVars,
uriQuery: queryParams
};
reqObj.authData = { uriPathVars: [this.allProps.authentication.tenant_id] };
try {
// Make the call -
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
return this.requestHandlerInst.identifyRequest('VendorPurchase', 'getVendorPurchase', reqObj, true, (irReturnData, irReturnError) => {
// if we received an error or their is no response on the results
// return an error
if (irReturnError) {
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
return callback(null, irReturnError);
}
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['getVendorPurchase'], null, null, null);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
// return the response
return callback(irReturnData, null);
});
} catch (ex) {
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
return callback(null, errorObj);
}
}
}
module.exports = MicrosoftDynamics;