@pipedream/google_ads 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +4 -4
  2. package/actions/add-contact-to-list-by-email/add-contact-to-list-by-email.mjs +1 -1
  3. package/actions/common/bidding.mjs +196 -0
  4. package/actions/common/conversion-upload.mjs +131 -0
  5. package/actions/common/props.mjs +1 -1
  6. package/actions/create-ad-group-report/create-ad-group-report.mjs +2 -2
  7. package/actions/create-ad-report/create-ad-report.mjs +2 -2
  8. package/actions/create-campaign-report/create-campaign-report.mjs +2 -2
  9. package/actions/create-customer-list/common-constants.mjs +10 -10
  10. package/actions/create-customer-list/create-customer-list.mjs +3 -3
  11. package/actions/create-customer-report/create-customer-report.mjs +2 -2
  12. package/actions/create-or-remove-campaign-criteria/create-or-remove-campaign-criteria.mjs +214 -0
  13. package/actions/create-or-remove-campaign-shared-set/create-or-remove-campaign-shared-set.mjs +155 -0
  14. package/actions/create-or-remove-shared-criteria/create-or-remove-shared-criteria.mjs +180 -0
  15. package/actions/create-or-update-ad-group/create-or-update-ad-group.mjs +315 -0
  16. package/actions/create-or-update-ad-group-ad/create-or-update-ad-group-ad.mjs +203 -0
  17. package/actions/create-or-update-bidding-strategy/create-or-update-bidding-strategy.mjs +185 -0
  18. package/actions/create-or-update-campaign/create-or-update-campaign.mjs +300 -0
  19. package/actions/create-or-update-campaign-budget/create-or-update-campaign-budget.mjs +212 -0
  20. package/actions/create-or-update-keywords/create-or-update-keywords.mjs +275 -0
  21. package/actions/create-or-update-shared-sets/create-or-update-shared-sets.mjs +180 -0
  22. package/actions/create-report/create-report.mjs +5 -7
  23. package/actions/create-responsive-search-ad/create-responsive-search-ad.mjs +202 -0
  24. package/actions/generate-keyword-ideas/generate-keyword-ideas.mjs +3 -3
  25. package/actions/get-keyword-quality-scores/get-keyword-quality-scores.mjs +107 -0
  26. package/actions/list-account-id-options/list-account-id-options.mjs +1 -1
  27. package/actions/list-ad-group-ads/list-ad-group-ads.mjs +55 -0
  28. package/actions/list-ad-group-criteria/list-ad-group-criteria.mjs +55 -0
  29. package/actions/list-ad-groups/list-ad-groups.mjs +55 -0
  30. package/actions/list-bidding-strategies/list-bidding-strategies.mjs +55 -0
  31. package/actions/list-campaign-budgets/list-campaign-budgets.mjs +55 -0
  32. package/actions/list-campaign-criteria/list-campaign-criteria.mjs +55 -0
  33. package/actions/list-campaign-shared-sets/list-campaign-shared-sets.mjs +55 -0
  34. package/actions/list-campaigns/list-campaigns.mjs +55 -0
  35. package/actions/list-customer-clients/list-customer-clients.mjs +2 -2
  36. package/actions/list-keywords/list-keywords.mjs +55 -0
  37. package/actions/list-shared-criteria/list-shared-criteria.mjs +55 -0
  38. package/actions/list-shared-sets/list-shared-sets.mjs +55 -0
  39. package/actions/send-offline-conversion/send-offline-conversion.mjs +4 -4
  40. package/actions/update-campaign-ai-max-settings/update-campaign-ai-max-settings.mjs +167 -0
  41. package/actions/upload-call-conversion/upload-call-conversion.mjs +65 -0
  42. package/actions/upload-click-conversion/upload-click-conversion.mjs +121 -0
  43. package/common/common-report.mjs +5 -7
  44. package/common/constants.mjs +369 -0
  45. package/common/queries.mjs +4 -2
  46. package/common/resources/ad.mjs +25 -70
  47. package/common/resources/adGroup.mjs +2 -3
  48. package/common/resources/campaign.mjs +7 -10
  49. package/common/resources/customer.mjs +3 -4
  50. package/common/utils.mjs +4 -0
  51. package/google_ads.app.mjs +657 -19
  52. package/package.json +1 -1
  53. package/sources/new-campaign-created/new-campaign-created.mjs +3 -3
  54. package/sources/new-lead-form-entry/new-lead-form-entry.mjs +3 -3
@@ -0,0 +1,300 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import googleAds from "../../google_ads.app.mjs";
3
+ import {
4
+ ADVERTISING_CHANNEL_TYPES,
5
+ CAMPAIGN_BIDDING_STRATEGY_TYPES,
6
+ CAMPAIGN_OPERATION_TYPES,
7
+ CAMPAIGN_STATUSES,
8
+ EU_POLITICAL_ADVERTISING_STATUSES,
9
+ } from "../../common/constants.mjs";
10
+ import { parseObject } from "../../common/utils.mjs";
11
+ import { getAdditionalFields } from "../common/props.mjs";
12
+ import {
13
+ buildBiddingScheme, CAMPAIGN_BIDDING_SCHEMES, getSchemeProps,
14
+ } from "../common/bidding.mjs";
15
+
16
+ const docLink =
17
+ "https://developers.google.com/google-ads/api/reference/rpc/v25/CampaignService/MutateCampaigns?transport=rest";
18
+
19
+ export default {
20
+ key: "google_ads-create-or-update-campaign",
21
+ name: "Create or Update Campaign",
22
+ description: `Creates or updates a campaign. [See the documentation](${docLink})`,
23
+ version: "1.0.0",
24
+ type: "action",
25
+ annotations: {
26
+ destructiveHint: true,
27
+ openWorldHint: true,
28
+ readOnlyHint: false,
29
+ },
30
+ props: {
31
+ googleAds,
32
+ accountId: {
33
+ propDefinition: [
34
+ googleAds,
35
+ "accountId",
36
+ ],
37
+ },
38
+ customerClientId: {
39
+ propDefinition: [
40
+ googleAds,
41
+ "customerClientId",
42
+ ({ accountId }) => ({
43
+ accountId,
44
+ }),
45
+ ],
46
+ optional: true,
47
+ },
48
+ operationType: {
49
+ type: "string",
50
+ label: "Operation Type",
51
+ description: "Whether to create, update, or remove a campaign.",
52
+ options: CAMPAIGN_OPERATION_TYPES,
53
+ },
54
+ campaignId: {
55
+ propDefinition: [
56
+ googleAds,
57
+ "campaignId",
58
+ ({
59
+ accountId, customerClientId,
60
+ }) => ({
61
+ accountId,
62
+ customerClientId,
63
+ }),
64
+ ],
65
+ description: "The campaign to update or remove. Required for **Update** and **Remove** operations.",
66
+ optional: true,
67
+ },
68
+ updateMask: {
69
+ type: "string",
70
+ label: "Update Mask",
71
+ description:
72
+ "Comma-separated list of fields to update (e.g., `name,status`). Only used for **update** operations.",
73
+ optional: true,
74
+ },
75
+ name: {
76
+ type: "string",
77
+ label: "Name",
78
+ description:
79
+ "The name of the campaign. Required for **create** operations.",
80
+ optional: true,
81
+ },
82
+ advertisingChannelType: {
83
+ type: "string",
84
+ label: "Advertising Channel Type",
85
+ description:
86
+ "The primary serving target for ads within the campaign. Required for **create** operations.",
87
+ options: ADVERTISING_CHANNEL_TYPES,
88
+ optional: true,
89
+ },
90
+ campaignBudget: {
91
+ type: "string",
92
+ label: "Campaign Budget",
93
+ description:
94
+ "The resource name of the campaign budget (e.g., `customers/{customer_id}/campaignBudgets/{budget_id}`). Required for **create** operations.",
95
+ optional: true,
96
+ },
97
+ status: {
98
+ type: "string",
99
+ label: "Status",
100
+ description: "The status of the campaign.",
101
+ options: CAMPAIGN_STATUSES,
102
+ optional: true,
103
+ },
104
+ startDateTime: {
105
+ type: "string",
106
+ label: "Start Date Time",
107
+ description:
108
+ "When the campaign starts serving ads, in the account's time zone, formatted as `YYYY-MM-DD HH:MM:SS` (use `00:00:00` for daily granularity).",
109
+ optional: true,
110
+ },
111
+ endDateTime: {
112
+ type: "string",
113
+ label: "End Date Time",
114
+ description:
115
+ "The last day and time the campaign serves ads, in the account's time zone, formatted as `YYYY-MM-DD HH:MM:SS` (use `23:59:59` for daily granularity). Leave blank to run indefinitely.",
116
+ optional: true,
117
+ },
118
+ trackingUrlTemplate: {
119
+ type: "string",
120
+ label: "Tracking URL Template",
121
+ description: "The URL template for constructing a tracking URL.",
122
+ optional: true,
123
+ },
124
+ containsEuPoliticalAdvertising: {
125
+ type: "string",
126
+ label: "Contains EU Political Advertising",
127
+ description: "Declares whether the campaign contains EU political advertising. Google requires this on **create**.",
128
+ options: EU_POLITICAL_ADVERTISING_STATUSES,
129
+ optional: true,
130
+ },
131
+ biddingStrategy: {
132
+ propDefinition: [
133
+ googleAds,
134
+ "biddingStrategyId",
135
+ ({
136
+ accountId, customerClientId,
137
+ }) => ({
138
+ accountId,
139
+ customerClientId,
140
+ }),
141
+ ],
142
+ label: "Portfolio Bidding Strategy",
143
+ description: "An existing portfolio bidding strategy to attach. Leave blank to use a standard (campaign-level) strategy instead.",
144
+ optional: true,
145
+ },
146
+ biddingStrategyType: {
147
+ type: "string",
148
+ label: "Standard Bidding Strategy",
149
+ description: "The campaign-level bidding strategy. Google requires either this or a **Portfolio Bidding Strategy** on **create**.",
150
+ options: CAMPAIGN_BIDDING_STRATEGY_TYPES,
151
+ optional: true,
152
+ },
153
+ ...getSchemeProps(CAMPAIGN_BIDDING_SCHEMES),
154
+ additionalFields: getAdditionalFields(docLink),
155
+ },
156
+ async run({ $ }) {
157
+ const {
158
+ googleAds,
159
+ accountId,
160
+ customerClientId,
161
+ operationType,
162
+ campaignId,
163
+ updateMask,
164
+ name,
165
+ advertisingChannelType,
166
+ campaignBudget,
167
+ status,
168
+ startDateTime,
169
+ endDateTime,
170
+ trackingUrlTemplate,
171
+ containsEuPoliticalAdvertising,
172
+ biddingStrategy,
173
+ biddingStrategyType,
174
+ additionalFields,
175
+ } = this;
176
+
177
+ if ((operationType === "update" || operationType === "remove") && !campaignId) {
178
+ throw new ConfigurationError(
179
+ "**Campaign** is required for Update and Remove operations.",
180
+ );
181
+ }
182
+
183
+ if (operationType === "update" && !updateMask) {
184
+ throw new ConfigurationError(
185
+ "**Update Mask** is required for Update operations.",
186
+ );
187
+ }
188
+
189
+ // `campaign_bidding_strategy` is a union field.
190
+ if (biddingStrategy && biddingStrategyType) {
191
+ throw new ConfigurationError(
192
+ "Set either **Portfolio Bidding Strategy** or **Standard Bidding Strategy**, not both.",
193
+ );
194
+ }
195
+
196
+ if (operationType === "create") {
197
+ if (!containsEuPoliticalAdvertising) {
198
+ throw new ConfigurationError(
199
+ "**Contains EU Political Advertising** is required for Create operations.",
200
+ );
201
+ }
202
+ if (!name) {
203
+ throw new ConfigurationError(
204
+ "**Name** is required for Create operations.",
205
+ );
206
+ }
207
+ if (!advertisingChannelType) {
208
+ throw new ConfigurationError(
209
+ "**Advertising Channel Type** is required for Create operations.",
210
+ );
211
+ }
212
+ if (!campaignBudget) {
213
+ throw new ConfigurationError(
214
+ "**Campaign Budget** is required for Create operations.",
215
+ );
216
+ }
217
+ }
218
+
219
+ const customerId = customerClientId ?? accountId;
220
+ const resourceName = campaignId
221
+ ? `customers/${customerId}/campaigns/${campaignId}`
222
+ : undefined;
223
+
224
+ let operation;
225
+
226
+ if (operationType === "remove") {
227
+ operation = {
228
+ remove: resourceName,
229
+ };
230
+ } else {
231
+ const campaignData = {
232
+ ...(resourceName && {
233
+ resourceName,
234
+ }),
235
+ ...(name && {
236
+ name,
237
+ }),
238
+ ...(advertisingChannelType && {
239
+ advertisingChannelType,
240
+ }),
241
+ ...(campaignBudget && {
242
+ campaignBudget,
243
+ }),
244
+ ...(status && {
245
+ status,
246
+ }),
247
+ ...(startDateTime && {
248
+ startDateTime,
249
+ }),
250
+ ...(endDateTime && {
251
+ endDateTime,
252
+ }),
253
+ ...(trackingUrlTemplate && {
254
+ trackingUrlTemplate,
255
+ }),
256
+ ...(containsEuPoliticalAdvertising && {
257
+ containsEuPoliticalAdvertising,
258
+ }),
259
+ ...(biddingStrategy && {
260
+ biddingStrategy: `customers/${customerId}/biddingStrategies/${biddingStrategy}`,
261
+ }),
262
+ ...buildBiddingScheme(CAMPAIGN_BIDDING_SCHEMES, biddingStrategyType, this),
263
+ ...parseObject(additionalFields),
264
+ };
265
+
266
+ if (operationType === "update") {
267
+ operation = {
268
+ update: campaignData,
269
+ updateMask,
270
+ };
271
+ } else {
272
+ operation = {
273
+ create: campaignData,
274
+ };
275
+ }
276
+ }
277
+
278
+ const response = await googleAds.mutateCampaign({
279
+ $,
280
+ accountId,
281
+ customerClientId,
282
+ data: {
283
+ operations: [
284
+ operation,
285
+ ],
286
+ },
287
+ });
288
+
289
+ const result = response?.results?.[0];
290
+ const id = result?.resourceName?.split("/").pop();
291
+
292
+ $.export(
293
+ "$summary",
294
+ `Successfully ${operationType}d campaign${id
295
+ ? ` with ID \`${id}\``
296
+ : ""}.`,
297
+ );
298
+ return response;
299
+ },
300
+ };
@@ -0,0 +1,212 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
2
+ import googleAds from "../../google_ads.app.mjs";
3
+ import {
4
+ BUDGET_DELIVERY_METHODS,
5
+ BUDGET_PERIODS,
6
+ CAMPAIGN_OPERATION_TYPES,
7
+ } from "../../common/constants.mjs";
8
+ import { parseObject } from "../../common/utils.mjs";
9
+ import { getAdditionalFields } from "../common/props.mjs";
10
+
11
+ const docLink =
12
+ "https://developers.google.com/google-ads/api/reference/rpc/v25/CampaignBudgetService/MutateCampaignBudgets?transport=rest";
13
+
14
+ export default {
15
+ key: "google_ads-create-or-update-campaign-budget",
16
+ name: "Create or Update Campaign Budget",
17
+ description: `Creates, updates, or removes a campaign budget. [See the documentation](${docLink})`,
18
+ version: "0.0.2",
19
+ type: "action",
20
+ annotations: {
21
+ destructiveHint: true,
22
+ openWorldHint: true,
23
+ readOnlyHint: false,
24
+ },
25
+ props: {
26
+ googleAds,
27
+ accountId: {
28
+ propDefinition: [
29
+ googleAds,
30
+ "accountId",
31
+ ],
32
+ },
33
+ customerClientId: {
34
+ propDefinition: [
35
+ googleAds,
36
+ "customerClientId",
37
+ ({ accountId }) => ({
38
+ accountId,
39
+ }),
40
+ ],
41
+ optional: true,
42
+ },
43
+ operationType: {
44
+ type: "string",
45
+ label: "Operation Type",
46
+ description: "Whether to create, update, or remove a campaign budget.",
47
+ options: CAMPAIGN_OPERATION_TYPES,
48
+ },
49
+ campaignBudgetId: {
50
+ propDefinition: [
51
+ googleAds,
52
+ "campaignBudgetId",
53
+ ({
54
+ accountId, customerClientId,
55
+ }) => ({
56
+ accountId,
57
+ customerClientId,
58
+ }),
59
+ ],
60
+ description: "The budget to update or remove. Required for **Update** and **Remove** operations.",
61
+ optional: true,
62
+ },
63
+ updateMask: {
64
+ type: "string",
65
+ label: "Update Mask",
66
+ description: "Comma-separated list of fields to update (e.g., `name,amountMicros`). Required for **Update** operations.",
67
+ optional: true,
68
+ },
69
+ name: {
70
+ type: "string",
71
+ label: "Name",
72
+ description: "The name of the budget. Required for **Create** operations.",
73
+ optional: true,
74
+ },
75
+ amountMicros: {
76
+ type: "string",
77
+ label: "Amount (Micros)",
78
+ description: "The amount of the budget in micros (e.g., `1000000` = $1.00). Required for **Create** operations.",
79
+ optional: true,
80
+ },
81
+ deliveryMethod: {
82
+ type: "string",
83
+ label: "Delivery Method",
84
+ description: "How quickly the budget is spent throughout the day.",
85
+ options: BUDGET_DELIVERY_METHODS,
86
+ optional: true,
87
+ },
88
+ explicitlyShared: {
89
+ type: "boolean",
90
+ label: "Explicitly Shared",
91
+ description: "Whether this budget is explicitly shared across multiple campaigns. Immutable after creation.",
92
+ optional: true,
93
+ },
94
+ period: {
95
+ type: "string",
96
+ label: "Period",
97
+ description: "The period over which to spend the budget. Immutable after creation.",
98
+ options: BUDGET_PERIODS,
99
+ optional: true,
100
+ },
101
+ additionalFields: getAdditionalFields(docLink),
102
+ },
103
+ async run({ $ }) {
104
+ const {
105
+ googleAds,
106
+ accountId,
107
+ customerClientId,
108
+ operationType,
109
+ campaignBudgetId,
110
+ updateMask,
111
+ name,
112
+ amountMicros,
113
+ deliveryMethod,
114
+ explicitlyShared,
115
+ period,
116
+ additionalFields,
117
+ } = this;
118
+
119
+ if ((operationType === "update" || operationType === "remove") && !campaignBudgetId) {
120
+ throw new ConfigurationError(
121
+ "**Campaign Budget** is required for Update and Remove operations.",
122
+ );
123
+ }
124
+
125
+ if (operationType === "update" && !updateMask) {
126
+ throw new ConfigurationError(
127
+ "**Update Mask** is required for Update operations.",
128
+ );
129
+ }
130
+
131
+ if (operationType === "create") {
132
+ if (!name) {
133
+ throw new ConfigurationError(
134
+ "**Name** is required for Create operations.",
135
+ );
136
+ }
137
+ if (!amountMicros) {
138
+ throw new ConfigurationError(
139
+ "**Amount (Micros)** is required for Create operations.",
140
+ );
141
+ }
142
+ }
143
+
144
+ const customerId = customerClientId ?? accountId;
145
+ const resourceName = campaignBudgetId
146
+ ? `customers/${customerId}/campaignBudgets/${campaignBudgetId}`
147
+ : undefined;
148
+
149
+ let operation;
150
+
151
+ if (operationType === "remove") {
152
+ operation = {
153
+ remove: resourceName,
154
+ };
155
+ } else {
156
+ const budgetData = {
157
+ ...(resourceName && {
158
+ resourceName,
159
+ }),
160
+ ...(name && {
161
+ name,
162
+ }),
163
+ ...(amountMicros && {
164
+ amountMicros,
165
+ }),
166
+ ...(deliveryMethod && {
167
+ deliveryMethod,
168
+ }),
169
+ ...(explicitlyShared !== undefined && {
170
+ explicitlyShared,
171
+ }),
172
+ ...(period && {
173
+ period,
174
+ }),
175
+ ...parseObject(additionalFields),
176
+ };
177
+
178
+ if (operationType === "update") {
179
+ operation = {
180
+ update: budgetData,
181
+ updateMask,
182
+ };
183
+ } else {
184
+ operation = {
185
+ create: budgetData,
186
+ };
187
+ }
188
+ }
189
+
190
+ const response = await googleAds.mutateCampaignBudgets({
191
+ $,
192
+ accountId,
193
+ customerClientId,
194
+ data: {
195
+ operations: [
196
+ operation,
197
+ ],
198
+ },
199
+ });
200
+
201
+ const result = response?.results?.[0];
202
+ const id = result?.resourceName?.split("/").pop();
203
+
204
+ $.export(
205
+ "$summary",
206
+ `Successfully ${operationType}d campaign budget${id
207
+ ? ` with ID \`${id}\``
208
+ : ""}.`,
209
+ );
210
+ return response;
211
+ },
212
+ };