Module: Google::Shopping::Merchant::LoyaltyCustomers

Defined in:
lib/google/shopping/merchant/loyalty_customers.rb,
lib/google/shopping/merchant/loyalty_customers/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.loyalty_customer_match_service(version: :v1, transport: :grpc, &block) ⇒ ::Object

Create a new client object for LoyaltyCustomerMatchService.

By default, this returns an instance of Google::Shopping::Merchant::LoyaltyCustomers::V1::LoyaltyCustomerMatchService::Client for a gRPC client for version V1 of the API. However, you can specify a different API version by passing it in the version parameter. If the LoyaltyCustomerMatchService service is supported by that API version, and the corresponding gem is available, the appropriate versioned client will be returned. You can also specify a different transport by passing :rest or :grpc in the transport parameter.

Raises an exception if the currently installed versioned client gem for the given API version does not support the given transport of the LoyaltyCustomerMatchService service. You can determine whether the method will succeed by calling loyalty_customer_match_service_available?.

About LoyaltyCustomerMatchService

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.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1) —

    The API version to connect to. Optional. Defaults to :v1.

  • transport (:grpc, :rest) (defaults to: :grpc) —

    The transport to use. Defaults to :grpc.

Returns:

  • (::Object) —

    A client object for the specified version.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/google/shopping/merchant/loyalty_customers.rb', line 71

def self.loyalty_customer_match_service version: :v1, transport: :grpc, &block
  require "google/shopping/merchant/loyalty_customers/#{version.to_s.downcase}"

  package_name = Google::Shopping::Merchant::LoyaltyCustomers
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  service_module = Google::Shopping::Merchant::LoyaltyCustomers.const_get(package_name).const_get(:LoyaltyCustomerMatchService)
  service_module = service_module.const_get(:Rest) if transport == :rest
  service_module.const_get(:Client).new(&block)
end

.loyalty_customer_match_service_available?(version: :v1, transport: :grpc) ⇒ boolean

Determines whether the LoyaltyCustomerMatchService service is supported by the current client. If true, you can retrieve a client object by calling loyalty_customer_match_service. If false, that method will raise an exception. This could happen if the given API version does not exist or does not support the LoyaltyCustomerMatchService service, or if the versioned client gem needs an update to support the LoyaltyCustomerMatchService service.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1) —

    The API version to connect to. Optional. Defaults to :v1.

  • transport (:grpc, :rest) (defaults to: :grpc) —

    The transport to use. Defaults to :grpc.

Returns:

  • (boolean) —

    Whether the service is available.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/google/shopping/merchant/loyalty_customers.rb', line 95

def self.loyalty_customer_match_service_available? version: :v1, transport: :grpc
  require "google/shopping/merchant/loyalty_customers/#{version.to_s.downcase}"
  package_name = Google::Shopping::Merchant::LoyaltyCustomers
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  return false unless package_name
  service_module = Google::Shopping::Merchant::LoyaltyCustomers.const_get package_name
  return false unless service_module.const_defined? :LoyaltyCustomerMatchService
  service_module = service_module.const_get :LoyaltyCustomerMatchService
  if transport == :rest
    return false unless service_module.const_defined? :Rest
    service_module = service_module.const_get :Rest
  end
  service_module.const_defined? :Client
rescue ::LoadError
  false
end