Class: ApiReference::PriceApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/api_reference/apis/price_api.rb

Overview

PriceApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from ApiReference::BaseApi

Instance Method Details

#create_price(body) ⇒ ApiResponse

This endpoint is used to create a price. 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 for the specification of different price model configurations possible in this endpoint. NewFloatingBulkPrice | NewFloatingBulkWithFiltersPrice | NewFloatingPackagePrice | NewFloatingMatrixPrice | NewFloatingThresholdTotalAmountPrice | NewFloatingTieredPackagePrice | NewFloatingTieredWithMinimumPrice | NewFloatingGroupedTieredPrice | NewFloatingTieredPackageWithMinimumPrice | NewFloatingPackageWithAllocationPrice | NewFloatingUnitWithPercentPrice | NewFloatingMatrixWithAllocationPrice | NewFloatingMatrixWithThresholdDiscountsPrice | NewFloatingTieredWithProrationPrice | NewFloatingUnitWithProrationPrice | NewFloatingGroupedAllocationPrice | NewFloatingBulkWithProrationPrice | NewFloatingGroupedWithProratedMinimumPrice | NewFloatingGroupedWithMeteredMinimumPrice | NewFloatingGroupedWithMinMaxThresholdsPrice | NewFloatingMatrixWithDisplayNamePrice | NewFloatingGroupedTieredPackagePrice | NewFloatingMaxGroupTieredPackagePrice | NewFloatingScalableMatrixWithUnitPricingPrice | NewFloatingScalableMatrixWithTieredPricingPrice | NewFloatingCumulativeGroupedBulkPrice | NewFloatingCumulativeGroupedAllocationPrice | NewFloatingDailyCreditAllowancePrice | NewFloatingMeteredAllowancePrice | NewFloatingMinimumCompositePrice | NewFloatingPercentCompositePrice | NewFloatingEventOutputPrice] body Required parameter: TODO: type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/api_reference/apis/price_api.rb', line 89

def create_price(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/prices',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true)
                            .validator(proc do |value|
                              UnionTypeLookUp.get(:NewFloatingPrice)
                                             .validate(value)
                            end))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(APIHelper.method(:json_serialize))
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(proc do |response, should_symbolize|
                  APIHelper.deserialize_union_type(
                    UnionTypeLookUp.get(:Price),
                    response, should_symbolize, true
                  )
                end)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#evaluate_multiple_prices(body) ⇒ ApiResponse

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, supporting the following workflows:

  1. Showing detailed usage and costs to the end customer.
  2. 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 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. description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/api_reference/apis/price_api.rb', line 166

def evaluate_multiple_prices(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/prices/evaluate',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(EvaluateMultiplePriceResource.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#evaluate_preview_events(body) ⇒ ApiResponse

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 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:

  1. Up to 100 prices can be evaluated in a single request.
  2. 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. parameter: TODO: type description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/api_reference/apis/price_api.rb', line 225

def evaluate_preview_events(body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/prices/evaluate_preview_events',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(EvaluateMultiplePriceResource.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#evaluate_price(price_id, body) ⇒ ApiResponse

[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, supporting the following workflows:

  1. Showing detailed usage and costs to the end customer.
  2. 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. here

Parameters:

  • price_id (String)

    Required parameter: TODO: type description here

  • body (EvaluatePriceBody)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/api_reference/apis/price_api.rb', line 495

def evaluate_price(price_id,
                   body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/prices/{price_id}/evaluate',
                                 Server::DEFAULT)
               .template_param(new_parameter(price_id, key: 'price_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(EvaluatePriceResource.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#fetch_price(price_id) ⇒ ApiResponse

This endpoint returns a price given an identifier.

Parameters:

  • price_id (String)

    Required parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File 'lib/api_reference/apis/price_api.rb', line 370

def fetch_price(price_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/prices/{price_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(price_id, key: 'price_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(proc do |response, should_symbolize|
                  APIHelper.deserialize_union_type(
                    UnionTypeLookUp.get(:Price),
                    response, should_symbolize, true
                  )
                end)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#fetch_price_external_id(external_price_id) ⇒ ApiResponse

This endpoint returns a price given an external price id. See the price creation API for more information about external price aliases. description here

Parameters:

  • external_price_id (String)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/api_reference/apis/price_api.rb', line 270

def fetch_price_external_id(external_price_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/prices/external_price_id/{external_price_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(external_price_id, key: 'external_price_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(proc do |response, should_symbolize|
                  APIHelper.deserialize_union_type(
                    UnionTypeLookUp.get(:Price),
                    response, should_symbolize, true
                  )
                end)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#list_prices(limit: 20, cursor: nil) ⇒ ApiResponse

This endpoint is used to list all add-on prices created using the price creation endpoint.

Parameters:

  • limit (Integer) (defaults to: 20)

    Optional parameter: Example:20

  • cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/api_reference/apis/price_api.rb', line 14

def list_prices(limit: 20,
                cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/prices',
                                 Server::DEFAULT)
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Prices.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#update_price(price_id, body) ⇒ ApiResponse

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. description here

Parameters:

  • price_id (String)

    Required parameter: TODO: type description here

  • body (UpdatePriceRequestParams)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/api_reference/apis/price_api.rb', line 419

def update_price(price_id,
                 body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/prices/{price_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(price_id, key: 'price_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(proc do |response, should_symbolize|
                  APIHelper.deserialize_union_type(
                    UnionTypeLookUp.get(:Price),
                    response, should_symbolize, true
                  )
                end)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end

#update_price_by_external_id(external_price_id, body) ⇒ ApiResponse

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. description here description here

Parameters:

  • external_price_id (String)

    Required parameter: TODO: type

  • body (UpdatePriceRequestParams)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/api_reference/apis/price_api.rb', line 320

def update_price_by_external_id(external_price_id,
                                body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/prices/external_price_id/{external_price_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(external_price_id, key: 'external_price_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('APIKeyAuth')))
    .response(new_response_handler
                .deserializer(proc do |response, should_symbolize|
                  APIHelper.deserialize_union_type(
                    UnionTypeLookUp.get(:Price),
                    response, should_symbolize, true
                  )
                end)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             APIException)
                .local_error('401',
                             'Unauthorized',
                             AuthorizationErrorException)
                .local_error('404',
                             'Not Found',
                             APIException)
                .local_error('409',
                             'Conflict',
                             IdempotencyRequestMismatchException)
                .local_error('413',
                             'Content Too Large',
                             APIException)
                .local_error('429',
                             'Too Many Requests',
                             TooManyRequestsException)
                .local_error('500',
                             'Internal Server Error',
                             ServerErrorException))
    .execute
end