Class v1beta.ReportServiceClient (0.7.0)

Service for retrieving reports and insights about your products, their performance, and their competitive environment on Google. v1beta

Package

@google-shopping/reports

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of ReportServiceClient.

Parameters
Name Description
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new ReportServiceClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

port

static get port(): number;

The port for this API service.

reportServiceStub

reportServiceStub?: Promise<{
        [name: string]: Function;
    }>;

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
Type Description
Promise<void>

{Promise} A promise that resolves when the client is closed.

getProjectId()

getProjectId(): Promise<string>;
Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
Type Description
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

search(request, options)

search(request?: protos.google.shopping.merchant.reports.v1beta.ISearchRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.reports.v1beta.IReportRow[],
        protos.google.shopping.merchant.reports.v1beta.ISearchRequest | null,
        protos.google.shopping.merchant.reports.v1beta.ISearchResponse
    ]>;

Retrieves a report defined by a search query. The response might contain fewer rows than specified by page_size. Rely on next_page_token to determine if there are more rows to be requested.

Parameters
Name Description
request ISearchRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.reports.v1beta.IReportRow[], protos.google.shopping.merchant.reports.v1beta.ISearchRequest | null, protos.google.shopping.merchant.reports.v1beta.ISearchResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of ReportRow. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using searchAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

search(request, options, callback)

search(request: protos.google.shopping.merchant.reports.v1beta.ISearchRequest, options: CallOptions, callback: PaginationCallback<protos.google.shopping.merchant.reports.v1beta.ISearchRequest, protos.google.shopping.merchant.reports.v1beta.ISearchResponse | null | undefined, protos.google.shopping.merchant.reports.v1beta.IReportRow>): void;
Parameters
Name Description
request ISearchRequest
options CallOptions
callback PaginationCallback<protos.google.shopping.merchant.reports.v1beta.ISearchRequest, protos.google.shopping.merchant.reports.v1beta.ISearchResponse | null | undefined, protos.google.shopping.merchant.reports.v1beta.IReportRow>
Returns
Type Description
void

search(request, callback)

search(request: protos.google.shopping.merchant.reports.v1beta.ISearchRequest, callback: PaginationCallback<protos.google.shopping.merchant.reports.v1beta.ISearchRequest, protos.google.shopping.merchant.reports.v1beta.ISearchResponse | null | undefined, protos.google.shopping.merchant.reports.v1beta.IReportRow>): void;
Parameters
Name Description
request ISearchRequest
callback PaginationCallback<protos.google.shopping.merchant.reports.v1beta.ISearchRequest, protos.google.shopping.merchant.reports.v1beta.ISearchResponse | null | undefined, protos.google.shopping.merchant.reports.v1beta.IReportRow>
Returns
Type Description
void

searchAsync(request, options)

searchAsync(request?: protos.google.shopping.merchant.reports.v1beta.ISearchRequest, options?: CallOptions): AsyncIterable<protos.google.shopping.merchant.reports.v1beta.IReportRow>;

Equivalent to search, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request ISearchRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.shopping.merchant.reports.v1beta.IReportRow>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ReportRow. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Id of the account making the call. Must be a standalone account
   *  or an MCA subaccount. Format: accounts/{account}
   */
  // const parent = 'abc123'
  /**
   *  Required. Query that defines a report to be retrieved.
   *  For details on how to construct your query, see the Query Language
   *  guide. For the full list of available tables and fields, see the Available
   *  fields.
   */
  // const query = 'abc123'
  /**
   *  Optional. Number of `ReportRows` to retrieve in a single page. Defaults to
   *  the maximum of 1000. Values above 1000 are coerced to 1000.
   */
  // const pageSize = 1234
  /**
   *  Optional. Token of the page to retrieve. If not specified, the first page
   *  of results is returned. In order to request the next page of results, the
   *  value obtained from `next_page_token` in the previous response should be
   *  used.
   */
  // const pageToken = 'abc123'

  // Imports the Reports library
  const {ReportServiceClient} = require('@google-shopping/reports').v1beta;

  // Instantiates a client
  const reportsClient = new ReportServiceClient();

  async function callSearch() {
    // Construct request
    const request = {
      parent,
      query,
    };

    // Run request
    const iterable = await reportsClient.searchAsync(request);
    for await (const response of iterable) {
      console.log(response);
    }
  }

  callSearch();

searchStream(request, options)

searchStream(request?: protos.google.shopping.merchant.reports.v1beta.ISearchRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request ISearchRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing ReportRow on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using searchAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.