Cloud Commerce Consumer Procurement V1 API - Class Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client (v0.2.0)

Reference documentation and code samples for the Cloud Commerce Consumer Procurement V1 API class Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.

REST client for the ConsumerProcurementService service.

ConsumerProcurementService allows customers to make purchases of products served by the Cloud Commerce platform.

When purchases are made, the ConsumerProcurementService programs the appropriate backends, including both Google's own infrastructure, as well as third-party systems, and to enable billing setup for charging for the procured item.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the ConsumerProcurementService Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all ConsumerProcurementService clients
::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

def configure() { |config| ... } -> Client::Configuration

Configure the ConsumerProcurementService Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#get_order

def get_order(request, options = nil) -> ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order
def get_order(name: nil) -> ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order

Returns the requested Order resource.

Overloads
def get_order(request, options = nil) -> ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order
Pass arguments to get_order via a request object, either of type GetOrderRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def get_order(name: nil) -> ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order
Pass arguments to get_order via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameter
  • name (::String) — Required. The name of the order to retrieve.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/commerce/consumer/procurement/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Commerce::Consumer::Procurement::V1::GetOrderRequest.new

# Call the get_order method.
result = client.get_order request

# The returned object is of type Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
p result

#initialize

def initialize() { |config| ... } -> Client

Create a new ConsumerProcurementService REST client object.

Yields
  • (config) — Configure the ConsumerProcurementService client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new do |config|
  config.timeout = 10.0
end

#list_orders

def list_orders(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>
def list_orders(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>

Lists Order resources that the user has access to, within the scope of the parent resource.

Overloads
def list_orders(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>
Pass arguments to list_orders via a request object, either of type ListOrdersRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def list_orders(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Commerce::Consumer::Procurement::V1::Order>
Pass arguments to list_orders via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The parent resource to query for orders. This field has the form billingAccounts/{billing-account-id}.
  • page_size (::Integer) — The maximum number of entries requested. The default page size is 25 and the maximum page size is 200.
  • page_token (::String) — The token for fetching the next page.
  • filter (::String) — Filter that you can use to limit the list request.

    A query string that can match a selected set of attributes with string values. For example, display_name=abc. Supported query attributes are

    • display_name

    If the query contains special characters other than letters, underscore, or digits, the phrase must be quoted with double quotes. For example, display_name="foo:bar", where the display name needs to be quoted because it contains special character colon.

    Queries can be combined with OR, and NOT to form more complex queries. You can also group them to force a desired evaluation order. For example, display_name=abc OR display_name=def.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/commerce/consumer/procurement/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Commerce::Consumer::Procurement::V1::ListOrdersRequest.new

# Call the list_orders method.
result = client.list_orders request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Commerce::Consumer::Procurement::V1::Order.
  p item
end

#operations_client

def operations_client() -> ::Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Operations

Get the associated client for long-running operations.

#place_order

def place_order(request, options = nil) -> ::Gapic::Operation
def place_order(parent: nil, display_name: nil, line_item_info: nil, request_id: nil) -> ::Gapic::Operation

Creates a new Order.

This API only supports GCP spend-based committed use discounts specified by GCP documentation.

The returned long-running operation is in-progress until the backend completes the creation of the resource. Once completed, the order is in [OrderState.ORDER_STATE_ACTIVE][google.cloud.commerce.consumer.procurement.v1.OrderState.ORDER_STATE_ACTIVE]. In case of failure, the order resource will be removed.

Overloads
def place_order(request, options = nil) -> ::Gapic::Operation
Pass arguments to place_order via a request object, either of type PlaceOrderRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
  • options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
def place_order(parent: nil, display_name: nil, line_item_info: nil, request_id: nil) -> ::Gapic::Operation
Pass arguments to place_order via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).
Parameters
  • parent (::String) — Required. The resource name of the parent resource. This field has the form billingAccounts/{billing-account-id}.
  • display_name (::String) — Required. The user-specified name of the order being placed.
  • line_item_info (::Array<::Google::Cloud::Commerce::Consumer::Procurement::V1::LineItemInfo, ::Hash>) — Optional. Places order for offer. Required when an offer-based order is being placed.
  • request_id (::String) — Optional. A unique identifier for this request. The server will ignore subsequent requests that provide a duplicate request ID for at least 120 minutes after the first request.

    The request ID must be a valid UUID.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/commerce/consumer/procurement/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Rest::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Commerce::Consumer::Procurement::V1::PlaceOrderRequest.new

# Call the place_order method.
result = client.place_order request

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end