google-ads-api 14.1.0 → 14.2.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/README.md +45 -0
- package/build/src/protos/autogen/serviceFactory.d.ts +10 -2
- package/build/src/service.js +19 -3
- package/build/src/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -367,6 +367,51 @@ const result = await customer.mutateResources(operations);
|
|
|
367
367
|
|
|
368
368
|
---
|
|
369
369
|
|
|
370
|
+
## Add Policy Exemption Rules
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import {
|
|
374
|
+
resources,
|
|
375
|
+
enums,
|
|
376
|
+
toMicros,
|
|
377
|
+
ResourceNames,
|
|
378
|
+
MutateOperation,
|
|
379
|
+
} from "google-ads-api";
|
|
380
|
+
|
|
381
|
+
// Ad Group to which you want to add the keyword
|
|
382
|
+
const adGroupResourceName = 'customers/123/adGroups/456'
|
|
383
|
+
|
|
384
|
+
const keyword = '24 hour locksmith harlem'
|
|
385
|
+
|
|
386
|
+
const operations: MutateOperation<
|
|
387
|
+
resources.IAdGroupCriterion & { exempt_policy_violation_keys?: google.ads.googleads.v14.common.IPolicyViolationKey[]}
|
|
388
|
+
>[] = [
|
|
389
|
+
{
|
|
390
|
+
entity: 'ad_group_criterion',
|
|
391
|
+
operation: "create",
|
|
392
|
+
resource: {
|
|
393
|
+
// Keyword with policy violation exemptions
|
|
394
|
+
ad_group: adGroupResourceName,
|
|
395
|
+
keyword: {
|
|
396
|
+
text: '24 hour locksmith harlem',
|
|
397
|
+
match_type: enums.KeywordMatchType.PHRASE,
|
|
398
|
+
},
|
|
399
|
+
status: enums.AdGroupStatus.ENABLED ,
|
|
400
|
+
},
|
|
401
|
+
exempt_policy_violation_keys: [
|
|
402
|
+
{
|
|
403
|
+
policy_name: 'LOCAL_SERVICES',
|
|
404
|
+
violating_text: keyword,
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
}
|
|
408
|
+
];
|
|
409
|
+
|
|
410
|
+
const result = await customer.mutateResources(operations);
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
370
415
|
## Uploading Click Conversions
|
|
371
416
|
|
|
372
417
|
```ts
|
|
@@ -167,12 +167,20 @@ export default class ServiceFactory extends Service {
|
|
|
167
167
|
* @description create resources of type resources.IAdGroupCriterion
|
|
168
168
|
* @returns services.MutateAdGroupCriteriaResponse
|
|
169
169
|
*/
|
|
170
|
-
create: (adGroupCriteria: (resources.IAdGroupCriterion
|
|
170
|
+
create: (adGroupCriteria: ((resources.IAdGroupCriterion & {
|
|
171
|
+
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
172
|
+
}) | (resources.AdGroupCriterion & {
|
|
173
|
+
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
174
|
+
}))[], options?: Partial<Pick<services.IMutateAdGroupCriteriaRequest, "validate_only" | "partial_failure" | "response_content_type">> | undefined) => Promise<services.MutateAdGroupCriteriaResponse>;
|
|
171
175
|
/**
|
|
172
176
|
* @description update resources of type resources.IAdGroupCriterion
|
|
173
177
|
* @returns services.MutateAdGroupCriteriaResponse
|
|
174
178
|
*/
|
|
175
|
-
update: (adGroupCriteria: (resources.IAdGroupCriterion
|
|
179
|
+
update: (adGroupCriteria: ((resources.IAdGroupCriterion & {
|
|
180
|
+
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
181
|
+
}) | (resources.AdGroupCriterion & {
|
|
182
|
+
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
183
|
+
}))[], options?: Partial<Pick<services.IMutateAdGroupCriteriaRequest, "validate_only" | "partial_failure" | "response_content_type">> | undefined) => Promise<services.MutateAdGroupCriteriaResponse>;
|
|
176
184
|
/**
|
|
177
185
|
* @description remove resources of type string
|
|
178
186
|
* @returns services.MutateAdGroupCriteriaResponse
|
package/build/src/service.js
CHANGED
|
@@ -123,12 +123,20 @@ class Service {
|
|
|
123
123
|
buildMutationRequestAndService(mutations, options) {
|
|
124
124
|
const service = this.loadService("GoogleAdsServiceClient");
|
|
125
125
|
const mutateOperations = mutations.map((mutation) => {
|
|
126
|
-
var _a;
|
|
126
|
+
var _a, _b;
|
|
127
127
|
const opKey = (0, utils_1.toSnakeCase)(`${mutation.entity}Operation`);
|
|
128
128
|
const operation = {
|
|
129
129
|
[(_a = mutation.operation) !== null && _a !== void 0 ? _a : "create"]: mutation.resource,
|
|
130
130
|
};
|
|
131
|
-
if (mutation.operation === "
|
|
131
|
+
if (mutation.operation === "create" &&
|
|
132
|
+
(
|
|
133
|
+
//@ts-ignore
|
|
134
|
+
(_b = mutation === null || mutation === void 0 ? void 0 : mutation.exempt_policy_violation_keys) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
135
|
+
//@ts-ignore
|
|
136
|
+
operation.exempt_policy_violation_keys =
|
|
137
|
+
mutation.exempt_policy_violation_keys;
|
|
138
|
+
}
|
|
139
|
+
else if (mutation.operation === "update") {
|
|
132
140
|
// @ts-expect-error Resource operations should have updateMask defined
|
|
133
141
|
operation.update_mask = (0, utils_1.getFieldMask)(mutation.resource);
|
|
134
142
|
}
|
|
@@ -146,11 +154,19 @@ class Service {
|
|
|
146
154
|
}
|
|
147
155
|
buildOperations(type, entities, message) {
|
|
148
156
|
const ops = entities.map((e) => {
|
|
157
|
+
var _a;
|
|
149
158
|
const op = {
|
|
150
159
|
[type]: e,
|
|
151
160
|
operation: type,
|
|
152
161
|
};
|
|
153
|
-
|
|
162
|
+
//@ts-ignore
|
|
163
|
+
if (type === "create" && ((_a = e === null || e === void 0 ? void 0 : e.exempt_policy_violation_keys) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
164
|
+
// @ts-expect-error Field required for policy violation exemptions
|
|
165
|
+
op.exempt_policy_violation_keys = e.exempt_policy_violation_keys;
|
|
166
|
+
//@ts-ignore
|
|
167
|
+
delete e.exempt_policy_violation_keys;
|
|
168
|
+
}
|
|
169
|
+
else if (type === "update") {
|
|
154
170
|
// @ts-expect-error Field required for updates
|
|
155
171
|
op.update_mask = (0, utils_1.getFieldMask)(
|
|
156
172
|
// @ts-expect-error Message types have a toObject method
|
package/build/src/types.d.ts
CHANGED
|
@@ -53,5 +53,6 @@ export declare type MutateOperation<T> = {
|
|
|
53
53
|
resource: T;
|
|
54
54
|
entity: fields.Resource;
|
|
55
55
|
operation?: "create" | "update" | "remove";
|
|
56
|
+
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
56
57
|
} & Partial<Omit<T, "toJSON">>;
|
|
57
58
|
export declare type PageToken = services.ISearchGoogleAdsResponse["next_page_token"];
|