Module: Google::Shopping::Merchant::DataSources

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

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

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

Create a new client object for DataSourcesService.

By default, this returns an instance of Google::Shopping::Merchant::DataSources::V1beta::DataSourcesService::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 DataSourcesService 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 DataSourcesService service. You can determine whether the method will succeed by calling data_sources_service_available?.

About DataSourcesService

Service to manage primary, supplemental, inventory and other data sources. See more in the Merchant Center help article.

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.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/google/shopping/merchant/data_sources.rb', line 60

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

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

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

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



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

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

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

Create a new client object for FileUploadsService.

By default, this returns an instance of Google::Shopping::Merchant::DataSources::V1beta::FileUploadsService::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 FileUploadsService 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 FileUploadsService service. You can determine whether the method will succeed by calling file_uploads_service_available?.

About FileUploadsService

Service to manage data source file uploads.

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.



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

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

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

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

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



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

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