Class LoyaltyCustomerMatchServiceClient (0.3.0)

GitHub RepositoryProduct Reference

Service Description: 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.

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.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create()) {
   ManageLoyaltyCustomerMatchRequest request =
       ManageLoyaltyCustomerMatchRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLoyaltyCustomer(LoyaltyCustomer.newBuilder().build())
           .build();
   ManageLoyaltyCustomerMatchResponse response =
       loyaltyCustomerMatchServiceClient.manageLoyaltyCustomerMatch(request);
 }
 

Note: close() needs to be called on the LoyaltyCustomerMatchServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

ManageLoyaltyCustomerMatch

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.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • manageLoyaltyCustomerMatch(ManageLoyaltyCustomerMatchRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • manageLoyaltyCustomerMatchCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of LoyaltyCustomerMatchServiceSettings to create(). For example:

To customize credentials:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoyaltyCustomerMatchServiceSettings loyaltyCustomerMatchServiceSettings =
     LoyaltyCustomerMatchServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create(loyaltyCustomerMatchServiceSettings);
 

To customize the endpoint:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoyaltyCustomerMatchServiceSettings loyaltyCustomerMatchServiceSettings =
     LoyaltyCustomerMatchServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
 LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create(loyaltyCustomerMatchServiceSettings);
 

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 LoyaltyCustomerMatchServiceSettings loyaltyCustomerMatchServiceSettings =
     LoyaltyCustomerMatchServiceSettings.newHttpJsonBuilder().build();
 LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create(loyaltyCustomerMatchServiceSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > LoyaltyCustomerMatchServiceClient

Static Methods

create()

public static final LoyaltyCustomerMatchServiceClient create()

Constructs an instance of LoyaltyCustomerMatchServiceClient with default settings.

Returns
Type Description
LoyaltyCustomerMatchServiceClient
Exceptions
Type Description
IOException

create(LoyaltyCustomerMatchServiceSettings settings)

public static final LoyaltyCustomerMatchServiceClient create(LoyaltyCustomerMatchServiceSettings settings)

Constructs an instance of LoyaltyCustomerMatchServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings LoyaltyCustomerMatchServiceSettings
Returns
Type Description
LoyaltyCustomerMatchServiceClient
Exceptions
Type Description
IOException

create(LoyaltyCustomerMatchServiceStub stub)

public static final LoyaltyCustomerMatchServiceClient create(LoyaltyCustomerMatchServiceStub stub)

Constructs an instance of LoyaltyCustomerMatchServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(LoyaltyCustomerMatchServiceSettings).

Parameter
Name Description
stub LoyaltyCustomerMatchServiceStub
Returns
Type Description
LoyaltyCustomerMatchServiceClient

Constructors

LoyaltyCustomerMatchServiceClient(LoyaltyCustomerMatchServiceSettings settings)

protected LoyaltyCustomerMatchServiceClient(LoyaltyCustomerMatchServiceSettings settings)

Constructs an instance of LoyaltyCustomerMatchServiceClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings LoyaltyCustomerMatchServiceSettings

LoyaltyCustomerMatchServiceClient(LoyaltyCustomerMatchServiceStub stub)

protected LoyaltyCustomerMatchServiceClient(LoyaltyCustomerMatchServiceStub stub)
Parameter
Name Description
stub LoyaltyCustomerMatchServiceStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

getSettings()

public final @Nullable LoyaltyCustomerMatchServiceSettings getSettings()
Returns
Type Description
@org.jspecify.annotations.Nullable com.google.shopping.merchant.loyaltycustomers.v1.LoyaltyCustomerMatchServiceSettings

getStub()

public LoyaltyCustomerMatchServiceStub getStub()
Returns
Type Description
LoyaltyCustomerMatchServiceStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

manageLoyaltyCustomerMatch(ManageLoyaltyCustomerMatchRequest request)

public final ManageLoyaltyCustomerMatchResponse manageLoyaltyCustomerMatch(ManageLoyaltyCustomerMatchRequest request)

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.

Sample code:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create()) {
   ManageLoyaltyCustomerMatchRequest request =
       ManageLoyaltyCustomerMatchRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLoyaltyCustomer(LoyaltyCustomer.newBuilder().build())
           .build();
   ManageLoyaltyCustomerMatchResponse response =
       loyaltyCustomerMatchServiceClient.manageLoyaltyCustomerMatch(request);
 }
 
Parameter
Name Description
request ManageLoyaltyCustomerMatchRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ManageLoyaltyCustomerMatchResponse

manageLoyaltyCustomerMatchCallable()

public final UnaryCallable<ManageLoyaltyCustomerMatchRequest,ManageLoyaltyCustomerMatchResponse> manageLoyaltyCustomerMatchCallable()

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.

Sample code:


 // 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.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (LoyaltyCustomerMatchServiceClient loyaltyCustomerMatchServiceClient =
     LoyaltyCustomerMatchServiceClient.create()) {
   ManageLoyaltyCustomerMatchRequest request =
       ManageLoyaltyCustomerMatchRequest.newBuilder()
           .setParent(AccountName.of("[ACCOUNT]").toString())
           .setLoyaltyCustomer(LoyaltyCustomer.newBuilder().build())
           .build();
   ApiFuture<ManageLoyaltyCustomerMatchResponse> future =
       loyaltyCustomerMatchServiceClient
           .manageLoyaltyCustomerMatchCallable()
           .futureCall(request);
   // Do something.
   ManageLoyaltyCustomerMatchResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ManageLoyaltyCustomerMatchRequest,ManageLoyaltyCustomerMatchResponse>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()