mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Small improvements to ZohoCRM-Node and OAuth fix
This commit is contained in:
@@ -9,12 +9,9 @@ import {
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function zohoApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('zohoOAuth2Api');
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
//@ts-ignore
|
||||
Authorization: `Zoho-oauthtoken ${credentials!.oauthTokenData.access_token}`
|
||||
},
|
||||
method,
|
||||
body: {
|
||||
|
||||
@@ -80,12 +80,16 @@ export class ZohoCrm implements INodeType {
|
||||
// }
|
||||
responseData = await zohoApiRequest.call(this, 'POST', '/leads', body);
|
||||
responseData = responseData.data;
|
||||
|
||||
} else {
|
||||
throw new Error(`The operation "${operation}" is not known!`);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`The resource "${resource}" is not known!`);
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
} else {
|
||||
} else if (responseData !== undefined) {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user