Module: Google::Cloud::Commerce::Consumer::Procurement::V1::ConsumerProcurementService::Paths

Extended by:
Paths
Included in:
Client, Paths, Rest::Client
Defined in:
lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/paths.rb

Overview

Path helper methods for the ConsumerProcurementService API.

Instance Method Summary collapse

Instance Method Details

#billing_account_path(billing_account:) ⇒ ::String

Create a fully-qualified BillingAccount resource string.

The resource will be in the following format:

billingAccounts/{billing_account}

Parameters:

  • billing_account (String)

Returns:

  • (::String)


39
40
41
# File 'lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/paths.rb', line 39

def  billing_account:
  "billingAccounts/#{}"
end

#offer_path(service: , offer: ) ⇒ ::String #offer_path(consumer_billing_account: , offer: ) ⇒ ::String

Create a fully-qualified Offer resource string.

Overloads:

  • #offer_path(service: , offer: ) ⇒ ::String

    The resource will be in the following format:

    services/{service}/standardOffers/{offer}

    Parameters:

    • service (String) (defaults to: )
    • offer (String) (defaults to: )
  • #offer_path(consumer_billing_account: , offer: ) ⇒ ::String

    The resource will be in the following format:

    billingAccounts/{consumer_billing_account}/offers/{offer}

    Parameters:

    • consumer_billing_account (String) (defaults to: )
    • offer (String) (defaults to: )

Returns:

  • (::String)

Raises:

  • (::ArgumentError)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/google/cloud/commerce/consumer/procurement/v1/consumer_procurement_service/paths.rb', line 63

def offer_path **args
  resources = {
    "offer:service" => (proc do |service:, offer:|
      raise ::ArgumentError, "service cannot contain /" if service.to_s.include? "/"

      "services/#{service}/standardOffers/#{offer}"
    end),
    "consumer_billing_account:offer" => (proc do |consumer_billing_account:, offer:|
      raise ::ArgumentError, "consumer_billing_account cannot contain /" if .to_s.include? "/"

      "billingAccounts/#{}/offers/#{offer}"
    end)
  }

  resource = resources[args.keys.sort.join(":")]
  raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
  resource.call(**args)
end