Module: Google::Shopping::Merchant::Inventories

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

Constant Summary collapse

VERSION =
"0.4.1"

Class Method Summary collapse

Class Method Details

.local_inventory_service(version: :v1beta, transport: :grpc, &block) ⇒ ::Object

Create a new client object for LocalInventoryService.

By default, this returns an instance of Google::Shopping::Merchant::Inventories::V1beta::LocalInventoryService::Client for a gRPC client for version V1beta of the API. However, you can specify a different API version by passing it in the version parameter. If the LocalInventoryService 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 LocalInventoryService service. You can determine whether the method will succeed by calling local_inventory_service_available?.

About LocalInventoryService

Service to manage local inventory for products

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1beta)

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

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

    The transport to use. Defaults to :grpc.

Returns:

  • (::Object)

    A client object for the specified version.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/google/shopping/merchant/inventories.rb', line 58

def self.local_inventory_service version: :v1beta, transport: :grpc, &block
  require "google/shopping/merchant/inventories/#{version.to_s.downcase}"

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

.local_inventory_service_available?(version: :v1beta, transport: :grpc) ⇒ boolean

Determines whether the LocalInventoryService service is supported by the current client. If true, you can retrieve a client object by calling local_inventory_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 LocalInventoryService service, or if the versioned client gem needs an update to support the LocalInventoryService service.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1beta)

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

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

    The transport to use. Defaults to :grpc.

Returns:

  • (boolean)

    Whether the service is available.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/google/shopping/merchant/inventories.rb', line 82

def self.local_inventory_service_available? version: :v1beta, transport: :grpc
  require "google/shopping/merchant/inventories/#{version.to_s.downcase}"
  package_name = Google::Shopping::Merchant::Inventories
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  return false unless package_name
  service_module = Google::Shopping::Merchant::Inventories.const_get package_name
  return false unless service_module.const_defined? :LocalInventoryService
  service_module = service_module.const_get :LocalInventoryService
  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

.regional_inventory_service(version: :v1beta, transport: :grpc, &block) ⇒ ::Object

Create a new client object for RegionalInventoryService.

By default, this returns an instance of Google::Shopping::Merchant::Inventories::V1beta::RegionalInventoryService::Client for a gRPC client for version V1beta of the API. However, you can specify a different API version by passing it in the version parameter. If the RegionalInventoryService 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 RegionalInventoryService service. You can determine whether the method will succeed by calling regional_inventory_service_available?.

About RegionalInventoryService

Service to manage regional inventory for products. There is also separate regions resource and API to manage regions definitions.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1beta)

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

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

    The transport to use. Defaults to :grpc.

Returns:

  • (::Object)

    A client object for the specified version.



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/google/shopping/merchant/inventories.rb', line 129

def self.regional_inventory_service version: :v1beta, transport: :grpc, &block
  require "google/shopping/merchant/inventories/#{version.to_s.downcase}"

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

.regional_inventory_service_available?(version: :v1beta, transport: :grpc) ⇒ boolean

Determines whether the RegionalInventoryService service is supported by the current client. If true, you can retrieve a client object by calling regional_inventory_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 RegionalInventoryService service, or if the versioned client gem needs an update to support the RegionalInventoryService service.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1beta)

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

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

    The transport to use. Defaults to :grpc.

Returns:

  • (boolean)

    Whether the service is available.



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/google/shopping/merchant/inventories.rb', line 153

def self.regional_inventory_service_available? version: :v1beta, transport: :grpc
  require "google/shopping/merchant/inventories/#{version.to_s.downcase}"
  package_name = Google::Shopping::Merchant::Inventories
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  return false unless package_name
  service_module = Google::Shopping::Merchant::Inventories.const_get package_name
  return false unless service_module.const_defined? :RegionalInventoryService
  service_module = service_module.const_get :RegionalInventoryService
  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