mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-11 13:15:28 +03: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: [
|
options: [
|
||||||
{
|
|
||||||
name: 'Create',
|
|
||||||
value: 'create',
|
|
||||||
description: 'Create an ad.',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description: 'Get ads.',
|
description: 'Get ads.',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'get',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -170,9 +165,6 @@ export const adFields = [
|
|||||||
operation: [
|
operation: [
|
||||||
'get'
|
'get'
|
||||||
],
|
],
|
||||||
getBy: [
|
|
||||||
'adAccount'
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
@ -262,46 +254,12 @@ export const adFields = [
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Effective Status',
|
displayName: 'Fields',
|
||||||
name: 'effectiveStatus',
|
name: 'fields',
|
||||||
type: 'fixedCollection',
|
type: 'string',
|
||||||
description: 'Filter ads by effective status.',
|
description: 'Comma separated fields of ad item you want to retrieve.',
|
||||||
typeOptions: {
|
|
||||||
multipleValues: true
|
|
||||||
},
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
displayName: 'Status Properties',
|
|
||||||
name: 'properties',
|
|
||||||
values: [
|
|
||||||
{
|
|
||||||
displayName: 'Status',
|
|
||||||
name: 'status',
|
|
||||||
type: 'options',
|
|
||||||
default: '',
|
default: '',
|
||||||
description: 'Effective status.',
|
placeholder: 'bid_amount,campaign'
|
||||||
options: [
|
|
||||||
{
|
|
||||||
name: 'ACTIVE',
|
|
||||||
value: 'ACTIVE'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'ARCHIVED',
|
|
||||||
value: 'ARCHIVED'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'DELETED',
|
|
||||||
value: 'DELETED'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'PAUSED',
|
|
||||||
value: 'PAUSED'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Time Range',
|
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[];
|
] as INodeProperties[];
|
@ -484,7 +484,6 @@ export const adInsightsFields = [
|
|||||||
displayName: 'Filters',
|
displayName: 'Filters',
|
||||||
name: 'filters',
|
name: 'filters',
|
||||||
type: 'fixedCollection',
|
type: 'fixedCollection',
|
||||||
default: 'properties',
|
|
||||||
description: 'Filters on the report data. This parameter is an array of filter objects.',
|
description: 'Filters on the report data. This parameter is an array of filter objects.',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: true
|
multipleValues: true
|
||||||
|
@ -68,7 +68,7 @@ export class FacebookAds implements INodeType {
|
|||||||
const operation = this.getNodeParameter('operation', 0) as string;
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
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') {
|
if (operation === 'get' || operation === 'create') {
|
||||||
const jsonParameters = this.getNodeParameter('jsonParameters', itemIndex) as boolean;
|
const jsonParameters = this.getNodeParameter('jsonParameters', itemIndex) as boolean;
|
||||||
const body : IAdInsightParameters = {};
|
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)) {
|
if (Array.isArray(responseData)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user