Skip to content

Commit

Permalink
add exempt_policy_violation_keys to mutateResources
Browse files Browse the repository at this point in the history
  • Loading branch information
Josecamero committed Nov 13, 2023
1 parent 43cd36e commit 14457f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions scripts/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,17 +353,18 @@ function buildMutateMethod(
const isUpdate = mutation === "update";
const updateMaskMessageArg = isUpdate ? `, ${requestClass}` : "";

const policyViolationArgType = argName!=='adGroupCriteria'?`(${resourceType} | ${requestClass})[]`:`((${resourceType} & {exempt_policy_violation_keys?: services.AdGroupCriterionOperation['exempt_policy_violation_keys'] } ) | (${requestClass} & {exempt_policy_violation_keys?: services.AdGroupCriterionOperation['exempt_policy_violation_keys'] }))[]`
const policyViolationArgType =
argName !== "adGroupCriteria"
? `(${resourceType} | ${requestClass})[]`
: `((${resourceType} & {exempt_policy_violation_keys?: services.AdGroupCriterionOperation['exempt_policy_violation_keys'] } ) | (${requestClass} & {exempt_policy_violation_keys?: services.AdGroupCriterionOperation['exempt_policy_violation_keys'] }))[]`;
return `
/**
* @description ${mutation} resources of type ${resourceType}
* @returns ${responseType}
*/
${mutation}: async (
${argName}: ${
mutation === "remove"
? `${resourceType}[]`
:`${policyViolationArgType}`
mutation === "remove" ? `${resourceType}[]` : `${policyViolationArgType}`
} ,
options?: MutateOptions
): Promise<${responseType} > => {
Expand Down
2 changes: 1 addition & 1 deletion src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ export class Service {
//@ts-ignore
mutation?.exempt_policy_violation_keys?.length
) {
//@ts-ignore
operation.exempt_policy_violation_keys =
// @ts-expect-error Field required for policy violation exemptions
mutation.exempt_policy_violation_keys;
} else if (mutation.operation === "update") {
// @ts-expect-error Resource operations should have updateMask defined
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export type MutateOperation<T> = {
resource: T;
entity: fields.Resource;
operation?: "create" | "update" | "remove";
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
} & Partial<Omit<T, "toJSON">>;

export type PageToken = services.ISearchGoogleAdsResponse["next_page_token"];

0 comments on commit 14457f7

Please sign in to comment.