Class v1beta.ProductReviewsServiceClient (0.1.0)

Service to manage product reviews. v1beta

Package

@google-shopping/reviews

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of ProductReviewsServiceClient.

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 ProductReviewsServiceClient({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;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

productReviewsServiceStub

productReviewsServiceStub?: 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

accountPath(account)

accountPath(account: string): string;

Return a fully-qualified account resource name string.

Parameter
Name Description
account string
Returns
Type Description
string

{string} Resource name string.

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.

deleteProductReview(request, options)

deleteProductReview(request?: protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | undefined),
        {} | undefined
    ]>;

Deletes a product review.

Parameters
Name Description
request IDeleteProductReviewRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, (protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. 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. The ID of the Product review.
   *  Format: accounts/{account}/productReviews/{productReview}
   */
  // const name = 'abc123'

  // Imports the Reviews library
  const {ProductReviewsServiceClient} = require('@google-shopping/reviews').v1beta;

  // Instantiates a client
  const reviewsClient = new ProductReviewsServiceClient();

  async function callDeleteProductReview() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await reviewsClient.deleteProductReview(request);
    console.log(response);
  }

  callDeleteProductReview();

deleteProductReview(request, options, callback)

deleteProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteProductReviewRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteProductReview(request, callback)

deleteProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteProductReviewRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.shopping.merchant.reviews.v1beta.IDeleteProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getProductReview(request, options)

getProductReview(request?: protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.reviews.v1beta.IProductReview,
        (protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | undefined),
        {} | undefined
    ]>;

Gets a product review.

Parameters
Name Description
request IGetProductReviewRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.reviews.v1beta.IProductReview, (protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ProductReview. 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. The ID of the merchant review.
   *  Format: accounts/{account}/productReviews/{productReview}
   */
  // const name = 'abc123'

  // Imports the Reviews library
  const {ProductReviewsServiceClient} = require('@google-shopping/reviews').v1beta;

  // Instantiates a client
  const reviewsClient = new ProductReviewsServiceClient();

  async function callGetProductReview() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await reviewsClient.getProductReview(request);
    console.log(response);
  }

  callGetProductReview();

getProductReview(request, options, callback)

getProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetProductReviewRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getProductReview(request, callback)

getProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest, callback: Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetProductReviewRequest
callback Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IGetProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

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.

insertProductReview(request, options)

insertProductReview(request?: protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.reviews.v1beta.IProductReview,
        (protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | undefined),
        {} | undefined
    ]>;

Inserts a product review.

Parameters
Name Description
request IInsertProductReviewRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.reviews.v1beta.IProductReview, (protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ProductReview. 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. The account where the product review will be inserted.
   *  Format: accounts/{account}
   */
  // const parent = 'abc123'
  /**
   *  Required. The product review to insert.
   */
  // const productReview = {}
  /**
   *  Required. Format:
   *  `accounts/{account}/dataSources/{datasource}`.
   */
  // const dataSource = 'abc123'

  // Imports the Reviews library
  const {ProductReviewsServiceClient} = require('@google-shopping/reviews').v1beta;

  // Instantiates a client
  const reviewsClient = new ProductReviewsServiceClient();

  async function callInsertProductReview() {
    // Construct request
    const request = {
      parent,
      productReview,
      dataSource,
    };

    // Run request
    const response = await reviewsClient.insertProductReview(request);
    console.log(response);
  }

  callInsertProductReview();

insertProductReview(request, options, callback)

insertProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IInsertProductReviewRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

insertProductReview(request, callback)

insertProductReview(request: protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest, callback: Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IInsertProductReviewRequest
callback Callback<protos.google.shopping.merchant.reviews.v1beta.IProductReview, protos.google.shopping.merchant.reviews.v1beta.IInsertProductReviewRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

listProductReviews(request, options)

listProductReviews(request?: protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.reviews.v1beta.IProductReview[],
        protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest | null,
        protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse
    ]>;

Lists product reviews.

Parameters
Name Description
request IListProductReviewsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.reviews.v1beta.IProductReview[], protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest | null, protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of ProductReview. 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 listProductReviewsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listProductReviews(request, options, callback)

listProductReviews(request: protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, options: CallOptions, callback: PaginationCallback<protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse | null | undefined, protos.google.shopping.merchant.reviews.v1beta.IProductReview>): void;
Parameters
Name Description
request IListProductReviewsRequest
options CallOptions
callback PaginationCallback<protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse | null | undefined, protos.google.shopping.merchant.reviews.v1beta.IProductReview>
Returns
Type Description
void

listProductReviews(request, callback)

listProductReviews(request: protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, callback: PaginationCallback<protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse | null | undefined, protos.google.shopping.merchant.reviews.v1beta.IProductReview>): void;
Parameters
Name Description
request IListProductReviewsRequest
callback PaginationCallback<protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsResponse | null | undefined, protos.google.shopping.merchant.reviews.v1beta.IProductReview>
Returns
Type Description
void

listProductReviewsAsync(request, options)

listProductReviewsAsync(request?: protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, options?: CallOptions): AsyncIterable<protos.google.shopping.merchant.reviews.v1beta.IProductReview>;

Equivalent to listProductReviews, but returns an iterable object.

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

Parameters
Name Description
request IListProductReviewsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.shopping.merchant.reviews.v1beta.IProductReview>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing ProductReview. 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. The account to list product reviews for.
   *  Format: accounts/{account}
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of products to return. The service may return
   *  fewer than this value.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token, received from a previous `ListProductReviews` call.
   *  Provide this to retrieve the subsequent page.
   *  When paginating, all other parameters provided to `ListProductReviews`
   *  must match the call that provided the page token.
   */
  // const pageToken = 'abc123'

  // Imports the Reviews library
  const {ProductReviewsServiceClient} = require('@google-shopping/reviews').v1beta;

  // Instantiates a client
  const reviewsClient = new ProductReviewsServiceClient();

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

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

  callListProductReviews();

listProductReviewsStream(request, options)

listProductReviewsStream(request?: protos.google.shopping.merchant.reviews.v1beta.IListProductReviewsRequest, options?: CallOptions): Transform;

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

Parameters
Name Description
request IListProductReviewsRequest

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 ProductReview 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 listProductReviewsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchAccountFromAccountName(accountName)

matchAccountFromAccountName(accountName: string): string | number;

Parse the account from Account resource.

Parameter
Name Description
accountName string

A fully-qualified path representing Account resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchAccountFromMerchantReviewName(merchantReviewName)

matchAccountFromMerchantReviewName(merchantReviewName: string): string | number;

Parse the account from MerchantReview resource.

Parameter
Name Description
merchantReviewName string

A fully-qualified path representing MerchantReview resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchAccountFromProductReviewName(productReviewName)

matchAccountFromProductReviewName(productReviewName: string): string | number;

Parse the account from ProductReview resource.

Parameter
Name Description
productReviewName string

A fully-qualified path representing ProductReview resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchNameFromMerchantReviewName(merchantReviewName)

matchNameFromMerchantReviewName(merchantReviewName: string): string | number;

Parse the name from MerchantReview resource.

Parameter
Name Description
merchantReviewName string

A fully-qualified path representing MerchantReview resource.

Returns
Type Description
string | number

{string} A string representing the name.

matchProductreviewFromProductReviewName(productReviewName)

matchProductreviewFromProductReviewName(productReviewName: string): string | number;

Parse the productreview from ProductReview resource.

Parameter
Name Description
productReviewName string

A fully-qualified path representing ProductReview resource.

Returns
Type Description
string | number

{string} A string representing the productreview.

merchantReviewPath(account, name)

merchantReviewPath(account: string, name: string): string;

Return a fully-qualified merchantReview resource name string.

Parameters
Name Description
account string
name string
Returns
Type Description
string

{string} Resource name string.

productReviewPath(account, productreview)

productReviewPath(account: string, productreview: string): string;

Return a fully-qualified productReview resource name string.

Parameters
Name Description
account string
productreview string
Returns
Type Description
string

{string} Resource name string.