mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const affiliateOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const affiliateOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -58,12 +54,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['affiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The affiliate’s email',
|
||||
@@ -75,12 +67,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['affiliate'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -93,12 +81,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['affiliate'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -112,12 +96,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -170,7 +150,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
name: 'country',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The country’s ISO_3166-1 code. <a href="https://en.wikipedia.org/wiki/ISO_3166-1">Codes</a>.',
|
||||
description:
|
||||
'The country’s ISO_3166-1 code. <a href="https://en.wikipedia.org/wiki/ISO_3166-1">Codes</a>.',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -197,12 +178,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -219,12 +196,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -239,12 +212,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -256,15 +225,9 @@ export const affiliateFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -282,12 +245,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['affiliate'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -324,7 +283,8 @@ export const affiliateFields: INodeProperties[] = [
|
||||
name: 'referral_code',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'An affiliate’s referral code. This corresponds to the value of ref= in their referral link.',
|
||||
description:
|
||||
'An affiliate’s referral code. This corresponds to the value of ref= in their referral link.',
|
||||
},
|
||||
{
|
||||
displayName: 'Source ID',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const affiliateMetadataOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const affiliateMetadataOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -31,7 +27,7 @@ export const affiliateMetadataOperations: INodeProperties[] = [
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update affiliate\'s metadata',
|
||||
description: "Update affiliate's metadata",
|
||||
action: 'Update metadata for an affiliate',
|
||||
},
|
||||
],
|
||||
@@ -51,12 +47,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -68,12 +60,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
type: 'fixedCollection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -116,12 +104,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'remove',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['remove'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -132,12 +116,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'remove',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['remove'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -155,12 +135,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -171,12 +147,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -188,12 +160,8 @@ export const affiliateMetadataFields: INodeProperties[] = [
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'affiliateMetadata',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['affiliateMetadata'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -9,11 +7,19 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function tapfiliateApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function tapfiliateApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string | undefined,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('tapfiliateApi');
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
@@ -41,8 +47,15 @@ export async function tapfiliateApiRequest(this: IHookFunctions | IExecuteFuncti
|
||||
}
|
||||
}
|
||||
|
||||
export async function tapfiliateApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function tapfiliateApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -50,13 +63,12 @@ export async function tapfiliateApiRequestAllItems(this: IExecuteFunctions | ILo
|
||||
query.page = 1;
|
||||
|
||||
do {
|
||||
responseData = await tapfiliateApiRequest.call(this, method, endpoint, body, query, '', { resolveWithFullResponse: true });
|
||||
responseData = await tapfiliateApiRequest.call(this, method, endpoint, body, query, '', {
|
||||
resolveWithFullResponse: true,
|
||||
});
|
||||
returnData.push.apply(returnData, responseData.body);
|
||||
query.page++;
|
||||
|
||||
} while (
|
||||
responseData.headers.link.includes('next')
|
||||
);
|
||||
} while (responseData.headers.link.includes('next'));
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const programAffiliateOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const programAffiliateOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -66,15 +62,12 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: ['add'],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Affiliate ID',
|
||||
@@ -84,12 +77,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -102,12 +91,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'add',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -142,15 +127,12 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'approve',
|
||||
],
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: ['approve'],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Affiliate ID',
|
||||
@@ -159,12 +141,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'approve',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['approve'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -183,15 +161,12 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'disapprove',
|
||||
],
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: ['disapprove'],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Affiliate ID',
|
||||
@@ -200,12 +175,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'disapprove',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['disapprove'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -225,15 +196,12 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Affiliate ID',
|
||||
@@ -243,12 +211,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the affiliate',
|
||||
@@ -268,15 +232,12 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['programAffiliate'],
|
||||
},
|
||||
},
|
||||
description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
@@ -284,12 +245,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -301,15 +258,9 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -327,12 +278,8 @@ export const programAffiliateFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'programAffiliate',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['programAffiliate'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,25 +10,16 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
affiliateFields,
|
||||
affiliateOperations
|
||||
} from './AffiliateDescription';
|
||||
import { affiliateFields, affiliateOperations } from './AffiliateDescription';
|
||||
|
||||
import {
|
||||
affiliateMetadataFields,
|
||||
affiliateMetadataOperations,
|
||||
} from './AffiliateMetadataDescription';
|
||||
|
||||
import {
|
||||
programAffiliateFields,
|
||||
programAffiliateOperations,
|
||||
} from './ProgramAffiliateDescription';
|
||||
import { programAffiliateFields, programAffiliateOperations } from './ProgramAffiliateDescription';
|
||||
|
||||
import {
|
||||
tapfiliateApiRequest,
|
||||
tapfiliateApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { tapfiliateApiRequest, tapfiliateApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
export class Tapfiliate implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -87,7 +76,7 @@ export class Tapfiliate implements INodeType {
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get custom fields to display to user so that they can select them easily
|
||||
async getPrograms(this: ILoadOptionsFunctions,): Promise<INodePropertyOptions[]> {
|
||||
async getPrograms(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const programs = await tapfiliateApiRequestAllItems.call(this, 'GET', '/programs/');
|
||||
for (const program of programs) {
|
||||
@@ -147,13 +136,21 @@ export class Tapfiliate implements INodeType {
|
||||
if (operation === 'delete') {
|
||||
//https://tapfiliate.com/docs/rest/#affiliates-affiliate-delete
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/affiliates/${affiliateId}/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/affiliates/${affiliateId}/`,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
if (operation === 'get') {
|
||||
//https://tapfiliate.com/docs/rest/#affiliates-affiliate-get
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'GET', `/affiliates/${affiliateId}/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/affiliates/${affiliateId}/`,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -162,7 +159,13 @@ export class Tapfiliate implements INodeType {
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
Object.assign(qs, filters);
|
||||
if (returnAll) {
|
||||
responseData = await tapfiliateApiRequestAllItems.call(this, 'GET', `/affiliates/`, {}, qs);
|
||||
responseData = await tapfiliateApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/affiliates/`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'GET', `/affiliates/`, {}, qs);
|
||||
@@ -175,12 +178,21 @@ export class Tapfiliate implements INodeType {
|
||||
if (operation === 'add') {
|
||||
//https://tapfiliate.com/docs/rest/#affiliates-meta-data-key-put
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject || {}).metadataValues as IDataObject[] || [];
|
||||
const metadata =
|
||||
(((this.getNodeParameter('metadataUi', i) as IDataObject) || {})
|
||||
.metadataValues as IDataObject[]) || [];
|
||||
if (metadata.length === 0) {
|
||||
throw new NodeOperationError(this.getNode(), 'Metadata cannot be empty.', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Metadata cannot be empty.', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
for (const { key, value } of metadata) {
|
||||
await tapfiliateApiRequest.call(this, 'PUT', `/affiliates/${affiliateId}/meta-data/${key}/`, { value });
|
||||
await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/affiliates/${affiliateId}/meta-data/${key}/`,
|
||||
{ value },
|
||||
);
|
||||
}
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -188,7 +200,11 @@ export class Tapfiliate implements INodeType {
|
||||
//https://tapfiliate.com/docs/rest/#affiliates-meta-data-key-delete
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
const key = this.getNodeParameter('key', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/affiliates/${affiliateId}/meta-data/${key}/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/affiliates/${affiliateId}/meta-data/${key}/`,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -196,7 +212,12 @@ export class Tapfiliate implements INodeType {
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
const key = this.getNodeParameter('key', i) as string;
|
||||
const value = this.getNodeParameter('value', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'PUT', `/affiliates/${affiliateId}/meta-data/`, { [key]: value });
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/affiliates/${affiliateId}/meta-data/`,
|
||||
{ [key]: value },
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
@@ -213,28 +234,45 @@ export class Tapfiliate implements INodeType {
|
||||
};
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
responseData = await tapfiliateApiRequest.call(this, 'POST', `/programs/${programId}/affiliates/`, body);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/programs/${programId}/affiliates/`,
|
||||
body,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
if (operation === 'approve') {
|
||||
//https://tapfiliate.com/docs/rest/#programs-approve-an-affiliate-for-a-program-put
|
||||
const programId = this.getNodeParameter('programId', i) as string;
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'PUT', `/programs/${programId}/affiliates/${affiliateId}/approved/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/programs/${programId}/affiliates/${affiliateId}/approved/`,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
if (operation === 'disapprove') {
|
||||
//https://tapfiliate.com/docs/rest/#programs-approve-an-affiliate-for-a-program-delete
|
||||
const programId = this.getNodeParameter('programId', i) as string;
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/programs/${programId}/affiliates/${affiliateId}/approved/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/programs/${programId}/affiliates/${affiliateId}/approved/`,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
if (operation === 'get') {
|
||||
//https://tapfiliate.com/docs/rest/#programs-affiliate-in-program-get
|
||||
const programId = this.getNodeParameter('programId', i) as string;
|
||||
const affiliateId = this.getNodeParameter('affiliateId', i) as string;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'GET', `/programs/${programId}/affiliates/${affiliateId}/`);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/programs/${programId}/affiliates/${affiliateId}/`,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -244,10 +282,22 @@ export class Tapfiliate implements INodeType {
|
||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
Object.assign(qs, filters);
|
||||
if (returnAll) {
|
||||
responseData = await tapfiliateApiRequestAllItems.call(this, 'GET', `/programs/${programId}/affiliates/`, {}, qs);
|
||||
responseData = await tapfiliateApiRequestAllItems.call(
|
||||
this,
|
||||
'GET',
|
||||
`/programs/${programId}/affiliates/`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await tapfiliateApiRequest.call(this, 'GET', `/programs/${programId}/affiliates/`, {}, qs);
|
||||
responseData = await tapfiliateApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/programs/${programId}/affiliates/`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
returnData.push.apply(returnData, responseData);
|
||||
|
||||
Reference in New Issue
Block a user