Class: Orb::Resources::DimensionalPriceGroups

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/resources/dimensional_price_groups.rb,
lib/orb/resources/dimensional_price_groups/external_dimensional_price_group_id.rb,
sig/orb/resources/dimensional_price_groups.rbs,
sig/orb/resources/dimensional_price_groups/external_dimensional_price_group_id.rbs

Defined Under Namespace

Classes: ExternalDimensionalPriceGroupID

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ DimensionalPriceGroups

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of DimensionalPriceGroups.

Parameters:



140
141
142
143
144
# File 'lib/orb/resources/dimensional_price_groups.rb', line 140

def initialize(client:)
  @client = client
  @external_dimensional_price_group_id =
    Orb::Resources::DimensionalPriceGroups::ExternalDimensionalPriceGroupID.new(client: client)
end

Instance Attribute Details

#external_dimensional_price_group_id ⇒ Orb::Resources::DimensionalPriceGroups::ExternalDimensionalPriceGroupID (readonly)



7
8
9
# File 'lib/orb/resources/dimensional_price_groups.rb', line 7

def external_dimensional_price_group_id
  @external_dimensional_price_group_id
end

Instance Method Details

#create(billable_metric_id:, dimensions:, name:, external_dimensional_price_group_id: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::DimensionalPriceGroup

Some parameter documentations has been truncated, see Models::DimensionalPriceGroupCreateParams for more details.

A dimensional price group is used to partition the result of a billable metric by a set of dimensions. Prices in a price group must specify the partition used to derive their usage.

For example, suppose we have a billable metric that measures the number of widgets used and we want to charge differently depending on the color of the widget. We can create a price group with a dimension "color" and two prices: one that charges $10 per red widget and one that charges $20 per blue widget.

Parameters:

  • billable_metric_id (String)
  • dimensions (Array<String>) —

    The set of keys (in order) used to disambiguate prices in the group.

  • name (String)
  • external_dimensional_price_group_id (String, nil)
  • metadata (Hash{Symbol=>String, nil}, nil) —

    User-specified key/value pairs for the resource. Individual keys can be removed

  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



38
39
40
41
42
43
44
45
46
47
# File 'lib/orb/resources/dimensional_price_groups.rb', line 38

def create(params)
  parsed, options = Orb::DimensionalPriceGroupCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "dimensional_price_groups",
    body: parsed,
    model: Orb::DimensionalPriceGroup,
    options: options
  )
end

#list(cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::DimensionalPriceGroup>

Some parameter documentations has been truncated, see Models::DimensionalPriceGroupListParams for more details.

This endpoint returns a list of all dimensional price groups for an account. A dimensional price group partitions the result of a billable metric by a set of dimensions, and the prices in the group specify which partition their usage is derived from.

The response also includes pagination_metadata, which lets the caller retrieve the next page of results if they exist.

Parameters:

  • cursor (String, nil) —

    Cursor for pagination. This can be populated by the next_cursor value returned

  • limit (Integer) —

    The number of items to fetch. Defaults to 20.

  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/orb/resources/dimensional_price_groups.rb', line 124

def list(params = {})
  parsed, options = Orb::DimensionalPriceGroupListParams.dump_request(params)
  query = Orb::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "dimensional_price_groups",
    query: query,
    page: Orb::Internal::Page,
    model: Orb::DimensionalPriceGroup,
    options: options
  )
end

#retrieve(dimensional_price_group_id, request_options: {}) ⇒ Orb::Models::DimensionalPriceGroup

This endpoint returns a dimensional price group identified by its ID. A dimensional price group partitions the result of a billable metric by a set of dimensions, and the prices in the group specify which partition their usage is derived from.

Parameters:

  • dimensional_price_group_id (String)
  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/orb/resources/dimensional_price_groups.rb', line 62

def retrieve(dimensional_price_group_id, params = {})
  @client.request(
    method: :get,
    path: ["dimensional_price_groups/%1$s", dimensional_price_group_id],
    model: Orb::DimensionalPriceGroup,
    options: params[:request_options]
  )
end

#update(dimensional_price_group_id, external_dimensional_price_group_id: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::DimensionalPriceGroup

Some parameter documentations has been truncated, see Models::DimensionalPriceGroupUpdateParams for more details.

This endpoint can be used to update the external_dimensional_price_group_id and metadata of an existing dimensional price group. Other fields on a dimensional price group are currently immutable.

Parameters:

  • dimensional_price_group_id (String)
  • external_dimensional_price_group_id (String, nil) —

    An optional user-defined ID for this dimensional price group resource, used thro

  • metadata (Hash{Symbol=>String, nil}, nil) —

    User-specified key/value pairs for the resource. Individual keys can be removed

  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



91
92
93
94
95
96
97
98
99
100
# File 'lib/orb/resources/dimensional_price_groups.rb', line 91

def update(dimensional_price_group_id, params = {})
  parsed, options = Orb::DimensionalPriceGroupUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["dimensional_price_groups/%1$s", dimensional_price_group_id],
    body: parsed,
    model: Orb::DimensionalPriceGroup,
    options: options
  )
end