Class v1.LoyaltyCustomerMatchServiceClient (0.4.1)

Manages customer loyalty program memberships for merchants.

This service allows all merchants, including non-advertisers, to share their first-party customer data of loyalty program members. Google uses this data to personalize organic free listing shopping experiences, in compliance with the [Merchant Center Terms of Service](https://support.google.com/merchants/answer/160173).

The service follows a non-standard, imperative pattern, exposing a single ManageLoyaltyCustomerMatch method rather than conventional resource identifiers and CRUD operations. This design protects user privacy by preventing the discovery of a customer's presence or membership status through standard GET or LIST methods. v1

Package

@google-shopping/loyaltycustomers

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of LoyaltyCustomerMatchServiceClient.

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

loyaltyCustomerMatchServiceStub

loyaltyCustomerMatchServiceStub?: 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.

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.

manageLoyaltyCustomerMatch(request, options)

manageLoyaltyCustomerMatch(request?: protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest, options?: CallOptions): Promise<[
        protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse,
        (protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | undefined),
        {} | undefined
    ]>;

Manages (inserts, updates, or removes) a customer's loyalty tier information.

This method serves as a single interface for all changes to a customer's loyalty status. The specific action (insert, update, or remove) is determined by the current state of the merchant-to-customer association and the loyalty_tier value provided in the request.

**Operation Logic:**

* **Upsert (Insert/Update):** Providing any valid tier other than NON_MEMBER will associate the customer with that tier. If an association already exists, it will be updated; otherwise, a new one will be created. * **Removal:** Setting loyalty_tier to NON_MEMBER will remove any existing loyalty association for the customer.

**Privacy Note:** To protect user privacy, this method consistently returns a 200 OK status with a default LoyaltyCustomer response if the customer's identifier cannot be matched to a Google account or if the user has not opted into loyalty personalization.

Parameters
Name Description
request IManageLoyaltyCustomerMatchRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse, (protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ManageLoyaltyCustomerMatchResponse. 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 parent account where this loyalty customer will be handled.
   *  Format: `accounts/{account}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The loyalty customer to insert, update, or remove.
   */
  // const loyaltyCustomer = {}

  // Imports the Loyaltycustomers library
  const {LoyaltyCustomerMatchServiceClient} = require('@google-shopping/loyaltycustomers').v1;

  // Instantiates a client
  const loyaltycustomersClient = new LoyaltyCustomerMatchServiceClient();

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

    // Run request
    const response = await loyaltycustomersClient.manageLoyaltyCustomerMatch(request);
    console.log(response);
  }

  callManageLoyaltyCustomerMatch();

manageLoyaltyCustomerMatch(request, options, callback)

manageLoyaltyCustomerMatch(request: protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse, protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IManageLoyaltyCustomerMatchRequest
options CallOptions
callback Callback<protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse, protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

manageLoyaltyCustomerMatch(request, callback)

manageLoyaltyCustomerMatch(request: protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest, callback: Callback<protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse, protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IManageLoyaltyCustomerMatchRequest
callback Callback<protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchResponse, protos.google.shopping.merchant.loyaltycustomers.v1.IManageLoyaltyCustomerMatchRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

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.