google-ads-api 16.0.0-rest-beta1 → 16.0.0-rest-beta3

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.
@@ -162,7 +162,6 @@ class Customer extends serviceFactory_1.default {
162
162
  When possible, use the searchStream method to avoid the overhead of pagination.
163
163
  */
164
164
  if (requestOptions.page_size === undefined &&
165
- // @ts-expect-error we do not allow this field in reportOptions, however it is still a valid request option
166
165
  requestOptions.return_total_results_count === undefined) {
167
166
  // If no pagination or summary options are set, we can use the non-paginated search method.
168
167
  const { response } = await this.useStreamToImitateRegularSearch(gaqlQuery, requestOptions);
@@ -171,7 +170,13 @@ class Customer extends serviceFactory_1.default {
171
170
  const response = [];
172
171
  let nextPageToken = undefined;
173
172
  const initialSearch = await this.search(gaqlQuery, requestOptions);
174
- const totalResultsCount = initialSearch.totalResultsCount;
173
+ let totalResultsCount = initialSearch.totalResultsCount;
174
+ // Sometimes (when no results?) the totalResultsCount field is not included in the response.
175
+ // In this case, we set it to 0.
176
+ if (requestOptions.return_total_results_count &&
177
+ initialSearch.totalResultsCount === undefined) {
178
+ totalResultsCount = 0;
179
+ }
175
180
  let summaryRow = initialSearch.summaryRow;
176
181
  response.push(...initialSearch.response);
177
182
  nextPageToken = initialSearch.nextPageToken;
@@ -481,8 +486,6 @@ class Customer extends serviceFactory_1.default {
481
486
  headers: {
482
487
  Authorization: `Bearer ${accessToken}`,
483
488
  ...this.callHeaders,
484
- "developer-token": this.clientOptions.developer_token ?? "",
485
- "login-customer-id": this.credentials.login_customer_id ?? "",
486
489
  },
487
490
  ...extra,
488
491
  };
@@ -21,7 +21,7 @@ const serviceCache = new ttlcache_1.default({
21
21
  await service.close();
22
22
  },
23
23
  });
24
- // A global access token cache used by REST calls. Issued tokens expire after 1 hour.
24
+ // A global access token cache used by REST calls. Issued tokens expire after 1 hour, so we cache them for 50 minutes.
25
25
  const accessTokenCache = new ttlcache_1.default({
26
26
  max: 100_000,
27
27
  ttl: 50 * 60 * 1000, // 50 minutes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "google-ads-api",
3
- "version": "16.0.0-rest-beta1",
3
+ "version": "16.0.0-rest-beta3",
4
4
  "description": "Google Ads API Client Library for Node.js",
5
5
  "repository": "https://github.com/Opteo/google-ads-api",
6
6
  "main": "build/src/index.js",