google-ads-api 17.1.0-rest-beta → 19.0.0-rest-beta

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 CHANGED
@@ -350,7 +350,7 @@ const operations: MutateOperation<
350
350
  advertising_channel_type: enums.AdvertisingChannelType.SEARCH,
351
351
  status: enums.CampaignStatus.PAUSED,
352
352
  manual_cpc: {
353
- enhanced_cpc_enabled: true,
353
+ enhanced_cpc_enabled: false,
354
354
  },
355
355
  // Use the temporary resource id which will be created in the previous operation
356
356
  campaign_budget: budgetResourceName,
@@ -443,7 +443,9 @@ If a summary row is requested in the `report` method, it will be included as the
443
443
  const [summaryRow, ...response] = await customer.report({
444
444
  entity: "campaign",
445
445
  metrics: ["metrics.clicks", "metrics.all_conversions"],
446
- summary_row_setting: enums.SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS,
446
+ search_settings: {
447
+ return_summary_row: enums.SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS,
448
+ },
447
449
  });
448
450
  ```
449
451
 
@@ -453,7 +455,9 @@ If a summery row is requested in the `reportStream` method, it will be included
453
455
  const stream = customer.reportStream({
454
456
  entity: "campaign",
455
457
  metrics: ["metrics.clicks", "metrics.all_conversions"],
456
- summary_row_setting: enums.SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS,
458
+ search_settings: {
459
+ return_summary_row: enums.SummaryRowSetting.SUMMARY_ROW_WITH_RESULTS,
460
+ },
457
461
  });
458
462
 
459
463
  const accumulator = [];
@@ -4,21 +4,6 @@ import { Hooks } from "./hooks";
4
4
  import { services } from "./protos";
5
5
  import ServiceFactory from "./protos/autogen/serviceFactory";
6
6
  import { CustomerOptions, MutateOperation, MutateOptions, ReportOptions, RequestOptions } from "./types";
7
- /**
8
- * TODO:
9
- * - rename querierRest to streamRest. Add hooks support to it. OK
10
- * - write querierRest, using pagination. OK
11
- * - make sure return_total_results_count works
12
- * - make sure SUMMARY_ROW_SETTING works
13
- * - adapt query()
14
- * - adapt queryStream
15
- * - adapt report()
16
- * - adapt reportCount()
17
- * - adapt reportStream()
18
- * - reportStreamRaw() ?
19
- * - bonus: use queryStream when the params allow it. Note: do it with native async generator to make it as fast as possible.
20
- * - bonus: make it possible to cancel a stream or pagination when row count exceeds specified max
21
- */
22
7
  export declare class Customer extends ServiceFactory {
23
8
  constructor(clientOptions: ClientOptions, customerOptions: CustomerOptions, hooks?: Hooks);
24
9
  /**
@@ -14,21 +14,6 @@ const serviceFactory_1 = __importDefault(require("./protos/autogen/serviceFactor
14
14
  const query_1 = require("./query");
15
15
  const version_1 = require("./version");
16
16
  const ROWS_PER_STREAMED_CHUNK = 10_000; // From experience, this is what can be expected from the API.
17
- /**
18
- * TODO:
19
- * - rename querierRest to streamRest. Add hooks support to it. OK
20
- * - write querierRest, using pagination. OK
21
- * - make sure return_total_results_count works
22
- * - make sure SUMMARY_ROW_SETTING works
23
- * - adapt query()
24
- * - adapt queryStream
25
- * - adapt report()
26
- * - adapt reportCount()
27
- * - adapt reportStream()
28
- * - reportStreamRaw() ?
29
- * - bonus: use queryStream when the params allow it. Note: do it with native async generator to make it as fast as possible.
30
- * - bonus: make it possible to cancel a stream or pagination when row count exceeds specified max
31
- */
32
17
  class Customer extends serviceFactory_1.default {
33
18
  constructor(clientOptions, customerOptions, hooks) {
34
19
  super(clientOptions, customerOptions, hooks ?? {});
@@ -71,8 +56,8 @@ class Customer extends serviceFactory_1.default {
71
56
  */
72
57
  async reportCount(options) {
73
58
  const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)({ ...options, limit: 1 }); // must get at least one row
74
- // @ts-expect-error we do not allow this field in reportOptions, however it is still a valid request option
75
- requestOptions.return_total_results_count = true;
59
+ // We do not allow this field in reportOptions, however it is still a valid request option
60
+ requestOptions.search_settings = { return_total_results_count: true };
76
61
  const useHooks = false; // to avoid cacheing conflicts
77
62
  const { totalResultsCount } = await this.querier(gaqlQuery, requestOptions, options, useHooks);
78
63
  return totalResultsCount;
@@ -162,7 +147,7 @@ class Customer extends serviceFactory_1.default {
162
147
  When possible, use the searchStream method to avoid the overhead of pagination.
163
148
  */
164
149
  if (requestOptions.page_size === undefined &&
165
- requestOptions.return_total_results_count === undefined) {
150
+ requestOptions.search_settings?.return_total_results_count === undefined) {
166
151
  // If no pagination or summary options are set, we can use the non-paginated search method.
167
152
  const { response } = await this.useStreamToImitateRegularSearch(gaqlQuery, requestOptions);
168
153
  return { response };
@@ -173,7 +158,7 @@ class Customer extends serviceFactory_1.default {
173
158
  let totalResultsCount = initialSearch.totalResultsCount;
174
159
  // Sometimes (when no results?) the totalResultsCount field is not included in the response.
175
160
  // In this case, we set it to 0.
176
- if (requestOptions.return_total_results_count &&
161
+ if (requestOptions.search_settings?.return_total_results_count &&
177
162
  initialSearch.totalResultsCount === undefined) {
178
163
  totalResultsCount = 0;
179
164
  }