google-shopping-merchant-promotions-v1beta 0.a → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +122 -0
- data/README.md +144 -8
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_common_pb.rb +62 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_pb.rb +57 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/client.rb +642 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/credentials.rb +49 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/paths.rb +52 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/rest/client.rb +595 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/rest/service_stub.rb +249 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service/rest.rb +54 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_service.rb +57 -0
- data/lib/google/shopping/merchant/promotions/v1beta/promotions_services_pb.rb +60 -0
- data/lib/google/shopping/merchant/promotions/v1beta/rest.rb +39 -0
- data/lib/google/shopping/merchant/promotions/v1beta/version.rb +7 -2
- data/lib/google/shopping/merchant/promotions/v1beta.rb +47 -0
- data/lib/google-shopping-merchant-promotions-v1beta.rb +21 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/client.rb +399 -0
- data/proto_docs/google/api/field_behavior.rb +85 -0
- data/proto_docs/google/api/launch_stage.rb +71 -0
- data/proto_docs/google/api/resource.rb +222 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/timestamp.rb +127 -0
- data/proto_docs/google/shopping/merchant/promotions/v1beta/promotions.rb +176 -0
- data/proto_docs/google/shopping/merchant/promotions/v1beta/promotions_common.rb +445 -0
- data/proto_docs/google/shopping/type/types.rb +210 -0
- data/proto_docs/google/type/interval.rb +45 -0
- metadata +89 -10
@@ -0,0 +1,642 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2024 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
|
+
|
19
|
+
require "google/cloud/errors"
|
20
|
+
require "google/shopping/merchant/promotions/v1beta/promotions_pb"
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Shopping
|
24
|
+
module Merchant
|
25
|
+
module Promotions
|
26
|
+
module V1beta
|
27
|
+
module PromotionsService
|
28
|
+
##
|
29
|
+
# Client for the PromotionsService service.
|
30
|
+
#
|
31
|
+
# Service to manage promotions for products.
|
32
|
+
#
|
33
|
+
class Client
|
34
|
+
# @private
|
35
|
+
API_VERSION = ""
|
36
|
+
|
37
|
+
# @private
|
38
|
+
DEFAULT_ENDPOINT_TEMPLATE = "merchantapi.$UNIVERSE_DOMAIN$"
|
39
|
+
|
40
|
+
include Paths
|
41
|
+
|
42
|
+
# @private
|
43
|
+
attr_reader :promotions_service_stub
|
44
|
+
|
45
|
+
##
|
46
|
+
# Configure the PromotionsService Client class.
|
47
|
+
#
|
48
|
+
# See {::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client::Configuration}
|
49
|
+
# for a description of the configuration fields.
|
50
|
+
#
|
51
|
+
# @example
|
52
|
+
#
|
53
|
+
# # Modify the configuration for all PromotionsService clients
|
54
|
+
# ::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.configure do |config|
|
55
|
+
# config.timeout = 10.0
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# @yield [config] Configure the Client client.
|
59
|
+
# @yieldparam config [Client::Configuration]
|
60
|
+
#
|
61
|
+
# @return [Client::Configuration]
|
62
|
+
#
|
63
|
+
def self.configure
|
64
|
+
@configure ||= begin
|
65
|
+
namespace = ["Google", "Shopping", "Merchant", "Promotions", "V1beta"]
|
66
|
+
parent_config = while namespace.any?
|
67
|
+
parent_name = namespace.join "::"
|
68
|
+
parent_const = const_get parent_name
|
69
|
+
break parent_const.configure if parent_const.respond_to? :configure
|
70
|
+
namespace.pop
|
71
|
+
end
|
72
|
+
default_config = Client::Configuration.new parent_config
|
73
|
+
|
74
|
+
default_config.timeout = 60.0
|
75
|
+
default_config.retry_policy = {
|
76
|
+
initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
|
77
|
+
}
|
78
|
+
|
79
|
+
default_config
|
80
|
+
end
|
81
|
+
yield @configure if block_given?
|
82
|
+
@configure
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Configure the PromotionsService Client instance.
|
87
|
+
#
|
88
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
89
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
90
|
+
# should be made on {Client.configure}.
|
91
|
+
#
|
92
|
+
# See {::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client::Configuration}
|
93
|
+
# for a description of the configuration fields.
|
94
|
+
#
|
95
|
+
# @yield [config] Configure the Client client.
|
96
|
+
# @yieldparam config [Client::Configuration]
|
97
|
+
#
|
98
|
+
# @return [Client::Configuration]
|
99
|
+
#
|
100
|
+
def configure
|
101
|
+
yield @config if block_given?
|
102
|
+
@config
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# The effective universe domain
|
107
|
+
#
|
108
|
+
# @return [String]
|
109
|
+
#
|
110
|
+
def universe_domain
|
111
|
+
@promotions_service_stub.universe_domain
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Create a new PromotionsService client object.
|
116
|
+
#
|
117
|
+
# @example
|
118
|
+
#
|
119
|
+
# # Create a client using the default configuration
|
120
|
+
# client = ::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new
|
121
|
+
#
|
122
|
+
# # Create a client using a custom configuration
|
123
|
+
# client = ::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new do |config|
|
124
|
+
# config.timeout = 10.0
|
125
|
+
# end
|
126
|
+
#
|
127
|
+
# @yield [config] Configure the PromotionsService client.
|
128
|
+
# @yieldparam config [Client::Configuration]
|
129
|
+
#
|
130
|
+
def initialize
|
131
|
+
# These require statements are intentionally placed here to initialize
|
132
|
+
# the gRPC module only when it's required.
|
133
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
134
|
+
require "gapic/grpc"
|
135
|
+
require "google/shopping/merchant/promotions/v1beta/promotions_services_pb"
|
136
|
+
|
137
|
+
# Create the configuration object
|
138
|
+
@config = Configuration.new Client.configure
|
139
|
+
|
140
|
+
# Yield the configuration if needed
|
141
|
+
yield @config if block_given?
|
142
|
+
|
143
|
+
# Create credentials
|
144
|
+
credentials = @config.credentials
|
145
|
+
# Use self-signed JWT if the endpoint is unchanged from default,
|
146
|
+
# but only if the default endpoint does not have a region prefix.
|
147
|
+
enable_self_signed_jwt = @config.endpoint.nil? ||
|
148
|
+
(@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
|
149
|
+
!@config.endpoint.split(".").first.include?("-"))
|
150
|
+
credentials ||= Credentials.default scope: @config.scope,
|
151
|
+
enable_self_signed_jwt: enable_self_signed_jwt
|
152
|
+
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
|
153
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
154
|
+
end
|
155
|
+
@quota_project_id = @config.quota_project
|
156
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
157
|
+
|
158
|
+
@promotions_service_stub = ::Gapic::ServiceStub.new(
|
159
|
+
::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Stub,
|
160
|
+
credentials: credentials,
|
161
|
+
endpoint: @config.endpoint,
|
162
|
+
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
163
|
+
universe_domain: @config.universe_domain,
|
164
|
+
channel_args: @config.channel_args,
|
165
|
+
interceptors: @config.interceptors,
|
166
|
+
channel_pool_config: @config.channel_pool
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Service calls
|
171
|
+
|
172
|
+
##
|
173
|
+
# Inserts a promotion for your Merchant Center account. If the promotion
|
174
|
+
# already exists, then it updates the promotion instead.
|
175
|
+
#
|
176
|
+
# @overload insert_promotion(request, options = nil)
|
177
|
+
# Pass arguments to `insert_promotion` via a request object, either of type
|
178
|
+
# {::Google::Shopping::Merchant::Promotions::V1beta::InsertPromotionRequest} or an equivalent Hash.
|
179
|
+
#
|
180
|
+
# @param request [::Google::Shopping::Merchant::Promotions::V1beta::InsertPromotionRequest, ::Hash]
|
181
|
+
# A request object representing the call parameters. Required. To specify no
|
182
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
183
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
184
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
185
|
+
#
|
186
|
+
# @overload insert_promotion(parent: nil, promotion: nil, data_source: nil)
|
187
|
+
# Pass arguments to `insert_promotion` via keyword arguments. Note that at
|
188
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
189
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
190
|
+
#
|
191
|
+
# @param parent [::String]
|
192
|
+
# Required. The account where the promotion will be inserted.
|
193
|
+
# Format: accounts/\\{account}
|
194
|
+
# @param promotion [::Google::Shopping::Merchant::Promotions::V1beta::Promotion, ::Hash]
|
195
|
+
# Required. The promotion to insert.
|
196
|
+
# @param data_source [::String]
|
197
|
+
# Required. The data source of the
|
198
|
+
# [promotion](https://support.google.com/merchants/answer/6396268?sjid=5155774230887277618-NC)
|
199
|
+
# Format:
|
200
|
+
# `accounts/{account}/dataSources/{datasource}`.
|
201
|
+
#
|
202
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
203
|
+
# @yieldparam response [::Google::Shopping::Merchant::Promotions::V1beta::Promotion]
|
204
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
205
|
+
#
|
206
|
+
# @return [::Google::Shopping::Merchant::Promotions::V1beta::Promotion]
|
207
|
+
#
|
208
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
209
|
+
#
|
210
|
+
# @example Basic example
|
211
|
+
# require "google/shopping/merchant/promotions/v1beta"
|
212
|
+
#
|
213
|
+
# # Create a client object. The client can be reused for multiple calls.
|
214
|
+
# client = Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new
|
215
|
+
#
|
216
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
217
|
+
# request = Google::Shopping::Merchant::Promotions::V1beta::InsertPromotionRequest.new
|
218
|
+
#
|
219
|
+
# # Call the insert_promotion method.
|
220
|
+
# result = client.insert_promotion request
|
221
|
+
#
|
222
|
+
# # The returned object is of type Google::Shopping::Merchant::Promotions::V1beta::Promotion.
|
223
|
+
# p result
|
224
|
+
#
|
225
|
+
def insert_promotion request, options = nil
|
226
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
227
|
+
|
228
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1beta::InsertPromotionRequest
|
229
|
+
|
230
|
+
# Converts hash and nil to an options object
|
231
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
232
|
+
|
233
|
+
# Customize the options with defaults
|
234
|
+
metadata = @config.rpcs.insert_promotion.metadata.to_h
|
235
|
+
|
236
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
237
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
238
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
239
|
+
gapic_version: ::Google::Shopping::Merchant::Promotions::V1beta::VERSION
|
240
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
241
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
242
|
+
|
243
|
+
header_params = {}
|
244
|
+
if request.parent
|
245
|
+
header_params["parent"] = request.parent
|
246
|
+
end
|
247
|
+
|
248
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
249
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
250
|
+
|
251
|
+
options.apply_defaults timeout: @config.rpcs.insert_promotion.timeout,
|
252
|
+
metadata: metadata,
|
253
|
+
retry_policy: @config.rpcs.insert_promotion.retry_policy
|
254
|
+
|
255
|
+
options.apply_defaults timeout: @config.timeout,
|
256
|
+
metadata: @config.metadata,
|
257
|
+
retry_policy: @config.retry_policy
|
258
|
+
|
259
|
+
@promotions_service_stub.call_rpc :insert_promotion, request, options: options do |response, operation|
|
260
|
+
yield response, operation if block_given?
|
261
|
+
return response
|
262
|
+
end
|
263
|
+
rescue ::GRPC::BadStatus => e
|
264
|
+
raise ::Google::Cloud::Error.from_error(e)
|
265
|
+
end
|
266
|
+
|
267
|
+
##
|
268
|
+
# Retrieves the promotion from your Merchant Center account.
|
269
|
+
#
|
270
|
+
# After inserting or updating a promotion input, it may take several
|
271
|
+
# minutes before the updated promotion can be retrieved.
|
272
|
+
#
|
273
|
+
# @overload get_promotion(request, options = nil)
|
274
|
+
# Pass arguments to `get_promotion` via a request object, either of type
|
275
|
+
# {::Google::Shopping::Merchant::Promotions::V1beta::GetPromotionRequest} or an equivalent Hash.
|
276
|
+
#
|
277
|
+
# @param request [::Google::Shopping::Merchant::Promotions::V1beta::GetPromotionRequest, ::Hash]
|
278
|
+
# A request object representing the call parameters. Required. To specify no
|
279
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
280
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
281
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
282
|
+
#
|
283
|
+
# @overload get_promotion(name: nil)
|
284
|
+
# Pass arguments to `get_promotion` via keyword arguments. Note that at
|
285
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
286
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
287
|
+
#
|
288
|
+
# @param name [::String]
|
289
|
+
# Required. The name of the promotion to retrieve.
|
290
|
+
# Format: `accounts/{account}/promotions/{promotions}`
|
291
|
+
#
|
292
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
293
|
+
# @yieldparam response [::Google::Shopping::Merchant::Promotions::V1beta::Promotion]
|
294
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
295
|
+
#
|
296
|
+
# @return [::Google::Shopping::Merchant::Promotions::V1beta::Promotion]
|
297
|
+
#
|
298
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
299
|
+
#
|
300
|
+
# @example Basic example
|
301
|
+
# require "google/shopping/merchant/promotions/v1beta"
|
302
|
+
#
|
303
|
+
# # Create a client object. The client can be reused for multiple calls.
|
304
|
+
# client = Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new
|
305
|
+
#
|
306
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
307
|
+
# request = Google::Shopping::Merchant::Promotions::V1beta::GetPromotionRequest.new
|
308
|
+
#
|
309
|
+
# # Call the get_promotion method.
|
310
|
+
# result = client.get_promotion request
|
311
|
+
#
|
312
|
+
# # The returned object is of type Google::Shopping::Merchant::Promotions::V1beta::Promotion.
|
313
|
+
# p result
|
314
|
+
#
|
315
|
+
def get_promotion request, options = nil
|
316
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
317
|
+
|
318
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1beta::GetPromotionRequest
|
319
|
+
|
320
|
+
# Converts hash and nil to an options object
|
321
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
322
|
+
|
323
|
+
# Customize the options with defaults
|
324
|
+
metadata = @config.rpcs.get_promotion.metadata.to_h
|
325
|
+
|
326
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
327
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
328
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
329
|
+
gapic_version: ::Google::Shopping::Merchant::Promotions::V1beta::VERSION
|
330
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
331
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
332
|
+
|
333
|
+
header_params = {}
|
334
|
+
if request.name
|
335
|
+
header_params["name"] = request.name
|
336
|
+
end
|
337
|
+
|
338
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
339
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
340
|
+
|
341
|
+
options.apply_defaults timeout: @config.rpcs.get_promotion.timeout,
|
342
|
+
metadata: metadata,
|
343
|
+
retry_policy: @config.rpcs.get_promotion.retry_policy
|
344
|
+
|
345
|
+
options.apply_defaults timeout: @config.timeout,
|
346
|
+
metadata: @config.metadata,
|
347
|
+
retry_policy: @config.retry_policy
|
348
|
+
|
349
|
+
@promotions_service_stub.call_rpc :get_promotion, request, options: options do |response, operation|
|
350
|
+
yield response, operation if block_given?
|
351
|
+
return response
|
352
|
+
end
|
353
|
+
rescue ::GRPC::BadStatus => e
|
354
|
+
raise ::Google::Cloud::Error.from_error(e)
|
355
|
+
end
|
356
|
+
|
357
|
+
##
|
358
|
+
# Lists the promotions in your Merchant Center account. The
|
359
|
+
# response might contain fewer items than specified by `pageSize`. Rely on
|
360
|
+
# `pageToken` to determine if there are more items to be requested.
|
361
|
+
#
|
362
|
+
# After inserting or updating a promotion, it may take several minutes before
|
363
|
+
# the updated processed promotion can be retrieved.
|
364
|
+
#
|
365
|
+
# @overload list_promotions(request, options = nil)
|
366
|
+
# Pass arguments to `list_promotions` via a request object, either of type
|
367
|
+
# {::Google::Shopping::Merchant::Promotions::V1beta::ListPromotionsRequest} or an equivalent Hash.
|
368
|
+
#
|
369
|
+
# @param request [::Google::Shopping::Merchant::Promotions::V1beta::ListPromotionsRequest, ::Hash]
|
370
|
+
# A request object representing the call parameters. Required. To specify no
|
371
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
372
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
373
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
374
|
+
#
|
375
|
+
# @overload list_promotions(parent: nil)
|
376
|
+
# Pass arguments to `list_promotions` via keyword arguments. Note that at
|
377
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
378
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
379
|
+
#
|
380
|
+
# @param parent [::String]
|
381
|
+
# Required. The account to list processed promotions for.
|
382
|
+
# Format: `accounts/{account}`
|
383
|
+
#
|
384
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
385
|
+
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Promotions::V1beta::Promotion>]
|
386
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
387
|
+
#
|
388
|
+
# @return [::Gapic::PagedEnumerable<::Google::Shopping::Merchant::Promotions::V1beta::Promotion>]
|
389
|
+
#
|
390
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
391
|
+
#
|
392
|
+
# @example Basic example
|
393
|
+
# require "google/shopping/merchant/promotions/v1beta"
|
394
|
+
#
|
395
|
+
# # Create a client object. The client can be reused for multiple calls.
|
396
|
+
# client = Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new
|
397
|
+
#
|
398
|
+
# # Create a request. To set request fields, pass in keyword arguments.
|
399
|
+
# request = Google::Shopping::Merchant::Promotions::V1beta::ListPromotionsRequest.new
|
400
|
+
#
|
401
|
+
# # Call the list_promotions method.
|
402
|
+
# result = client.list_promotions request
|
403
|
+
#
|
404
|
+
# # The returned object is of type Gapic::PagedEnumerable. You can iterate
|
405
|
+
# # over elements, and API calls will be issued to fetch pages as needed.
|
406
|
+
# result.each do |item|
|
407
|
+
# # Each element is of type ::Google::Shopping::Merchant::Promotions::V1beta::Promotion.
|
408
|
+
# p item
|
409
|
+
# end
|
410
|
+
#
|
411
|
+
def list_promotions request, options = nil
|
412
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
413
|
+
|
414
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1beta::ListPromotionsRequest
|
415
|
+
|
416
|
+
# Converts hash and nil to an options object
|
417
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
418
|
+
|
419
|
+
# Customize the options with defaults
|
420
|
+
metadata = @config.rpcs.list_promotions.metadata.to_h
|
421
|
+
|
422
|
+
# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
|
423
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
424
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
425
|
+
gapic_version: ::Google::Shopping::Merchant::Promotions::V1beta::VERSION
|
426
|
+
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
|
427
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
428
|
+
|
429
|
+
header_params = {}
|
430
|
+
if request.parent
|
431
|
+
header_params["parent"] = request.parent
|
432
|
+
end
|
433
|
+
|
434
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
435
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
436
|
+
|
437
|
+
options.apply_defaults timeout: @config.rpcs.list_promotions.timeout,
|
438
|
+
metadata: metadata,
|
439
|
+
retry_policy: @config.rpcs.list_promotions.retry_policy
|
440
|
+
|
441
|
+
options.apply_defaults timeout: @config.timeout,
|
442
|
+
metadata: @config.metadata,
|
443
|
+
retry_policy: @config.retry_policy
|
444
|
+
|
445
|
+
@promotions_service_stub.call_rpc :list_promotions, request, options: options do |response, operation|
|
446
|
+
response = ::Gapic::PagedEnumerable.new @promotions_service_stub, :list_promotions, request, response, operation, options
|
447
|
+
yield response, operation if block_given?
|
448
|
+
return response
|
449
|
+
end
|
450
|
+
rescue ::GRPC::BadStatus => e
|
451
|
+
raise ::Google::Cloud::Error.from_error(e)
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# Configuration class for the PromotionsService API.
|
456
|
+
#
|
457
|
+
# This class represents the configuration for PromotionsService,
|
458
|
+
# providing control over timeouts, retry behavior, logging, transport
|
459
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
460
|
+
# applied individually to specific RPCs. See
|
461
|
+
# {::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client::Configuration::Rpcs}
|
462
|
+
# for a list of RPCs that can be configured independently.
|
463
|
+
#
|
464
|
+
# Configuration can be applied globally to all clients, or to a single client
|
465
|
+
# on construction.
|
466
|
+
#
|
467
|
+
# @example
|
468
|
+
#
|
469
|
+
# # Modify the global config, setting the timeout for
|
470
|
+
# # insert_promotion to 20 seconds,
|
471
|
+
# # and all remaining timeouts to 10 seconds.
|
472
|
+
# ::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.configure do |config|
|
473
|
+
# config.timeout = 10.0
|
474
|
+
# config.rpcs.insert_promotion.timeout = 20.0
|
475
|
+
# end
|
476
|
+
#
|
477
|
+
# # Apply the above configuration only to a new client.
|
478
|
+
# client = ::Google::Shopping::Merchant::Promotions::V1beta::PromotionsService::Client.new do |config|
|
479
|
+
# config.timeout = 10.0
|
480
|
+
# config.rpcs.insert_promotion.timeout = 20.0
|
481
|
+
# end
|
482
|
+
#
|
483
|
+
# @!attribute [rw] endpoint
|
484
|
+
# A custom service endpoint, as a hostname or hostname:port. The default is
|
485
|
+
# nil, indicating to use the default endpoint in the current universe domain.
|
486
|
+
# @return [::String,nil]
|
487
|
+
# @!attribute [rw] credentials
|
488
|
+
# Credentials to send with calls. You may provide any of the following types:
|
489
|
+
# * (`String`) The path to a service account key file in JSON format
|
490
|
+
# * (`Hash`) A service account key as a Hash
|
491
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
492
|
+
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
|
493
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
494
|
+
# (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
|
495
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
496
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
497
|
+
# * (`nil`) indicating no credentials
|
498
|
+
# @return [::Object]
|
499
|
+
# @!attribute [rw] scope
|
500
|
+
# The OAuth scopes
|
501
|
+
# @return [::Array<::String>]
|
502
|
+
# @!attribute [rw] lib_name
|
503
|
+
# The library name as recorded in instrumentation and logging
|
504
|
+
# @return [::String]
|
505
|
+
# @!attribute [rw] lib_version
|
506
|
+
# The library version as recorded in instrumentation and logging
|
507
|
+
# @return [::String]
|
508
|
+
# @!attribute [rw] channel_args
|
509
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
510
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
511
|
+
# @return [::Hash]
|
512
|
+
# @!attribute [rw] interceptors
|
513
|
+
# An array of interceptors that are run before calls are executed.
|
514
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
515
|
+
# @!attribute [rw] timeout
|
516
|
+
# The call timeout in seconds.
|
517
|
+
# @return [::Numeric]
|
518
|
+
# @!attribute [rw] metadata
|
519
|
+
# Additional gRPC headers to be sent with the call.
|
520
|
+
# @return [::Hash{::Symbol=>::String}]
|
521
|
+
# @!attribute [rw] retry_policy
|
522
|
+
# The retry policy. The value is a hash with the following keys:
|
523
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
524
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
525
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
526
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
527
|
+
# trigger a retry.
|
528
|
+
# @return [::Hash]
|
529
|
+
# @!attribute [rw] quota_project
|
530
|
+
# A separate project against which to charge quota.
|
531
|
+
# @return [::String]
|
532
|
+
# @!attribute [rw] universe_domain
|
533
|
+
# The universe domain within which to make requests. This determines the
|
534
|
+
# default endpoint URL. The default value of nil uses the environment
|
535
|
+
# universe (usually the default "googleapis.com" universe).
|
536
|
+
# @return [::String,nil]
|
537
|
+
#
|
538
|
+
class Configuration
|
539
|
+
extend ::Gapic::Config
|
540
|
+
|
541
|
+
# @private
|
542
|
+
# The endpoint specific to the default "googleapis.com" universe. Deprecated.
|
543
|
+
DEFAULT_ENDPOINT = "merchantapi.googleapis.com"
|
544
|
+
|
545
|
+
config_attr :endpoint, nil, ::String, nil
|
546
|
+
config_attr :credentials, nil do |value|
|
547
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
548
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
549
|
+
allowed.any? { |klass| klass === value }
|
550
|
+
end
|
551
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
552
|
+
config_attr :lib_name, nil, ::String, nil
|
553
|
+
config_attr :lib_version, nil, ::String, nil
|
554
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
|
555
|
+
config_attr :interceptors, nil, ::Array, nil
|
556
|
+
config_attr :timeout, nil, ::Numeric, nil
|
557
|
+
config_attr :metadata, nil, ::Hash, nil
|
558
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
559
|
+
config_attr :quota_project, nil, ::String, nil
|
560
|
+
config_attr :universe_domain, nil, ::String, nil
|
561
|
+
|
562
|
+
# @private
|
563
|
+
def initialize parent_config = nil
|
564
|
+
@parent_config = parent_config unless parent_config.nil?
|
565
|
+
|
566
|
+
yield self if block_given?
|
567
|
+
end
|
568
|
+
|
569
|
+
##
|
570
|
+
# Configurations for individual RPCs
|
571
|
+
# @return [Rpcs]
|
572
|
+
#
|
573
|
+
def rpcs
|
574
|
+
@rpcs ||= begin
|
575
|
+
parent_rpcs = nil
|
576
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
|
577
|
+
Rpcs.new parent_rpcs
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
##
|
582
|
+
# Configuration for the channel pool
|
583
|
+
# @return [::Gapic::ServiceStub::ChannelPool::Configuration]
|
584
|
+
#
|
585
|
+
def channel_pool
|
586
|
+
@channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
|
587
|
+
end
|
588
|
+
|
589
|
+
##
|
590
|
+
# Configuration RPC class for the PromotionsService API.
|
591
|
+
#
|
592
|
+
# Includes fields providing the configuration for each RPC in this service.
|
593
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
594
|
+
# the following configuration fields:
|
595
|
+
#
|
596
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in seconds
|
597
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
598
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
599
|
+
# include the following keys:
|
600
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
601
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
602
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
603
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
604
|
+
# trigger a retry.
|
605
|
+
#
|
606
|
+
class Rpcs
|
607
|
+
##
|
608
|
+
# RPC-specific configuration for `insert_promotion`
|
609
|
+
# @return [::Gapic::Config::Method]
|
610
|
+
#
|
611
|
+
attr_reader :insert_promotion
|
612
|
+
##
|
613
|
+
# RPC-specific configuration for `get_promotion`
|
614
|
+
# @return [::Gapic::Config::Method]
|
615
|
+
#
|
616
|
+
attr_reader :get_promotion
|
617
|
+
##
|
618
|
+
# RPC-specific configuration for `list_promotions`
|
619
|
+
# @return [::Gapic::Config::Method]
|
620
|
+
#
|
621
|
+
attr_reader :list_promotions
|
622
|
+
|
623
|
+
# @private
|
624
|
+
def initialize parent_rpcs = nil
|
625
|
+
insert_promotion_config = parent_rpcs.insert_promotion if parent_rpcs.respond_to? :insert_promotion
|
626
|
+
@insert_promotion = ::Gapic::Config::Method.new insert_promotion_config
|
627
|
+
get_promotion_config = parent_rpcs.get_promotion if parent_rpcs.respond_to? :get_promotion
|
628
|
+
@get_promotion = ::Gapic::Config::Method.new get_promotion_config
|
629
|
+
list_promotions_config = parent_rpcs.list_promotions if parent_rpcs.respond_to? :list_promotions
|
630
|
+
@list_promotions = ::Gapic::Config::Method.new list_promotions_config
|
631
|
+
|
632
|
+
yield self if block_given?
|
633
|
+
end
|
634
|
+
end
|
635
|
+
end
|
636
|
+
end
|
637
|
+
end
|
638
|
+
end
|
639
|
+
end
|
640
|
+
end
|
641
|
+
end
|
642
|
+
end
|