Module: Google::Shopping::Merchant::Reports
- Defined in:
- lib/google/shopping/merchant/reports.rb,
lib/google/shopping/merchant/reports/version.rb
Constant Summary collapse
- VERSION =
"0.4.2"
Class Method Summary collapse
-
.report_service(version: :v1beta, transport: :grpc, &block) ⇒ ::Object
Create a new client object for ReportService.
-
.report_service_available?(version: :v1beta, transport: :grpc) ⇒ boolean
Determines whether the ReportService service is supported by the current client.
Class Method Details
.report_service(version: :v1beta, transport: :grpc, &block) ⇒ ::Object
Create a new client object for ReportService.
By default, this returns an instance of
Google::Shopping::Merchant::Reports::V1beta::ReportService::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 ReportService 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 ReportService service. You can determine whether the method will succeed by calling report_service_available?.
About ReportService
Service for retrieving reports and insights about your products, their performance, and their competitive environment on Google.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/google/shopping/merchant/reports.rb', line 59 def self.report_service version: :v1beta, transport: :grpc, &block require "google/shopping/merchant/reports/#{version.to_s.downcase}" package_name = Google::Shopping::Merchant::Reports .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first service_module = Google::Shopping::Merchant::Reports.const_get(package_name).const_get(:ReportService) service_module = service_module.const_get(:Rest) if transport == :rest service_module.const_get(:Client).new(&block) end |
.report_service_available?(version: :v1beta, transport: :grpc) ⇒ boolean
Determines whether the ReportService service is supported by the current client. If true, you can retrieve a client object by calling report_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 ReportService service, or if the versioned client gem needs an update to support the ReportService service.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/google/shopping/merchant/reports.rb', line 83 def self.report_service_available? version: :v1beta, transport: :grpc require "google/shopping/merchant/reports/#{version.to_s.downcase}" package_name = Google::Shopping::Merchant::Reports .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first return false unless package_name service_module = Google::Shopping::Merchant::Reports.const_get package_name return false unless service_module.const_defined? :ReportService service_module = service_module.const_get :ReportService 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 |