Add Create and Update for Invoice API

This commit is contained in:
trojanh
2020-02-03 14:53:58 +05:30
parent 2a57b15e10
commit 0121e3b85c
3 changed files with 268 additions and 4 deletions

View File

@@ -362,6 +362,21 @@ export class Harvest implements INodeType {
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
returnData.push(responseData);
} else if (operation === 'update') {
// ----------------------------------
// update
// ----------------------------------
requestMethod = 'PATCH';
const id = this.getNodeParameter('id', i) as string;
endpoint = `${resource}/${id}`;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
Object.assign(body, updateFields);
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
returnData.push(responseData);
} else if (operation === 'delete') {
// ----------------------------------
// delete
@@ -574,7 +589,7 @@ export class Harvest implements INodeType {
requestMethod = 'POST';
endpoint = resource;
body.name = this.getNodeParameter('name', i) as string;
body.client_id = this.getNodeParameter('client_id', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields);