class Google::Shopping::Merchant::Promotions::V1::PromotionsService::Client
def insert_promotion request, options = nil
- Example: Basic example -
Raises:
-
(::Google::Cloud::Error)
- if the RPC is aborted.
Returns:
-
(::Google::Shopping::Merchant::Promotions::V1::Promotion)
-
Other tags:
- Yieldparam: operation -
Yieldparam: response -
Other tags:
- Yield: - Access the result along with the RPC operation
Parameters:
-
data_source
(::String
) -- -
promotion
(::Google::Shopping::Merchant::Promotions::V1::Promotion, ::Hash
) -- -
parent
(::String
) -- -
options
(::Gapic::CallOptions, ::Hash
) -- -
request
(::Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest, ::Hash
) --
Overloads:
-
insert_promotion(parent: nil, promotion: nil, data_source: nil)
-
insert_promotion(request, options = nil)
def insert_promotion request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Shopping::Merchant::Promotions::V1::InsertPromotionRequest # Converts hash and nil to an options object options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h # Customize the options with defaults metadata = @config.rpcs.insert_promotion.metadata.to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ lib_name: @config.lib_name, lib_version: @config.lib_version, gapic_version: ::Google::Shopping::Merchant::Promotions::V1::VERSION metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = {} if request.parent header_params["parent"] = request.parent end request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&") metadata[:"x-goog-request-params"] ||= request_params_header options.apply_defaults timeout: @config.rpcs.insert_promotion.timeout, metadata: metadata, retry_policy: @config.rpcs.insert_promotion.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @promotions_service_stub.call_rpc :insert_promotion, request, options: options do |response, operation| yield response, operation if block_given? end rescue ::GRPC::BadStatus => e raise ::Google::Cloud::Error.from_error(e) end