Class v1beta.NotificationsApiServiceClient (0.2.0)

Service to manage notification subscriptions for merchants v1beta

Package

@google-shopping/notifications

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of NotificationsApiServiceClient.

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

notificationsApiServiceStub

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

pathTemplates

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

port

static get port(): number;

The port for this API service.

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.

createNotificationSubscription(request, options)

createNotificationSubscription(request?: protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription,
        (protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | undefined),
        {} | undefined
    ]>;

Creates a notification subscription for a merchant. We will allow the following types of notification subscriptions to exist together (per merchant as a subscriber per event type): 1. Subscription for all managed accounts + subscription for self 2. Multiple "partial" subscriptions for managed accounts + subscription for self

we will not allow (per merchant as a subscriber per event type): 1. multiple self subscriptions. 2. multiple "all managed accounts" subscriptions. 3. all and partial subscriptions at the same time. 4. multiple partial subscriptions for the same target account

Parameters
Name Description
request ICreateNotificationSubscriptionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, (protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 merchant account that owns the new notification subscription.
   *  Format: `accounts/{account}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The notification subscription to create.
   */
  // const notificationSubscription = {}

  // Imports the Notifications library
  const {NotificationsApiServiceClient} = require('@google-shopping/notifications').v1beta;

  // Instantiates a client
  const notificationsClient = new NotificationsApiServiceClient();

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

    // Run request
    const response = await notificationsClient.createNotificationSubscription(request);
    console.log(response);
  }

  callCreateNotificationSubscription();

createNotificationSubscription(request, options, callback)

createNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateNotificationSubscriptionRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createNotificationSubscription(request, callback)

createNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateNotificationSubscriptionRequest
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.ICreateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteNotificationSubscription(request, options)

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

Deletes a notification subscription for a merchant.

Parameters
Name Description
request IDeleteNotificationSubscriptionRequest

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.notifications.v1beta.IDeleteNotificationSubscriptionRequest | 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 name of the notification subscription to be deleted.
   */
  // const name = 'abc123'

  // Imports the Notifications library
  const {NotificationsApiServiceClient} = require('@google-shopping/notifications').v1beta;

  // Instantiates a client
  const notificationsClient = new NotificationsApiServiceClient();

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

    // Run request
    const response = await notificationsClient.deleteNotificationSubscription(request);
    console.log(response);
  }

  callDeleteNotificationSubscription();

deleteNotificationSubscription(request, options, callback)

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

deleteNotificationSubscription(request, callback)

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

getNotificationSubscription(request, options)

getNotificationSubscription(request?: protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription,
        (protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | undefined),
        {} | undefined
    ]>;

Gets notification subscriptions for an account.

Parameters
Name Description
request IGetNotificationSubscriptionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, (protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 `name` of the notification subscription.
   */
  // const name = 'abc123'

  // Imports the Notifications library
  const {NotificationsApiServiceClient} = require('@google-shopping/notifications').v1beta;

  // Instantiates a client
  const notificationsClient = new NotificationsApiServiceClient();

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

    // Run request
    const response = await notificationsClient.getNotificationSubscription(request);
    console.log(response);
  }

  callGetNotificationSubscription();

getNotificationSubscription(request, options, callback)

getNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetNotificationSubscriptionRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getNotificationSubscription(request, callback)

getNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetNotificationSubscriptionRequest
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IGetNotificationSubscriptionRequest | 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.

listNotificationSubscriptions(request, options)

listNotificationSubscriptions(request?: protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription[],
        protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest | null,
        protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse
    ]>;

Gets all the notification subscriptions for a merchant.

Parameters
Name Description
request IListNotificationSubscriptionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription[], protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest | null, protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse ]>

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

listNotificationSubscriptions(request, options, callback)

listNotificationSubscriptions(request: protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse | null | undefined, protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>): void;
Parameters
Name Description
request IListNotificationSubscriptionsRequest
options CallOptions
callback PaginationCallback<protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse | null | undefined, protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>
Returns
Type Description
void

listNotificationSubscriptions(request, callback)

listNotificationSubscriptions(request: protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, callback: PaginationCallback<protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse | null | undefined, protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>): void;
Parameters
Name Description
request IListNotificationSubscriptionsRequest
callback PaginationCallback<protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsResponse | null | undefined, protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>
Returns
Type Description
void

listNotificationSubscriptionsAsync(request, options)

listNotificationSubscriptionsAsync(request?: protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, options?: CallOptions): AsyncIterable<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>;

Equivalent to listNotificationSubscriptions, but returns an iterable object.

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

Parameters
Name Description
request IListNotificationSubscriptionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . 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 merchant account who owns the notification subscriptions.
   *  Format: `accounts/{account}`
   */
  // const parent = 'abc123'
  /**
   *  The maximum number of notification subscriptions to return in a page.
   *  The default value for `page_size` is 100. The
   *  maximum value is `200`. Values above `200` will be coerced to `200`.
   */
  // const pageSize = 1234
  /**
   *  Token (if provided) to retrieve the subsequent page. All other parameters
   *  must match the original call that provided the page token.
   */
  // const pageToken = 'abc123'

  // Imports the Notifications library
  const {NotificationsApiServiceClient} = require('@google-shopping/notifications').v1beta;

  // Instantiates a client
  const notificationsClient = new NotificationsApiServiceClient();

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

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

  callListNotificationSubscriptions();

listNotificationSubscriptionsStream(request, options)

listNotificationSubscriptionsStream(request?: protos.google.shopping.merchant.notifications.v1beta.IListNotificationSubscriptionsRequest, options?: CallOptions): Transform;

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

Parameters
Name Description
request IListNotificationSubscriptionsRequest

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 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 listNotificationSubscriptionsAsync() 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.

matchAccountFromNotificationSubscriptionName(notificationSubscriptionName)

matchAccountFromNotificationSubscriptionName(notificationSubscriptionName: string): string | number;

Parse the account from NotificationSubscription resource.

Parameter
Name Description
notificationSubscriptionName string

A fully-qualified path representing NotificationSubscription resource.

Returns
Type Description
string | number

{string} A string representing the account.

matchNotificationSubscriptionFromNotificationSubscriptionName(notificationSubscriptionName)

matchNotificationSubscriptionFromNotificationSubscriptionName(notificationSubscriptionName: string): string | number;

Parse the notification_subscription from NotificationSubscription resource.

Parameter
Name Description
notificationSubscriptionName string

A fully-qualified path representing NotificationSubscription resource.

Returns
Type Description
string | number

{string} A string representing the notification_subscription.

notificationSubscriptionPath(account, notificationSubscription)

notificationSubscriptionPath(account: string, notificationSubscription: string): string;

Return a fully-qualified notificationSubscription resource name string.

Parameters
Name Description
account string
notificationSubscription string
Returns
Type Description
string

{string} Resource name string.

updateNotificationSubscription(request, options)

updateNotificationSubscription(request?: protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription,
        (protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | undefined),
        {} | undefined
    ]>;

Updates an existing notification subscription for a merchant.

Parameters
Name Description
request IUpdateNotificationSubscriptionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, (protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . 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 new version of the notification subscription that should be
   *  updated.
   */
  // const notificationSubscription = {}
  /**
   *  List of fields being updated.
   */
  // const updateMask = {}

  // Imports the Notifications library
  const {NotificationsApiServiceClient} = require('@google-shopping/notifications').v1beta;

  // Instantiates a client
  const notificationsClient = new NotificationsApiServiceClient();

  async function callUpdateNotificationSubscription() {
    // Construct request
    const request = {
      notificationSubscription,
    };

    // Run request
    const response = await notificationsClient.updateNotificationSubscription(request);
    console.log(response);
  }

  callUpdateNotificationSubscription();

updateNotificationSubscription(request, options, callback)

updateNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateNotificationSubscriptionRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateNotificationSubscription(request, callback)

updateNotificationSubscription(request: protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest, callback: Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateNotificationSubscriptionRequest
callback Callback<protos.google.shopping.merchant.notifications.v1beta.INotificationSubscription, protos.google.shopping.merchant.notifications.v1beta.IUpdateNotificationSubscriptionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void