UNPKG

google-ads-api

Version:

Google Ads API Client Library for Node.js

1,068 lines 806 kB
"use strict"; /* Autogenerated File! Do Not Edit */ Object.defineProperty(exports, "__esModule", { value: true }); const service_1 = require("../../service"); const index_1 = require("../index"); class ServiceFactory extends service_1.Service { constructor(clientOptions, customerOptions, hooks) { super(clientOptions, customerOptions, hooks ?? {}); } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AccountBudgetProposalService */ get accountBudgetProposals() { const service = this.loadService("AccountBudgetProposalServiceClient"); return { /** * @description create resources of type resources.IAccountBudgetProposal * @returns services.MutateAccountBudgetProposalResponse */ create: async (accountBudgetProposals, options) => { const ops = this.buildOperations("create", accountBudgetProposals); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AccountBudgetProposalService.mutateAccountBudgetProposal", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAccountBudgetProposal(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response, resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return response; } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAccountBudgetProposalResponse */ remove: async (accountBudgetProposals, options) => { const ops = this.buildOperations("remove", accountBudgetProposals); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AccountBudgetProposalService.mutateAccountBudgetProposal", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAccountBudgetProposal(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response, resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return response; } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, }; } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AccountLinkService */ get accountLinks() { const service = this.loadService("AccountLinkServiceClient"); return { /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AccountLinkService#createaccountlink */ createAccountLink: async (request) => { const baseHookArguments = { credentials: this.credentials, method: "AccountLinkService.CreateAccountLink", requestOptions: request, }; if (this.hooks.onServiceStart) { const serviceCancellation = { cancelled: false }; await this.hooks.onServiceStart({ ...baseHookArguments, cancel: (res) => { serviceCancellation.cancelled = true; serviceCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (serviceCancellation.cancelled) { return serviceCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.createAccountLink(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onServiceEnd) { const serviceResolution = { resolved: false }; await this.hooks.onServiceEnd({ ...baseHookArguments, response, resolve: (res) => { serviceResolution.resolved = true; serviceResolution.res = res; }, }); if (serviceResolution.resolved) { return serviceResolution.res; } } return response; } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onServiceError) { await this.hooks.onServiceError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description update resources of type resources.IAccountLink * @returns services.MutateAccountLinkResponse */ update: async (accountLinks, options) => { const ops = this.buildOperations("update", accountLinks, // @ts-expect-error Static class type here is fine index_1.resources.AccountLink); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AccountLinkService.mutateAccountLink", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAccountLink(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAccountLinkResponse */ remove: async (accountLinks, options) => { const ops = this.buildOperations("remove", accountLinks); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AccountLinkService.mutateAccountLink", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAccountLink(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, }; } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AdGroupAdLabelService */ get adGroupAdLabels() { const service = this.loadService("AdGroupAdLabelServiceClient"); return { /** * @description create resources of type resources.IAdGroupAdLabel * @returns services.MutateAdGroupAdLabelsResponse */ create: async (adGroupAdLabels, options) => { const ops = this.buildOperations("create", adGroupAdLabels); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdLabelService.mutateAdGroupAdLabels", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAdLabels(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAdGroupAdLabelsResponse */ remove: async (adGroupAdLabels, options) => { const ops = this.buildOperations("remove", adGroupAdLabels); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdLabelService.mutateAdGroupAdLabels", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAdLabels(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, }; } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AdGroupAdService */ get adGroupAds() { const service = this.loadService("AdGroupAdServiceClient"); return { /** * @description create resources of type resources.IAdGroupAd * @returns services.MutateAdGroupAdsResponse */ create: async (adGroupAds, options) => { const ops = this.buildOperations("create", adGroupAds); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdService.mutateAdGroupAds", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAds(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description update resources of type resources.IAdGroupAd * @returns services.MutateAdGroupAdsResponse */ update: async (adGroupAds, options) => { const ops = this.buildOperations("update", adGroupAds, // @ts-expect-error Static class type here is fine index_1.resources.AdGroupAd); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdService.mutateAdGroupAds", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAds(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAdGroupAdsResponse */ remove: async (adGroupAds, options) => { const ops = this.buildOperations("remove", adGroupAds); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdService.mutateAdGroupAds", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAds(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AdGroupAdService#removeautomaticallycreatedassets */ removeAutomaticallyCreatedAssets: async (request) => { const baseHookArguments = { credentials: this.credentials, method: "AdGroupAdService.RemoveAutomaticallyCreatedAssets", requestOptions: request, }; if (this.hooks.onServiceStart) { const serviceCancellation = { cancelled: false }; await this.hooks.onServiceStart({ ...baseHookArguments, cancel: (res) => { serviceCancellation.cancelled = true; serviceCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (serviceCancellation.cancelled) { return serviceCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.removeAutomaticallyCreatedAssets(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onServiceEnd) { const serviceResolution = { resolved: false }; await this.hooks.onServiceEnd({ ...baseHookArguments, response, resolve: (res) => { serviceResolution.resolved = true; serviceResolution.res = res; }, }); if (serviceResolution.resolved) { return serviceResolution.res; } } return response; } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onServiceError) { await this.hooks.onServiceError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, }; } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AdGroupAssetService */ get adGroupAssets() { const service = this.loadService("AdGroupAssetServiceClient"); return { /** * @description create resources of type resources.IAdGroupAsset * @returns services.MutateAdGroupAssetsResponse */ create: async (adGroupAssets, options) => { const ops = this.buildOperations("create", adGroupAssets); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAssetService.mutateAdGroupAssets", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAssets(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description update resources of type resources.IAdGroupAsset * @returns services.MutateAdGroupAssetsResponse */ update: async (adGroupAssets, options) => { const ops = this.buildOperations("update", adGroupAssets, // @ts-expect-error Static class type here is fine index_1.resources.AdGroupAsset); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAssetService.mutateAdGroupAssets", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAssets(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAdGroupAssetsResponse */ remove: async (adGroupAssets, options) => { const ops = this.buildOperations("remove", adGroupAssets); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAssetService.mutateAdGroupAssets", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAssets(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, }; } /** * @link https://developers.google.com/google-ads/api/reference/rpc/v19/AdGroupAssetSetService */ get adGroupAssetSets() { const service = this.loadService("AdGroupAssetSetServiceClient"); return { /** * @description create resources of type resources.IAdGroupAssetSet * @returns services.MutateAdGroupAssetSetsResponse */ create: async (adGroupAssetSets, options) => { const ops = this.buildOperations("create", adGroupAssetSets); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAssetSetService.mutateAdGroupAssetSets", mutation: request, isServiceCall: true, }; if (this.hooks.onMutationStart) { const mutationCancellation = { cancelled: false }; await this.hooks.onMutationStart({ ...baseHookArguments, cancel: (res) => { mutationCancellation.cancelled = true; mutationCancellation.res = res; }, editOptions: (options) => { Object.entries(options).forEach(([key, val]) => { // @ts-expect-error Index with key type is fine request[key] = val; }); }, }); if (mutationCancellation.cancelled) { return mutationCancellation.res; } } try { // @ts-expect-error Response is an array type const [response] = await service.mutateAdGroupAssetSets(request, { // @ts-expect-error This arg doesn't exist in the type definitions otherArgs: { headers: this.callHeaders, }, }); if (this.hooks.onMutationEnd) { const mutationResolution = { resolved: false }; await this.hooks.onMutationEnd({ ...baseHookArguments, response: this.decodePartialFailureError(response), resolve: (res) => { mutationResolution.resolved = true; mutationResolution.res = res; }, }); if (mutationResolution.resolved) { return mutationResolution.res; } } return this.decodePartialFailureError(response); } catch (err) { const googleAdsError = this.getGoogleAdsError(err); if (this.hooks.onMutationError) { await this.hooks.onMutationError({ ...baseHookArguments, error: googleAdsError, }); } throw googleAdsError; } }, /** * @description remove resources of type string * @returns services.MutateAdGroupAssetSetsResponse */ remove: async (adGroupAssetSets, options) => { const ops = this.buildOperations("remove", adGroupAssetSets); const request = this.buildRequest(ops, options); const baseHookArguments = { credentials: this.credentials, method: "AdGroupAssetSetService.mutateAdGroupAssetSets