Class: Orb::Resources::Prices
- Inherits:
-
Object
- Object
- Orb::Resources::Prices
- Defined in:
- lib/orb/resources/prices.rb,
lib/orb/resources/prices/external_price_id.rb
Defined Under Namespace
Classes: ExternalPriceID
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(cadence: , currency: , item_id: , model_type: , name: , unit_config: , package_config: , matrix_config: , matrix_with_allocation_config: , tiered_config: , tiered_bps_config: , bps_config: , bulk_bps_config: , bulk_config: , threshold_total_amount_config: , tiered_package_config: , grouped_tiered_config: , max_group_tiered_package_config: , tiered_with_minimum_config: , package_with_allocation_config: , tiered_package_with_minimum_config: , unit_with_percent_config: , tiered_with_proration_config: , unit_with_proration_config: , grouped_allocation_config: , grouped_with_prorated_minimum_config: , grouped_with_metered_minimum_config: , matrix_with_display_name_config: , bulk_with_proration_config: , grouped_tiered_package_config: , scalable_matrix_with_unit_pricing_config: , scalable_matrix_with_tiered_pricing_config: , cumulative_grouped_bulk_config: , billable_metric_id: nil, billed_in_advance: nil, billing_cycle_configuration: nil, conversion_rate: nil, conversion_rate_config: nil, dimensional_price_configuration: nil, external_price_id: nil, fixed_price_quantity: nil, invoice_grouping_key: nil, invoicing_cycle_configuration: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
Some parameter documentations has been truncated, see Models::PriceCreateParams for more details.
-
#evaluate(price_id, timeframe_end: , timeframe_start: , customer_id: nil, external_customer_id: nil, filter: nil, grouping_keys: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluateResponse
Some parameter documentations has been truncated, see Models::PriceEvaluateParams for more details.
-
#evaluate_multiple(timeframe_end: , timeframe_start: , customer_id: nil, external_customer_id: nil, price_evaluations: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluateMultipleResponse
This endpoint is used to evaluate the output of price(s) for a given customer and time range over ingested events.
-
#evaluate_preview_events(timeframe_end: , timeframe_start: , customer_id: nil, events: nil, external_customer_id: nil, price_evaluations: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluatePreviewEventsResponse
This endpoint evaluates prices on preview events instead of actual usage, making it ideal for building price calculators and cost estimation tools.
-
#fetch(price_id, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
This endpoint returns a price given an identifier.
-
#initialize(client:) ⇒ Prices
constructor
private
A new instance of Prices.
-
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Price::Unit, Orb::Models::Price::Package, Orb::Models::Price::Matrix, Orb::Models::Price::Tiered, Orb::Models::Price::TieredBPS, Orb::Models::Price::BPS, Orb::Models::Price::BulkBPS, Orb::Models::Price::Bulk, Orb::Models::Price::ThresholdTotalAmount, Orb::Models::Price::TieredPackage, Orb::Models::Price::GroupedTiered, Orb::Models::Price::TieredWithMinimum, Orb::Models::Price::TieredPackageWithMinimum, Orb::Models::Price::PackageWithAllocation, Orb::Models::Price::UnitWithPercent, Orb::Models::Price::MatrixWithAllocation, Orb::Models::Price::TieredWithProration, Orb::Models::Price::UnitWithProration, Orb::Models::Price::GroupedAllocation, Orb::Models::Price::GroupedWithProratedMinimum, Orb::Models::Price::GroupedWithMeteredMinimum, Orb::Models::Price::MatrixWithDisplayName, Orb::Models::Price::BulkWithProration, Orb::Models::Price::GroupedTieredPackage, Orb::Models::Price::MaxGroupTieredPackage, Orb::Models::Price::ScalableMatrixWithUnitPricing, Orb::Models::Price::ScalableMatrixWithTieredPricing, Orb::Models::Price::CumulativeGroupedBulk, Orb::Models::Price::GroupedWithMinMaxThresholds>
Some parameter documentations has been truncated, see Models::PriceListParams for more details.
-
#update(price_id, metadata: nil, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
Some parameter documentations has been truncated, see Models::PriceUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Prices
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 Prices.
371 372 373 374 |
# File 'lib/orb/resources/prices.rb', line 371 def initialize(client:) @client = client @external_price_id = Orb::Resources::Prices::ExternalPriceID.new(client: client) end |
Instance Attribute Details
#external_price_id ⇒ Orb::Resources::Prices::ExternalPriceID (readonly)
7 8 9 |
# File 'lib/orb/resources/prices.rb', line 7 def external_price_id @external_price_id end |
Instance Method Details
#create(cadence: , currency: , item_id: , model_type: , name: , unit_config: , package_config: , matrix_config: , matrix_with_allocation_config: , tiered_config: , tiered_bps_config: , bps_config: , bulk_bps_config: , bulk_config: , threshold_total_amount_config: , tiered_package_config: , grouped_tiered_config: , max_group_tiered_package_config: , tiered_with_minimum_config: , package_with_allocation_config: , tiered_package_with_minimum_config: , unit_with_percent_config: , tiered_with_proration_config: , unit_with_proration_config: , grouped_allocation_config: , grouped_with_prorated_minimum_config: , grouped_with_metered_minimum_config: , matrix_with_display_name_config: , bulk_with_proration_config: , grouped_tiered_package_config: , scalable_matrix_with_unit_pricing_config: , scalable_matrix_with_tiered_pricing_config: , cumulative_grouped_bulk_config: , billable_metric_id: nil, billed_in_advance: nil, billing_cycle_configuration: nil, conversion_rate: nil, conversion_rate_config: nil, dimensional_price_configuration: nil, external_price_id: nil, fixed_price_quantity: nil, invoice_grouping_key: nil, invoicing_cycle_configuration: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
Some parameter documentations has been truncated, see Models::PriceCreateParams for more details.
This endpoint is used to create a [price](/product-catalog/price-configuration). A price created using this endpoint is always an add-on, meaning that it’s not associated with a specific plan and can instead be individually added to subscriptions, including subscriptions on different plans.
An ‘external_price_id` can be optionally specified as an alias to allow ergonomic interaction with prices in the Orb API.
See the [Price resource](/product-catalog/price-configuration) for the specification of different price model configurations possible in this endpoint.
118 119 120 121 |
# File 'lib/orb/resources/prices.rb', line 118 def create(params) parsed, = Orb::PriceCreateParams.dump_request(params) @client.request(method: :post, path: "prices", body: parsed, model: Orb::Price, options: ) end |
#evaluate(price_id, timeframe_end: , timeframe_start: , customer_id: nil, external_customer_id: nil, filter: nil, grouping_keys: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluateResponse
Some parameter documentations has been truncated, see Models::PriceEvaluateParams for more details.
- NOTE
-
It is recommended to use the ‘/v1/prices/evaluate` which offers further
functionality, such as multiple prices, inline price definitions, and querying over preview events.
This endpoint is used to evaluate the output of a price for a given customer and time range. It enables filtering and grouping the output using [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the following workflows:
-
Showing detailed usage and costs to the end customer.
-
Auditing subtotals on invoice line items.
For these workflows, the expressiveness of computed properties in both the filters and grouping is critical. For example, if you’d like to show your customer their usage grouped by hour and another property, you can do so with the following ‘grouping_keys`: `[“hour_floor_timestamp_millis(timestamp_millis)”, “my_property”]`. If you’d like to examine a customer’s usage for a specific property value, you can do so with the following ‘filter`: `my_property = ’foo’ AND my_other_property = ‘bar’‘.
By default, the start of the time range must be no more than 100 days ago and the length of the results must be no greater than 1000. Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body rather than query parameters.
231 232 233 234 235 236 237 238 239 240 |
# File 'lib/orb/resources/prices.rb', line 231 def evaluate(price_id, params) parsed, = Orb::PriceEvaluateParams.dump_request(params) @client.request( method: :post, path: ["prices/%1$s/evaluate", price_id], body: parsed, model: Orb::Models::PriceEvaluateResponse, options: ) end |
#evaluate_multiple(timeframe_end: , timeframe_start: , customer_id: nil, external_customer_id: nil, price_evaluations: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluateMultipleResponse
This endpoint is used to evaluate the output of price(s) for a given customer and time range over ingested events. It enables filtering and grouping the output using [computed properties](/extensibility/advanced-metrics#computed-properties), supporting the following workflows:
-
Showing detailed usage and costs to the end customer.
-
Auditing subtotals on invoice line items.
For these workflows, the expressiveness of computed properties in both the filters and grouping is critical. For example, if you’d like to show your customer their usage grouped by hour and another property, you can do so with the following ‘grouping_keys`: `[“hour_floor_timestamp_millis(timestamp_millis)”, “my_property”]`. If you’d like to examine a customer’s usage for a specific property value, you can do so with the following ‘filter`: `my_property = ’foo’ AND my_other_property = ‘bar’‘.
Prices may either reference existing prices in your Orb account or be defined inline in the request body. Up to 100 prices can be evaluated in a single request.
Prices are evaluated on ingested events and the start of the time range must be no more than 100 days ago. To evaluate based off a set of provided events, the [evaluate preview events](/api-reference/price/evaluate-preview-events) endpoint can be used instead.
Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body rather than query parameters.
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/orb/resources/prices.rb', line 289 def evaluate_multiple(params) parsed, = Orb::PriceEvaluateMultipleParams.dump_request(params) @client.request( method: :post, path: "prices/evaluate", body: parsed, model: Orb::Models::PriceEvaluateMultipleResponse, options: ) end |
#evaluate_preview_events(timeframe_end: , timeframe_start: , customer_id: nil, events: nil, external_customer_id: nil, price_evaluations: nil, request_options: {}) ⇒ Orb::Models::PriceEvaluatePreviewEventsResponse
This endpoint evaluates prices on preview events instead of actual usage, making it ideal for building price calculators and cost estimation tools. You can filter and group results using [computed properties](/extensibility/advanced-metrics#computed-properties) to analyze pricing across different dimensions.
Prices may either reference existing prices in your Orb account or be defined inline in the request body. The endpoint has the following limitations:
-
Up to 100 prices can be evaluated in a single request.
-
Up to 500 preview events can be provided in a single request.
A top-level customer_id is required to evaluate the preview events. Additionally, all events without a customer_id will have the top-level customer_id added.
Note that this is a POST endpoint rather than a GET endpoint because it employs a JSON body rather than query parameters.
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/orb/resources/prices.rb', line 338 def evaluate_preview_events(params) parsed, = Orb::PriceEvaluatePreviewEventsParams.dump_request(params) @client.request( method: :post, path: "prices/evaluate_preview_events", body: parsed, model: Orb::Models::PriceEvaluatePreviewEventsResponse, options: ) end |
#fetch(price_id, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
This endpoint returns a price given an identifier.
359 360 361 362 363 364 365 366 |
# File 'lib/orb/resources/prices.rb', line 359 def fetch(price_id, params = {}) @client.request( method: :get, path: ["prices/%1$s", price_id], model: Orb::Price, options: params[:request_options] ) end |
#list(cursor: nil, limit: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Price::Unit, Orb::Models::Price::Package, Orb::Models::Price::Matrix, Orb::Models::Price::Tiered, Orb::Models::Price::TieredBPS, Orb::Models::Price::BPS, Orb::Models::Price::BulkBPS, Orb::Models::Price::Bulk, Orb::Models::Price::ThresholdTotalAmount, Orb::Models::Price::TieredPackage, Orb::Models::Price::GroupedTiered, Orb::Models::Price::TieredWithMinimum, Orb::Models::Price::TieredPackageWithMinimum, Orb::Models::Price::PackageWithAllocation, Orb::Models::Price::UnitWithPercent, Orb::Models::Price::MatrixWithAllocation, Orb::Models::Price::TieredWithProration, Orb::Models::Price::UnitWithProration, Orb::Models::Price::GroupedAllocation, Orb::Models::Price::GroupedWithProratedMinimum, Orb::Models::Price::GroupedWithMeteredMinimum, Orb::Models::Price::MatrixWithDisplayName, Orb::Models::Price::BulkWithProration, Orb::Models::Price::GroupedTieredPackage, Orb::Models::Price::MaxGroupTieredPackage, Orb::Models::Price::ScalableMatrixWithUnitPricing, Orb::Models::Price::ScalableMatrixWithTieredPricing, Orb::Models::Price::CumulativeGroupedBulk, Orb::Models::Price::GroupedWithMinMaxThresholds>
Some parameter documentations has been truncated, see Models::PriceListParams for more details.
This endpoint is used to list all add-on prices created using the [price creation endpoint](/api-reference/price/create-price).
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/orb/resources/prices.rb', line 169 def list(params = {}) parsed, = Orb::PriceListParams.dump_request(params) @client.request( method: :get, path: "prices", query: parsed, page: Orb::Internal::Page, model: Orb::Price, options: ) end |
#update(price_id, metadata: nil, request_options: {}) ⇒ Orb::Models::Price::Unit, ...
Some parameter documentations has been truncated, see Models::PriceUpdateParams for more details.
This endpoint allows you to update the ‘metadata` property on a price. If you pass null for the metadata value, it will clear any existing metadata for that price.
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/orb/resources/prices.rb', line 141 def update(price_id, params = {}) parsed, = Orb::PriceUpdateParams.dump_request(params) @client.request( method: :put, path: ["prices/%1$s", price_id], body: parsed, model: Orb::Price, options: ) end |