n8n/packages/nodes-base/nodes/Google/Ads/GoogleAds.node.ts

72 lines
1.6 KiB
TypeScript
Raw Normal View History

import type { INodeType, INodeTypeDescription } from 'n8n-workflow';
feat(Google Ads Node): Add new node (#3526) * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add api call to getall * Fix formdata in the body for the request * N8N-2928 Added custom queries to campaign * Fix header bug and add developer-token field * Add operation and fields to campaign new format * Add more configurations and queries * Add Invoice ressources and operations * Remov old version from the node * Fixed bud with typo * Correctly prepends the baseURL * add query to invocie request * Fixes header not parsing the expression * Invoice param changes * Fixes bug related to headers not being parsed, and bug with auth * Remove useless imports * Added analytics to google ad node and removed useless header * Removed url for testing * Fixed inconsistent behaviour with the access token not being refreshed * Added placeholders to help user * Removed useless comments * Resolved name confusion * Added support for body in a GET method * Removed hyphens, parse body's expression * Renamed operation for clarity * Remove unused code * Removed invoice resource and fixed bug with body and headers The invoice operation was removed since it does not reflect what a user would expect from it. Google ADS invoices are only used for big advertisers where invoicing is performed after the end of the month and for big sums. This would be misleading for the majority of the users expecting an expenses report. Also fixed a bug with header and body being sent since it was broken for multiple input rows. The first execution would override all others. Lastly, made some improvements to the node itself by transforming data, adding filters and operations. * Improve campagin operation and remove analytics; fix tests * Improve tooltips and descriptions * Fix lint issues * Improve tooltip to explain amounts in micros * Change wording for micros * Change the fix to a more elegant solution Co-authored-by: Cyril Gobrecht <cyril.gobrecht@gmail.com> Co-authored-by: Aël Gobrecht <ael.gobrecht@gmail.com>
2022-07-04 13:47:50 -07:00
import { campaignFields, campaignOperations } from './CampaignDescription';
feat(Google Ads Node): Add new node (#3526) * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add api call to getall * Fix formdata in the body for the request * N8N-2928 Added custom queries to campaign * Fix header bug and add developer-token field * Add operation and fields to campaign new format * Add more configurations and queries * Add Invoice ressources and operations * Remov old version from the node * Fixed bud with typo * Correctly prepends the baseURL * add query to invocie request * Fixes header not parsing the expression * Invoice param changes * Fixes bug related to headers not being parsed, and bug with auth * Remove useless imports * Added analytics to google ad node and removed useless header * Removed url for testing * Fixed inconsistent behaviour with the access token not being refreshed * Added placeholders to help user * Removed useless comments * Resolved name confusion * Added support for body in a GET method * Removed hyphens, parse body's expression * Renamed operation for clarity * Remove unused code * Removed invoice resource and fixed bug with body and headers The invoice operation was removed since it does not reflect what a user would expect from it. Google ADS invoices are only used for big advertisers where invoicing is performed after the end of the month and for big sums. This would be misleading for the majority of the users expecting an expenses report. Also fixed a bug with header and body being sent since it was broken for multiple input rows. The first execution would override all others. Lastly, made some improvements to the node itself by transforming data, adding filters and operations. * Improve campagin operation and remove analytics; fix tests * Improve tooltips and descriptions * Fix lint issues * Improve tooltip to explain amounts in micros * Change wording for micros * Change the fix to a more elegant solution Co-authored-by: Cyril Gobrecht <cyril.gobrecht@gmail.com> Co-authored-by: Aël Gobrecht <ael.gobrecht@gmail.com>
2022-07-04 13:47:50 -07:00
export class GoogleAds implements INodeType {
description: INodeTypeDescription = {
displayName: 'Google Ads',
name: 'googleAds',
icon: 'file:googleAds.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Use the Google Ads API',
defaults: {
name: 'Google Ads',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'googleAdsOAuth2Api',
required: true,
testedBy: {
request: {
method: 'GET',
url: '/v13/customers:listAccessibleCustomers',
feat(Google Ads Node): Add new node (#3526) * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add api call to getall * Fix formdata in the body for the request * N8N-2928 Added custom queries to campaign * Fix header bug and add developer-token field * Add operation and fields to campaign new format * Add more configurations and queries * Add Invoice ressources and operations * Remov old version from the node * Fixed bud with typo * Correctly prepends the baseURL * add query to invocie request * Fixes header not parsing the expression * Invoice param changes * Fixes bug related to headers not being parsed, and bug with auth * Remove useless imports * Added analytics to google ad node and removed useless header * Removed url for testing * Fixed inconsistent behaviour with the access token not being refreshed * Added placeholders to help user * Removed useless comments * Resolved name confusion * Added support for body in a GET method * Removed hyphens, parse body's expression * Renamed operation for clarity * Remove unused code * Removed invoice resource and fixed bug with body and headers The invoice operation was removed since it does not reflect what a user would expect from it. Google ADS invoices are only used for big advertisers where invoicing is performed after the end of the month and for big sums. This would be misleading for the majority of the users expecting an expenses report. Also fixed a bug with header and body being sent since it was broken for multiple input rows. The first execution would override all others. Lastly, made some improvements to the node itself by transforming data, adding filters and operations. * Improve campagin operation and remove analytics; fix tests * Improve tooltips and descriptions * Fix lint issues * Improve tooltip to explain amounts in micros * Change wording for micros * Change the fix to a more elegant solution Co-authored-by: Cyril Gobrecht <cyril.gobrecht@gmail.com> Co-authored-by: Aël Gobrecht <ael.gobrecht@gmail.com>
2022-07-04 13:47:50 -07:00
},
},
},
],
requestDefaults: {
returnFullResponse: true,
baseURL: 'https://googleads.googleapis.com',
headers: {
'developer-token': '={{$credentials.developerToken}}',
},
},
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Campaign',
value: 'campaign',
},
],
default: 'campaign',
},
//-------------------------------
// Campaign Operations
//-------------------------------
...campaignOperations,
{
displayName:
'Divide field names expressed with <i>micros</i> by 1,000,000 to get the actual value',
feat(Google Ads Node): Add new node (#3526) * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add api call to getall * Fix formdata in the body for the request * N8N-2928 Added custom queries to campaign * Fix header bug and add developer-token field * Add operation and fields to campaign new format * Add more configurations and queries * Add Invoice ressources and operations * Remov old version from the node * Fixed bud with typo * Correctly prepends the baseURL * add query to invocie request * Fixes header not parsing the expression * Invoice param changes * Fixes bug related to headers not being parsed, and bug with auth * Remove useless imports * Added analytics to google ad node and removed useless header * Removed url for testing * Fixed inconsistent behaviour with the access token not being refreshed * Added placeholders to help user * Removed useless comments * Resolved name confusion * Added support for body in a GET method * Removed hyphens, parse body's expression * Renamed operation for clarity * Remove unused code * Removed invoice resource and fixed bug with body and headers The invoice operation was removed since it does not reflect what a user would expect from it. Google ADS invoices are only used for big advertisers where invoicing is performed after the end of the month and for big sums. This would be misleading for the majority of the users expecting an expenses report. Also fixed a bug with header and body being sent since it was broken for multiple input rows. The first execution would override all others. Lastly, made some improvements to the node itself by transforming data, adding filters and operations. * Improve campagin operation and remove analytics; fix tests * Improve tooltips and descriptions * Fix lint issues * Improve tooltip to explain amounts in micros * Change wording for micros * Change the fix to a more elegant solution Co-authored-by: Cyril Gobrecht <cyril.gobrecht@gmail.com> Co-authored-by: Aël Gobrecht <ael.gobrecht@gmail.com>
2022-07-04 13:47:50 -07:00
name: 'campaigsNotice',
type: 'notice',
default: '',
displayOptions: {
show: {
resource: ['campaign'],
feat(Google Ads Node): Add new node (#3526) * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add basic layout with icon for Google Ads * Add node versioning(V1) * Add node and credential to package * Add api call to getall * Fix formdata in the body for the request * N8N-2928 Added custom queries to campaign * Fix header bug and add developer-token field * Add operation and fields to campaign new format * Add more configurations and queries * Add Invoice ressources and operations * Remov old version from the node * Fixed bud with typo * Correctly prepends the baseURL * add query to invocie request * Fixes header not parsing the expression * Invoice param changes * Fixes bug related to headers not being parsed, and bug with auth * Remove useless imports * Added analytics to google ad node and removed useless header * Removed url for testing * Fixed inconsistent behaviour with the access token not being refreshed * Added placeholders to help user * Removed useless comments * Resolved name confusion * Added support for body in a GET method * Removed hyphens, parse body's expression * Renamed operation for clarity * Remove unused code * Removed invoice resource and fixed bug with body and headers The invoice operation was removed since it does not reflect what a user would expect from it. Google ADS invoices are only used for big advertisers where invoicing is performed after the end of the month and for big sums. This would be misleading for the majority of the users expecting an expenses report. Also fixed a bug with header and body being sent since it was broken for multiple input rows. The first execution would override all others. Lastly, made some improvements to the node itself by transforming data, adding filters and operations. * Improve campagin operation and remove analytics; fix tests * Improve tooltips and descriptions * Fix lint issues * Improve tooltip to explain amounts in micros * Change wording for micros * Change the fix to a more elegant solution Co-authored-by: Cyril Gobrecht <cyril.gobrecht@gmail.com> Co-authored-by: Aël Gobrecht <ael.gobrecht@gmail.com>
2022-07-04 13:47:50 -07:00
},
},
},
...campaignFields,
],
};
}