mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
Ad get logic, fixed ad description (removed create feature)
This commit is contained in:
parent
39d7f16840
commit
117986fd48
|
@ -13,18 +13,13 @@ export const adOperations = [
|
|||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create an ad.',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get ads.',
|
||||
}
|
||||
],
|
||||
default: 'create',
|
||||
default: 'get',
|
||||
description: 'The operation to perform.',
|
||||
},
|
||||
{
|
||||
|
@ -170,9 +165,6 @@ export const adFields = [
|
|||
operation: [
|
||||
'get'
|
||||
],
|
||||
getBy: [
|
||||
'adAccount'
|
||||
],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
@ -262,46 +254,12 @@ export const adFields = [
|
|||
]
|
||||
},
|
||||
{
|
||||
displayName: 'Effective Status',
|
||||
name: 'effectiveStatus',
|
||||
type: 'fixedCollection',
|
||||
description: 'Filter ads by effective status.',
|
||||
typeOptions: {
|
||||
multipleValues: true
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Status Properties',
|
||||
name: 'properties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: '',
|
||||
description: 'Effective status.',
|
||||
options: [
|
||||
{
|
||||
name: 'ACTIVE',
|
||||
value: 'ACTIVE'
|
||||
},
|
||||
{
|
||||
name: 'ARCHIVED',
|
||||
value: 'ARCHIVED'
|
||||
},
|
||||
{
|
||||
name: 'DELETED',
|
||||
value: 'DELETED'
|
||||
},
|
||||
{
|
||||
name: 'PAUSED',
|
||||
value: 'PAUSED'
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
displayName: 'Fields',
|
||||
name: 'fields',
|
||||
type: 'string',
|
||||
description: 'Comma separated fields of ad item you want to retrieve.',
|
||||
default: '',
|
||||
placeholder: 'bid_amount,campaign'
|
||||
},
|
||||
{
|
||||
displayName: 'Time Range',
|
||||
|
@ -334,54 +292,6 @@ export const adFields = [
|
|||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
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: {
|
||||
resource: [
|
||||
'ad'
|
||||
],
|
||||
operation: [
|
||||
'create'
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'ID of ad creative.',
|
||||
default: ''
|
||||
},
|
||||
{
|
||||
displayName: 'Ad Set ID',
|
||||
name: 'adSetId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'ad'
|
||||
],
|
||||
operation: [
|
||||
'create'
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'ID of ad creative.',
|
||||
default: ''
|
||||
},
|
||||
] as INodeProperties[];
|
|
@ -484,7 +484,6 @@ export const adInsightsFields = [
|
|||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'fixedCollection',
|
||||
default: 'properties',
|
||||
description: 'Filters on the report data. This parameter is an array of filter objects.',
|
||||
typeOptions: {
|
||||
multipleValues: true
|
||||
|
|
|
@ -68,7 +68,7 @@ export class FacebookAds implements INodeType {
|
|||
const operation = this.getNodeParameter('operation', 0) as string;
|
||||
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
if (resource === 'adAccount' || resource === 'ad' || resource === 'adSet' || resource === 'adCampaign') {
|
||||
if (resource === 'insightsReport') {
|
||||
if (operation === 'get' || operation === 'create') {
|
||||
const jsonParameters = this.getNodeParameter('jsonParameters', itemIndex) as boolean;
|
||||
const body : IAdInsightParameters = {};
|
||||
|
@ -182,7 +182,51 @@ export class FacebookAds implements INodeType {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'ad') {
|
||||
if (operation === 'get') {
|
||||
const body : IAdInsightParameters = {};
|
||||
const itemId : string = this.getNodeParameter('itemId', itemIndex) as string;
|
||||
const getBy : string = this.getNodeParameter('getBy', itemIndex) as string;
|
||||
const additionalFields : IDataObject = this.getNodeParameter('additionalFields', itemIndex) as IDataObject;
|
||||
|
||||
if (additionalFields) {
|
||||
if (additionalFields.datePreset) {
|
||||
body.date_preset = additionalFields.datePreset as string;
|
||||
}
|
||||
if (additionalFields.datePreset) {
|
||||
body.fields = additionalFields.fields.split(',') as string[];
|
||||
}
|
||||
if (additionalFields.timeRange) {
|
||||
body.time_range = additionalFields.timeRange.properties as ITimeRange;
|
||||
}
|
||||
}
|
||||
|
||||
let endpoint : string;
|
||||
let method : string;
|
||||
|
||||
if (getBy === 'id') {
|
||||
endpoint = `${itemId}`;
|
||||
method = 'GET';
|
||||
responseData = await facebookAdsApiRequest.call(this, method, endpoint, body);
|
||||
}
|
||||
if (getBy === 'adAccount') {
|
||||
endpoint = `act_${itemId}/ads`;
|
||||
method = 'GET';
|
||||
responseData = await facebookAdsApiRequest.call(this, method, endpoint, body);
|
||||
}
|
||||
if (getBy === 'adCampaign') {
|
||||
endpoint = `${itemId}/ads`;
|
||||
method = 'GET';
|
||||
responseData = await facebookAdsApiRequest.call(this, method, endpoint, body);
|
||||
}
|
||||
if (getBy === 'adSet') {
|
||||
endpoint = `${itemId}/ads`;
|
||||
method = 'GET';
|
||||
responseData = await facebookAdsApiRequest.call(this, method, endpoint, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(responseData)) {
|
||||
|
|
Loading…
Reference in a new issue