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

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:



130
131
132
133
134
# File 'lib/orb/resources/dimensional_price_groups.rb', line 130

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_idOrb::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 parition 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.

List dimensional price groups

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:



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/orb/resources/dimensional_price_groups.rb', line 115

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

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

Fetch dimensional price group

Parameters:

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

Returns:

See Also:



59
60
61
62
63
64
65
66
# File 'lib/orb/resources/dimensional_price_groups.rb', line 59

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:



88
89
90
91
92
93
94
95
96
97
# File 'lib/orb/resources/dimensional_price_groups.rb', line 88

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