1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-09-11 13:15:28 +03:00

Separated Insight report from Ad, Ad Description

This commit is contained in:
Rupenieks 2020-05-14 14:36:16 +02:00
parent 5775a0c59a
commit 94278b2e56
3 changed files with 409 additions and 27 deletions

View File

@ -0,0 +1,355 @@
import { INodeProperties } from "n8n-workflow";
export const adOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'ad'
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create an ad.',
},
{
name: 'Get',
value: 'get',
description: 'Get ads.',
}
],
default: 'create',
description: 'The operation to perform.',
},
{
displayName: 'Get by',
name: 'getBy',
type: 'options',
displayOptions: {
show: {
operation: [
'get'
],
},
},
options: [
{
name: 'ID',
value: 'id',
description: 'Get ad by ID.',
},
{
name: 'Ad Account',
value: 'adAccount',
description: 'Get ad by account.',
},
{
name: 'Ad Campaign',
value: 'adCampaign',
description: 'Get ad by campaign.',
},
{
name: 'Ad Set',
value: 'adSet',
description: 'Get ad by ad set.',
},
],
default: 'id',
description: 'Means through which to get Ad.',
},
] as INodeProperties[];
export const adFields = [
/* -------------------------------------------------------------------------- */
/* ad:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Ad ID',
name: 'itemId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get'
],
getBy: [
'id'
],
},
},
description: 'ID of ad to get.',
default: ''
},
{
displayName: 'Ad Account ID',
name: 'itemId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get'
],
getBy: [
'adAccount'
],
},
},
description: 'ID of ad account.',
default: ''
},
{
displayName: 'Campaign ID',
name: 'itemId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get'
],
getBy: [
'adCampaign'
],
},
},
description: 'ID of ad campaign.',
default: ''
},
{
displayName: 'Ad Set ID',
name: 'itemId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'get'
],
getBy: [
'adSet'
],
},
},
description: 'ID of ad set.',
default: ''
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
operation: [
'get'
],
getBy: [
'adAccount'
],
},
},
options: [
{
displayName: 'Date Preset',
name: 'datePreset',
type: 'options',
description: 'Represents a relative time range. This field is ignored if Time Range or Time Ranges is specified.',
default: 'today',
options: [
{
name: 'Today',
value: 'today'
},
{
name: 'Yesterday',
value: 'yesterday'
},
{
name: 'This Month',
value: 'this_month'
},
{
name: 'Last Month',
value: 'last_month'
},
{
name: 'This Quarter',
value: 'this_quarter'
},
{
name: 'Lifetime',
value: 'lifetime'
},
{
name: 'Last 3 Days',
value: 'last_3d'
},
{
name: 'Last 7 Days',
value: 'last_7d'
},
{
name: 'Last 14 Days',
value: 'last_14d'
},
{
name: 'Last 28 Days',
value: 'last_28d'
},
{
name: 'Last 30 Days',
value: 'last_30d'
},
{
name: 'Last 90 Days',
value: 'last_90d'
},
{
name: 'Last Week (Mon-Sun)',
value: 'last_week_mon_sun'
},
{
name: 'Last Week (Sun-Sat)',
value: 'last_week_sun_sat'
},
{
name: 'Last Quarter',
value: 'last_quarter'
},
{
name: 'Last Year',
value: 'last_year'
},
{
name: 'This Week (Mon-Today)',
value: 'this_week_mon_today'
},
{
name: 'This Week (Sun-Today)',
value: 'this_week_sun_today'
},
{
name: 'This Year',
value: 'this_year'
},
]
},
{
displayName: 'Effective Status',
name: 'effectiveStatus',
type: 'fixedCollection',
description: 'Filter ads by effective status.',
typeOptions: {
multipleValues: true
},
default: 'impression',
options: [
{
displayName: 'Status',
name: 'properties',
values: [
{
name: 'ACTIVE',
value: 'ACTIVE'
},
{
name: 'ARCHIVED',
value: 'ARCHIVED'
},
{
name: 'DELETED',
value: 'DELETED'
},
{
name: 'PAUSED',
value: 'PAUSED'
},
]
}
]
},
{
displayName: 'Time Range',
name: 'timeRange',
type: 'fixedCollection',
default: 'properties',
description: 'A single time range object. This param is ignored if time_ranges is provided.',
options: [
{
displayName: 'Time Range Properties',
name: 'properties',
values: [
{
displayName: 'Since',
name: 'since',
type: 'dateTime',
default: '',
description: 'A date in the format of "YYYY-MM-DD", which means from the beginning midnight of that day.',
required: true
},
{
displayName: 'Until',
name: 'until',
type: 'dateTime',
default: '',
description: 'A date in the format of "YYYY-MM-DD", which means to the beginning midnight of the following day.',
required: true
},
]
},
]
},
{
displayName: 'Updated Since',
name: 'updatedSince',
type: 'number',
required: true,
description: 'Time since the Ad has been updated.',
default: ''
}
]
},
/* -------------------------------------------------------------------------- */
/* ad:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Ad Creative ID',
name: 'adCreativeId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'create'
],
},
},
description: 'ID of ad creative.',
default: ''
},
{
displayName: 'Ad Set ID',
name: 'adSetId',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'create'
],
},
},
description: 'ID of ad creative.',
default: ''
},
] as INodeProperties[];

View File

@ -1,13 +1,45 @@
import { INodeProperties } from "n8n-workflow";
export const adOperations = [
export const adInsightsOperations = [
{
displayName: 'Type',
name: 'type',
type: 'options',
displayOptions: {
show: {
resource: [
'insightsReport'
]
}
},
options: [
{
name: 'Ad',
value: 'ad'
},
{
name: 'Ad Account',
value: 'adAccount'
},
{
name: 'Ad Campaign',
value: 'adCampaign'
},
{
name: 'Ad Set',
value: 'adSet'
}
],
default: 'ad',
description: 'The description text',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
type: [
'adAccount', 'adCampaign', 'adSet', 'ad'
],
},
@ -16,12 +48,12 @@ export const adOperations = [
{
name: 'Create',
value: 'create',
description: 'Create insights report run.',
description: 'Create a insights report run.',
},
{
name: 'Get',
value: 'get',
description: 'Get insights report.',
description: 'Get an insights report.',
}
],
default: 'create',
@ -29,7 +61,7 @@ export const adOperations = [
},
] as INodeProperties[];
export const adFields = [
export const adInsightsFields = [
/* -------------------------------------------------------------------------- */
/* ad*:get/create */
@ -41,7 +73,7 @@ export const adFields = [
required: true,
displayOptions: {
show: {
resource: [
type: [
'ad'
],
operation: [
@ -58,7 +90,7 @@ export const adFields = [
required: true,
displayOptions: {
show: {
resource: [
type: [
'adAccount', 'adCampaign', 'adSet', 'ad'
],
operation: [
@ -75,7 +107,7 @@ export const adFields = [
required: true,
displayOptions: {
show: {
resource: [
type: [
'adSet'
],
operation: [
@ -92,7 +124,7 @@ export const adFields = [
required: true,
displayOptions: {
show: {
resource: [
type: [
'adAccount', 'adCampaign'
],
operation: [
@ -110,7 +142,7 @@ export const adFields = [
description: 'Insert JSON data instead of manual parameter selection.',
displayOptions: {
show: {
resource: [
type: [
'ad', 'adAccount', 'adCampaign', 'adSet'
],
operation: [
@ -129,7 +161,7 @@ export const adFields = [
default: '',
displayOptions: {
show: {
resource: [
type: [
'ad', 'adAccount', 'adCampaign', 'adSet'
],
operation: [
@ -149,7 +181,7 @@ export const adFields = [
default: {},
displayOptions: {
show: {
resource: [
type: [
'ad', 'adAccount', 'adCampaign', 'adSet'
],
operation: [

View File

@ -5,9 +5,10 @@ import {
INodeTypeDescription,
IDataObject
} from 'n8n-workflow';
import { adOperations, adFields } from './AdAccountInsightDescription';
import { adInsightsOperations, adInsightsFields } from './AdInsightsDescription';
import { IAdInsightParameters, IFilter, ITimeRange } from './AdInsightInterface';
import { validateJSON, facebookAdsApiRequest } from './GenericFunctions';
import { adFields, adOperations } from './AdDescription';
export class FacebookAds implements INodeType {
@ -41,25 +42,19 @@ export class FacebookAds implements INodeType {
value: 'ad'
},
{
name: 'Ad Account',
value: 'adAccount'
},
{
name: 'Ad Campaign',
value: 'adCampaign'
},
{
name: 'Ad Set',
value: 'adSet'
name: 'Insights Report',
value: 'insightsReport'
}
],
default: 'ad',
description: 'The description text',
description: 'Facebook Ads resource to use.',
},
// Ad Account
// Ad
...adOperations,
...adFields
...adFields,
// Ad Insights
...adInsightsOperations,
...adInsightsFields
]
};