@pipedream/google_ads 0.7.0 → 0.8.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.
- package/actions/add-contact-to-list-by-email/add-contact-to-list-by-email.mjs +1 -1
- package/actions/create-ad-group-report/create-ad-group-report.mjs +1 -1
- package/actions/create-ad-report/create-ad-report.mjs +1 -1
- package/actions/create-campaign-report/create-campaign-report.mjs +1 -1
- package/actions/create-customer-list/create-customer-list.mjs +1 -1
- package/actions/create-customer-report/create-customer-report.mjs +1 -1
- package/actions/create-or-remove-campaign-criteria/create-or-remove-campaign-criteria.mjs +214 -0
- package/actions/create-or-remove-campaign-shared-set/create-or-remove-campaign-shared-set.mjs +155 -0
- package/actions/create-or-remove-shared-criteria/create-or-remove-shared-criteria.mjs +180 -0
- package/actions/create-or-update-ad-group/create-or-update-ad-group.mjs +315 -0
- package/actions/create-or-update-ad-group-ad/create-or-update-ad-group-ad.mjs +203 -0
- package/actions/create-or-update-bidding-strategy/create-or-update-bidding-strategy.mjs +180 -0
- package/actions/create-or-update-campaign/create-or-update-campaign.mjs +243 -0
- package/actions/create-or-update-campaign-budget/create-or-update-campaign-budget.mjs +212 -0
- package/actions/create-or-update-keywords/create-or-update-keywords.mjs +275 -0
- package/actions/create-or-update-shared-sets/create-or-update-shared-sets.mjs +180 -0
- package/actions/create-report/create-report.mjs +1 -1
- package/actions/create-responsive-search-ad/create-responsive-search-ad.mjs +202 -0
- package/actions/generate-keyword-ideas/generate-keyword-ideas.mjs +1 -1
- package/actions/get-keyword-quality-scores/get-keyword-quality-scores.mjs +107 -0
- package/actions/list-account-id-options/list-account-id-options.mjs +1 -1
- package/actions/list-ad-group-ads/list-ad-group-ads.mjs +55 -0
- package/actions/list-ad-group-criteria/list-ad-group-criteria.mjs +55 -0
- package/actions/list-ad-groups/list-ad-groups.mjs +55 -0
- package/actions/list-bidding-strategies/list-bidding-strategies.mjs +55 -0
- package/actions/list-campaign-budgets/list-campaign-budgets.mjs +55 -0
- package/actions/list-campaign-criteria/list-campaign-criteria.mjs +55 -0
- package/actions/list-campaign-shared-sets/list-campaign-shared-sets.mjs +55 -0
- package/actions/list-campaigns/list-campaigns.mjs +55 -0
- package/actions/list-customer-clients/list-customer-clients.mjs +1 -1
- package/actions/list-keywords/list-keywords.mjs +55 -0
- package/actions/list-shared-criteria/list-shared-criteria.mjs +55 -0
- package/actions/list-shared-sets/list-shared-sets.mjs +55 -0
- package/actions/send-offline-conversion/send-offline-conversion.mjs +1 -1
- package/actions/update-campaign-ai-max-settings/update-campaign-ai-max-settings.mjs +167 -0
- package/common/constants.mjs +269 -0
- package/common/queries.mjs +4 -2
- package/common/utils.mjs +4 -0
- package/google_ads.app.mjs +589 -1
- package/package.json +1 -1
- package/sources/new-campaign-created/new-campaign-created.mjs +1 -1
- package/sources/new-lead-form-entry/new-lead-form-entry.mjs +1 -1
|
@@ -7,7 +7,7 @@ export default {
|
|
|
7
7
|
key: "google_ads-add-contact-to-list-by-email",
|
|
8
8
|
name: "Add Contact to Customer List by Email",
|
|
9
9
|
description: "Adds a contact to a specific customer list in Google Ads. Lists typically update in 6 to 12 hours after operation. [See the documentation](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/customer-match/get-started)",
|
|
10
|
-
version: "0.1.
|
|
10
|
+
version: "0.1.9",
|
|
11
11
|
annotations: {
|
|
12
12
|
destructiveHint: true,
|
|
13
13
|
openWorldHint: true,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_ads-create-ad-group-report",
|
|
7
7
|
name: "Create Ad Group Report",
|
|
8
8
|
description: "Creates a report for the Ad Group resource. [See the documentation](https://developers.google.com/google-ads/api/reference/rpc/v21/GoogleAdsService/Search?transport=rest)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
|
12
12
|
openWorldHint: true,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_ads-create-ad-report",
|
|
7
7
|
name: "Create Ad Report",
|
|
8
8
|
description: "Creates a report for the Ad resource. [See the documentation](https://developers.google.com/google-ads/api/reference/rpc/v21/GoogleAdsService/Search?transport=rest)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
|
12
12
|
openWorldHint: true,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_ads-create-campaign-report",
|
|
7
7
|
name: "Create Campaign Report",
|
|
8
8
|
description: "Creates a report for the Campaign resource. [See the documentation](https://developers.google.com/google-ads/api/reference/rpc/v21/GoogleAdsService/Search?transport=rest)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
|
12
12
|
openWorldHint: true,
|
|
@@ -15,7 +15,7 @@ export default {
|
|
|
15
15
|
key: "google_ads-create-customer-list",
|
|
16
16
|
name: "Create Customer List",
|
|
17
17
|
description: "Create a new customer list in Google Ads. [See the documentation](https://developers.google.com/google-ads/api/reference/rpc/v21/UserList)",
|
|
18
|
-
version: "0.0.
|
|
18
|
+
version: "0.0.10",
|
|
19
19
|
annotations: {
|
|
20
20
|
destructiveHint: false,
|
|
21
21
|
openWorldHint: true,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "google_ads-create-customer-report",
|
|
7
7
|
name: "Create Customer Report",
|
|
8
8
|
description: "Creates a report for the Customer resource. [See the documentation](https://developers.google.com/google-ads/api/reference/rpc/v21/GoogleAdsService/Search?transport=rest)",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.3",
|
|
10
10
|
annotations: {
|
|
11
11
|
destructiveHint: false,
|
|
12
12
|
openWorldHint: true,
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleAds from "../../google_ads.app.mjs";
|
|
3
|
+
import {
|
|
4
|
+
CAMPAIGN_STATUSES,
|
|
5
|
+
CREATE_REMOVE_OPERATION_TYPES,
|
|
6
|
+
KEYWORD_MATCH_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/v21/CampaignCriterionService/MutateCampaignCriteria?transport=rest";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
key: "google_ads-create-or-remove-campaign-criteria",
|
|
16
|
+
name: "Create or Remove Campaign Criteria",
|
|
17
|
+
description: `Creates or removes criteria for a campaign (e.g., keyword targeting, brand lists). [See the documentation](${docLink})`,
|
|
18
|
+
version: "0.0.1",
|
|
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 or remove a campaign criterion.",
|
|
47
|
+
options: CREATE_REMOVE_OPERATION_TYPES,
|
|
48
|
+
},
|
|
49
|
+
campaignCriterionId: {
|
|
50
|
+
propDefinition: [
|
|
51
|
+
googleAds,
|
|
52
|
+
"campaignCriterionId",
|
|
53
|
+
({
|
|
54
|
+
accountId, customerClientId,
|
|
55
|
+
}) => ({
|
|
56
|
+
accountId,
|
|
57
|
+
customerClientId,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
description: "The campaign criterion to remove. Required for **Remove** operations.",
|
|
61
|
+
optional: true,
|
|
62
|
+
},
|
|
63
|
+
campaignId: {
|
|
64
|
+
propDefinition: [
|
|
65
|
+
googleAds,
|
|
66
|
+
"campaignId",
|
|
67
|
+
({
|
|
68
|
+
accountId, customerClientId,
|
|
69
|
+
}) => ({
|
|
70
|
+
accountId,
|
|
71
|
+
customerClientId,
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
description: "The campaign to add this criterion to. Required for **Create** operations.",
|
|
75
|
+
optional: true,
|
|
76
|
+
},
|
|
77
|
+
negative: {
|
|
78
|
+
type: "boolean",
|
|
79
|
+
label: "Negative",
|
|
80
|
+
description: "Whether this is a negative criterion (e.g., a keyword to exclude). Immutable after creation.",
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
status: {
|
|
84
|
+
type: "string",
|
|
85
|
+
label: "Status",
|
|
86
|
+
description: "The status of the criterion.",
|
|
87
|
+
options: CAMPAIGN_STATUSES,
|
|
88
|
+
optional: true,
|
|
89
|
+
},
|
|
90
|
+
keywordText: {
|
|
91
|
+
type: "string",
|
|
92
|
+
label: "Keyword Text",
|
|
93
|
+
description: "The keyword text for keyword criteria (max 80 characters, max 10 words).",
|
|
94
|
+
optional: true,
|
|
95
|
+
},
|
|
96
|
+
keywordMatchType: {
|
|
97
|
+
type: "string",
|
|
98
|
+
label: "Keyword Match Type",
|
|
99
|
+
description: "The match type for the keyword. Required when **Keyword Text** is provided.",
|
|
100
|
+
options: KEYWORD_MATCH_TYPES,
|
|
101
|
+
optional: true,
|
|
102
|
+
},
|
|
103
|
+
brandListSharedSet: {
|
|
104
|
+
type: "string",
|
|
105
|
+
label: "Brand List Shared Set",
|
|
106
|
+
description: "The resource name of the shared set for brand list criteria (e.g., `customers/123/sharedSets/456`).",
|
|
107
|
+
optional: true,
|
|
108
|
+
},
|
|
109
|
+
additionalFields: getAdditionalFields(docLink),
|
|
110
|
+
},
|
|
111
|
+
async run({ $ }) {
|
|
112
|
+
const {
|
|
113
|
+
googleAds,
|
|
114
|
+
accountId,
|
|
115
|
+
customerClientId,
|
|
116
|
+
operationType,
|
|
117
|
+
campaignCriterionId,
|
|
118
|
+
campaignId,
|
|
119
|
+
negative,
|
|
120
|
+
status,
|
|
121
|
+
keywordText,
|
|
122
|
+
keywordMatchType,
|
|
123
|
+
brandListSharedSet,
|
|
124
|
+
additionalFields,
|
|
125
|
+
} = this;
|
|
126
|
+
|
|
127
|
+
if (operationType === "remove" && !campaignCriterionId) {
|
|
128
|
+
throw new ConfigurationError(
|
|
129
|
+
"**Campaign Criterion** is required for Remove operations.",
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (operationType === "create") {
|
|
134
|
+
if (!campaignId) {
|
|
135
|
+
throw new ConfigurationError(
|
|
136
|
+
"**Campaign** is required for Create operations.",
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (keywordText && !keywordMatchType) {
|
|
140
|
+
throw new ConfigurationError(
|
|
141
|
+
"**Keyword Match Type** is required when **Keyword Text** is provided.",
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (keywordMatchType && !keywordText) {
|
|
145
|
+
throw new ConfigurationError(
|
|
146
|
+
"**Keyword Text** is required when **Keyword Match Type** is provided.",
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const customerId = customerClientId ?? accountId;
|
|
152
|
+
const campaign = campaignId
|
|
153
|
+
? `customers/${customerId}/campaigns/${campaignId}`
|
|
154
|
+
: undefined;
|
|
155
|
+
|
|
156
|
+
let operation;
|
|
157
|
+
|
|
158
|
+
if (operationType === "remove") {
|
|
159
|
+
operation = {
|
|
160
|
+
remove: campaignCriterionId,
|
|
161
|
+
};
|
|
162
|
+
} else {
|
|
163
|
+
const criterionData = {
|
|
164
|
+
...(campaign && {
|
|
165
|
+
campaign,
|
|
166
|
+
}),
|
|
167
|
+
...(negative !== undefined && {
|
|
168
|
+
negative,
|
|
169
|
+
}),
|
|
170
|
+
...(status && {
|
|
171
|
+
status,
|
|
172
|
+
}),
|
|
173
|
+
...(keywordText && keywordMatchType && {
|
|
174
|
+
keyword: {
|
|
175
|
+
text: keywordText,
|
|
176
|
+
matchType: keywordMatchType,
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
...(brandListSharedSet && {
|
|
180
|
+
brandList: {
|
|
181
|
+
sharedSet: brandListSharedSet,
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
...parseObject(additionalFields),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
operation = {
|
|
188
|
+
create: criterionData,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const response = await googleAds.mutateCampaignCriteria({
|
|
193
|
+
$,
|
|
194
|
+
accountId,
|
|
195
|
+
customerClientId,
|
|
196
|
+
data: {
|
|
197
|
+
operations: [
|
|
198
|
+
operation,
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
const result = response?.results?.[0];
|
|
204
|
+
const id = result?.resourceName?.split("~").pop();
|
|
205
|
+
|
|
206
|
+
$.export(
|
|
207
|
+
"$summary",
|
|
208
|
+
`Successfully ${operationType}d campaign criterion${id
|
|
209
|
+
? ` with criterion ID \`${id}\``
|
|
210
|
+
: ""}.`,
|
|
211
|
+
);
|
|
212
|
+
return response;
|
|
213
|
+
},
|
|
214
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleAds from "../../google_ads.app.mjs";
|
|
3
|
+
import { CREATE_REMOVE_OPERATION_TYPES } from "../../common/constants.mjs";
|
|
4
|
+
|
|
5
|
+
const docLink =
|
|
6
|
+
"https://developers.google.com/google-ads/api/reference/rpc/v21/CampaignSharedSetService/MutateCampaignSharedSets?transport=rest";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
key: "google_ads-create-or-remove-campaign-shared-set",
|
|
10
|
+
name: "Create or Remove Campaign Shared Set",
|
|
11
|
+
description: `Attaches or detaches a shared set from a campaign. [See the documentation](${docLink})`,
|
|
12
|
+
version: "0.0.1",
|
|
13
|
+
type: "action",
|
|
14
|
+
annotations: {
|
|
15
|
+
destructiveHint: true,
|
|
16
|
+
openWorldHint: true,
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
},
|
|
19
|
+
props: {
|
|
20
|
+
googleAds,
|
|
21
|
+
accountId: {
|
|
22
|
+
propDefinition: [
|
|
23
|
+
googleAds,
|
|
24
|
+
"accountId",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
customerClientId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
googleAds,
|
|
30
|
+
"customerClientId",
|
|
31
|
+
({ accountId }) => ({
|
|
32
|
+
accountId,
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
operationType: {
|
|
38
|
+
type: "string",
|
|
39
|
+
label: "Operation Type",
|
|
40
|
+
description: "Whether to attach or detach a shared set from a campaign.",
|
|
41
|
+
options: CREATE_REMOVE_OPERATION_TYPES,
|
|
42
|
+
},
|
|
43
|
+
campaignSharedSetId: {
|
|
44
|
+
propDefinition: [
|
|
45
|
+
googleAds,
|
|
46
|
+
"campaignSharedSetId",
|
|
47
|
+
({
|
|
48
|
+
accountId, customerClientId,
|
|
49
|
+
}) => ({
|
|
50
|
+
accountId,
|
|
51
|
+
customerClientId,
|
|
52
|
+
}),
|
|
53
|
+
],
|
|
54
|
+
description: "The campaign shared set to remove. Required for **Remove** operations.",
|
|
55
|
+
optional: true,
|
|
56
|
+
},
|
|
57
|
+
campaignId: {
|
|
58
|
+
propDefinition: [
|
|
59
|
+
googleAds,
|
|
60
|
+
"campaignId",
|
|
61
|
+
({
|
|
62
|
+
accountId, customerClientId,
|
|
63
|
+
}) => ({
|
|
64
|
+
accountId,
|
|
65
|
+
customerClientId,
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
description: "The campaign to attach the shared set to. Required for **Create** operations.",
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
sharedSetId: {
|
|
72
|
+
propDefinition: [
|
|
73
|
+
googleAds,
|
|
74
|
+
"sharedSetId",
|
|
75
|
+
({
|
|
76
|
+
accountId, customerClientId,
|
|
77
|
+
}) => ({
|
|
78
|
+
accountId,
|
|
79
|
+
customerClientId,
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
82
|
+
description: "The shared set to attach to the campaign. Required for **Create** operations.",
|
|
83
|
+
optional: true,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
async run({ $ }) {
|
|
87
|
+
const {
|
|
88
|
+
googleAds,
|
|
89
|
+
accountId,
|
|
90
|
+
customerClientId,
|
|
91
|
+
operationType,
|
|
92
|
+
campaignSharedSetId,
|
|
93
|
+
campaignId,
|
|
94
|
+
sharedSetId,
|
|
95
|
+
} = this;
|
|
96
|
+
|
|
97
|
+
if (operationType === "remove" && !campaignSharedSetId) {
|
|
98
|
+
throw new ConfigurationError(
|
|
99
|
+
"**Campaign Shared Set** is required for Remove operations.",
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (operationType === "create") {
|
|
104
|
+
if (!campaignId) {
|
|
105
|
+
throw new ConfigurationError(
|
|
106
|
+
"**Campaign** is required for Create operations.",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (!sharedSetId) {
|
|
110
|
+
throw new ConfigurationError(
|
|
111
|
+
"**Shared Set** is required for Create operations.",
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const customerId = customerClientId ?? accountId;
|
|
117
|
+
|
|
118
|
+
let operation;
|
|
119
|
+
|
|
120
|
+
if (operationType === "remove") {
|
|
121
|
+
operation = {
|
|
122
|
+
remove: campaignSharedSetId,
|
|
123
|
+
};
|
|
124
|
+
} else {
|
|
125
|
+
operation = {
|
|
126
|
+
create: {
|
|
127
|
+
campaign: `customers/${customerId}/campaigns/${campaignId}`,
|
|
128
|
+
sharedSet: `customers/${customerId}/sharedSets/${sharedSetId}`,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const response = await googleAds.mutateCampaignSharedSets({
|
|
134
|
+
$,
|
|
135
|
+
accountId,
|
|
136
|
+
customerClientId,
|
|
137
|
+
data: {
|
|
138
|
+
operations: [
|
|
139
|
+
operation,
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const result = response?.results?.[0];
|
|
145
|
+
const resourceId = result?.resourceName?.split("/").pop();
|
|
146
|
+
|
|
147
|
+
$.export(
|
|
148
|
+
"$summary",
|
|
149
|
+
`Successfully ${operationType}d campaign shared set${resourceId
|
|
150
|
+
? ` \`${resourceId}\``
|
|
151
|
+
: ""}.`,
|
|
152
|
+
);
|
|
153
|
+
return response;
|
|
154
|
+
},
|
|
155
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleAds from "../../google_ads.app.mjs";
|
|
3
|
+
import {
|
|
4
|
+
CREATE_REMOVE_OPERATION_TYPES,
|
|
5
|
+
KEYWORD_MATCH_TYPES,
|
|
6
|
+
} from "../../common/constants.mjs";
|
|
7
|
+
import { parseObject } from "../../common/utils.mjs";
|
|
8
|
+
import { getAdditionalFields } from "../common/props.mjs";
|
|
9
|
+
|
|
10
|
+
const docLink =
|
|
11
|
+
"https://developers.google.com/google-ads/api/reference/rpc/v21/SharedCriterionService/MutateSharedCriteria?transport=rest";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
key: "google_ads-create-or-remove-shared-criteria",
|
|
15
|
+
name: "Create or Remove Shared Criteria",
|
|
16
|
+
description: `Creates or removes criteria from a shared set (e.g., negative keywords). [See the documentation](${docLink})`,
|
|
17
|
+
version: "0.0.1",
|
|
18
|
+
type: "action",
|
|
19
|
+
annotations: {
|
|
20
|
+
destructiveHint: true,
|
|
21
|
+
openWorldHint: true,
|
|
22
|
+
readOnlyHint: false,
|
|
23
|
+
},
|
|
24
|
+
props: {
|
|
25
|
+
googleAds,
|
|
26
|
+
accountId: {
|
|
27
|
+
propDefinition: [
|
|
28
|
+
googleAds,
|
|
29
|
+
"accountId",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
customerClientId: {
|
|
33
|
+
propDefinition: [
|
|
34
|
+
googleAds,
|
|
35
|
+
"customerClientId",
|
|
36
|
+
({ accountId }) => ({
|
|
37
|
+
accountId,
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
42
|
+
operationType: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Operation Type",
|
|
45
|
+
description: "Whether to create or remove a shared criterion.",
|
|
46
|
+
options: CREATE_REMOVE_OPERATION_TYPES,
|
|
47
|
+
},
|
|
48
|
+
sharedCriterionId: {
|
|
49
|
+
propDefinition: [
|
|
50
|
+
googleAds,
|
|
51
|
+
"sharedCriterionId",
|
|
52
|
+
({
|
|
53
|
+
accountId, customerClientId,
|
|
54
|
+
}) => ({
|
|
55
|
+
accountId,
|
|
56
|
+
customerClientId,
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
description: "The shared criterion to remove. Required for **Remove** operations.",
|
|
60
|
+
optional: true,
|
|
61
|
+
},
|
|
62
|
+
sharedSetId: {
|
|
63
|
+
propDefinition: [
|
|
64
|
+
googleAds,
|
|
65
|
+
"sharedSetId",
|
|
66
|
+
({
|
|
67
|
+
accountId, customerClientId,
|
|
68
|
+
}) => ({
|
|
69
|
+
accountId,
|
|
70
|
+
customerClientId,
|
|
71
|
+
}),
|
|
72
|
+
],
|
|
73
|
+
description: "The shared set to add this criterion to. Required for **Create** operations.",
|
|
74
|
+
optional: true,
|
|
75
|
+
},
|
|
76
|
+
keywordText: {
|
|
77
|
+
type: "string",
|
|
78
|
+
label: "Keyword Text",
|
|
79
|
+
description: "The keyword text to add to the shared set (max 80 characters, max 10 words). Required for keyword criteria.",
|
|
80
|
+
optional: true,
|
|
81
|
+
},
|
|
82
|
+
keywordMatchType: {
|
|
83
|
+
type: "string",
|
|
84
|
+
label: "Keyword Match Type",
|
|
85
|
+
description: "The match type for the keyword. Required for keyword criteria.",
|
|
86
|
+
options: KEYWORD_MATCH_TYPES,
|
|
87
|
+
optional: true,
|
|
88
|
+
},
|
|
89
|
+
additionalFields: getAdditionalFields(docLink),
|
|
90
|
+
},
|
|
91
|
+
async run({ $ }) {
|
|
92
|
+
const {
|
|
93
|
+
googleAds,
|
|
94
|
+
accountId,
|
|
95
|
+
customerClientId,
|
|
96
|
+
operationType,
|
|
97
|
+
sharedCriterionId,
|
|
98
|
+
sharedSetId,
|
|
99
|
+
keywordText,
|
|
100
|
+
keywordMatchType,
|
|
101
|
+
additionalFields,
|
|
102
|
+
} = this;
|
|
103
|
+
|
|
104
|
+
if (operationType === "remove" && !sharedCriterionId) {
|
|
105
|
+
throw new ConfigurationError(
|
|
106
|
+
"**Shared Criterion** is required for Remove operations.",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (operationType === "create") {
|
|
111
|
+
if (!sharedSetId) {
|
|
112
|
+
throw new ConfigurationError(
|
|
113
|
+
"**Shared Set** is required for Create operations.",
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (keywordText && !keywordMatchType) {
|
|
117
|
+
throw new ConfigurationError(
|
|
118
|
+
"**Keyword Match Type** is required when **Keyword Text** is provided.",
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (keywordMatchType && !keywordText) {
|
|
122
|
+
throw new ConfigurationError(
|
|
123
|
+
"**Keyword Text** is required when **Keyword Match Type** is provided.",
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const customerId = customerClientId ?? accountId;
|
|
129
|
+
const sharedSet = sharedSetId
|
|
130
|
+
? `customers/${customerId}/sharedSets/${sharedSetId}`
|
|
131
|
+
: undefined;
|
|
132
|
+
|
|
133
|
+
let operation;
|
|
134
|
+
|
|
135
|
+
if (operationType === "remove") {
|
|
136
|
+
operation = {
|
|
137
|
+
remove: sharedCriterionId,
|
|
138
|
+
};
|
|
139
|
+
} else {
|
|
140
|
+
const criterionData = {
|
|
141
|
+
...(sharedSet && {
|
|
142
|
+
sharedSet,
|
|
143
|
+
}),
|
|
144
|
+
...(keywordText && keywordMatchType && {
|
|
145
|
+
keyword: {
|
|
146
|
+
text: keywordText,
|
|
147
|
+
matchType: keywordMatchType,
|
|
148
|
+
},
|
|
149
|
+
}),
|
|
150
|
+
...parseObject(additionalFields),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
operation = {
|
|
154
|
+
create: criterionData,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const response = await googleAds.mutateSharedCriteria({
|
|
159
|
+
$,
|
|
160
|
+
accountId,
|
|
161
|
+
customerClientId,
|
|
162
|
+
data: {
|
|
163
|
+
operations: [
|
|
164
|
+
operation,
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const result = response?.results?.[0];
|
|
170
|
+
const id = result?.resourceName?.split("~").pop();
|
|
171
|
+
|
|
172
|
+
$.export(
|
|
173
|
+
"$summary",
|
|
174
|
+
`Successfully ${operationType}d shared criterion${id
|
|
175
|
+
? ` with criterion ID \`${id}\``
|
|
176
|
+
: ""}.`,
|
|
177
|
+
);
|
|
178
|
+
return response;
|
|
179
|
+
},
|
|
180
|
+
};
|