Class: AdvancedBilling::ComponentPricePointsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/advanced_billing/controllers/component_price_points_controller.rb

Overview

ComponentPricePointsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

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

Constructor Details

This class inherits a constructor from AdvancedBilling::BaseController

Instance Method Details

#archive_component_price_point(component_id, price_point_id) ⇒ ComponentPricePointResponse

Archives a component price point. Subscriptions using a price point that has been archived will continue using it until they’re moved to another price point. handle of the component. When using the handle, it must be prefixed with ‘handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle. handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-price_point-handle` for a string handle.

Parameters:

  • component_id (Integer | String)

    Required parameter: The id or

  • price_point_id (Integer | String)

    Required parameter: The id or

Returns:



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
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 321

def archive_component_price_point(component_id,
                                  price_point_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/components/{component_id}/price_points/{price_point_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:ArchiveComponentPricePointComponentId)
                                                 .validate(value)
                                end))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:ArchiveComponentPricePointPricePointId)
                                                 .validate(value)
                                end))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#bulk_create_component_price_points(component_id, body: nil) ⇒ ComponentPricePointsResponse

Creates multiple component price points in one request. of the component for which you want to fetch price points. type description here

Parameters:

Returns:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 128

def bulk_create_component_price_points(component_id,
                                       body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points/bulk.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointsResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#clone_component_price_point(component_id, price_point_id, body: nil) ⇒ ComponentPricePointCurrencyOverageResponse

Clones a component price point. Custom price points (tied to a specific subscription) cannot be cloned. The following attributes are copied from the source price point:

  • Pricing scheme

  • All price tiers (with starting/ending quantities and unit prices)

  • Tax included setting

  • Currency prices (if definitive pricing is set)

  • Overage pricing (for prepaid usage components)

  • Interval settings (if multi-frequency is enabled)

  • Event-based billing segments (if applicable)

handle of the component. When using the handle, it must be prefixed with ‘handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle. handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-price_point-handle` for a string handle. type description here

Parameters:

  • component_id (Integer | String)

    Required parameter: The id or

  • price_point_id (Integer | String)

    Required parameter: The id or

  • body (CloneComponentPricePointRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:



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
204
205
206
207
208
209
210
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 173

def clone_component_price_point(component_id,
                                price_point_id,
                                body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points/{price_point_id}/clone.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:CloneComponentPricePointComponentId)
                                                 .validate(value)
                                end))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:CloneComponentPricePointPricePointId)
                                                 .validate(value)
                                end))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointCurrencyOverageResponse.method(:from_hash))
                .local_error_template('404',
                                      'Not Found:\'{$response.body}\'',
                                      APIException)
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#create_component_price_point(component_id, body: nil) ⇒ ComponentPricePointResponse

Creates a price point for an existing component. of the component type description here

Parameters:

  • component_id (Integer)

    Required parameter: The Advanced Billing id

  • body (CreateComponentPricePointRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 49

def create_component_price_point(component_id,
                                 body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorArrayMapResponseException))
    .execute
end

#create_currency_prices(price_point_id, body: nil) ⇒ ComponentCurrencyPricesResponse

Creates currency prices for a given currency defined at the site level. When creating currency prices, they need to mirror the structure of your primary pricing. For each price level defined on the component price point, there should be a matching price level created in the given currency. Note: Currency Prices are not able to be created for custom price points. id of the price point description here

Parameters:

  • price_point_id (Integer)

    Required parameter: The Advanced Billing

  • body (CreateCurrencyPricesRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 390

def create_currency_prices(price_point_id,
                           body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/price_points/{price_point_id}/currency_prices.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentCurrencyPricesResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorArrayMapResponseException))
    .execute
end

#list_all_component_price_points(options = {}) ⇒ ListComponentsPricePointsResponse

Lists all component price points belonging to a site. Allows including additional data in the response. Use in query: ‘include=currency_prices`. pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query `per_page=200`. in which results are returned. Use in query `direction=asc`. for List PricePoints operations

Parameters:

  • include (ListComponentsPricePointsInclude)

    Optional parameter:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • direction (SortingDirection)

    Optional parameter: Controls the order

  • filter (ListPricePointsFilter)

    Optional parameter: Filter to use

Returns:



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 465

def list_all_component_price_points(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components_price_points.json',
                                 Server::PRODUCTION)
               .query_param(new_parameter(options['include'], key: 'include'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['direction'], key: 'direction'))
               .query_param(new_parameter(options['filter'], key: 'filter'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListComponentsPricePointsResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#list_component_price_points(options = {}) ⇒ ComponentPricePointsResponse

Lists the price points associated with a component. You may specify the component by using either the numeric id or the ‘handle:gold` syntax. When fetching a component’s price points, if you have defined multiple currencies at the site level, you can optionally pass the ‘?currency_prices=true` query param to include an array of currency price data in the response. If the price point is set to `use_site_exchange_rate: true`, it will return pricing based on the current exchange rate. If the flag is set to false, it will return all of the defined prices for each currency. of the component Include an array of currency price data pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query `page=1`. many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query `per_page=200`. query: `filter=catalog,default`.

Parameters:

  • component_id (Integer)

    Required parameter: The Advanced Billing id

  • currency_prices (TrueClass | FalseClass)

    Optional parameter:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter_type (Array[PricePointType])

    Optional parameter: Use in

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 101

def list_component_price_points(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/{component_id}/price_points.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['component_id'], key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['currency_prices'], key: 'currency_prices'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['filter_type'], key: 'filter[type]'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointsResponse.method(:from_hash)))
    .execute
end

#promote_component_price_point_to_default(component_id, price_point_id) ⇒ ComponentResponse

Sets a new default price point for the component. This new default will apply to all new subscriptions going forward - existing subscriptions will remain on their current price point. See [Price Points Documentation](maxio.zendesk.com/hc/en-us/articles/24261191737101- Price-Points-Components) for more information on price points and moving subscriptions between price points. Note: Custom price points are not able to be set as the default for a component. of the component to which the price point belongs id of the price point

Parameters:

  • component_id (Integer)

    Required parameter: The Advanced Billing id

  • price_point_id (Integer)

    Required parameter: The Advanced Billing

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 23

def promote_component_price_point_to_default(component_id,
                                             price_point_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/default.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash)))
    .execute
end

#read_component_price_point(component_id, price_point_id, currency_prices: nil) ⇒ ComponentPricePointCurrencyOverageResponse

Returns details for a specific component price point. You can achieve this by using either the component price point ID or handle. handle of the component. When using the handle, it must be prefixed with ‘handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle. handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-price_point-handle` for a string handle. Include an array of currency price data

Parameters:

  • component_id (Integer | String)

    Required parameter: The id or

  • price_point_id (Integer | String)

    Required parameter: The id or

  • currency_prices (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter:

Returns:



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
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 279

def read_component_price_point(component_id,
                               price_point_id,
                               currency_prices: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/{component_id}/price_points/{price_point_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:ReadComponentPricePointComponentId)
                                                 .validate(value)
                                end))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:ReadComponentPricePointPricePointId)
                                                 .validate(value)
                                end))
               .query_param(new_parameter(currency_prices, key: 'currency_prices'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointCurrencyOverageResponse.method(:from_hash)))
    .execute
end

#unarchive_component_price_point(component_id, price_point_id) ⇒ ComponentPricePointResponse

Unarchives a component price point. of the component to which the price point belongs id of the price point

Parameters:

  • component_id (Integer)

    Required parameter: The Advanced Billing id

  • price_point_id (Integer)

    Required parameter: The Advanced Billing

Returns:



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 359

def unarchive_component_price_point(component_id,
                                    price_point_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/unarchive.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash)))
    .execute
end

#update_component_price_point(component_id, price_point_id, body: nil) ⇒ ComponentPricePointResponse

Updates a component price point and its associated prices. Passing in a price bracket without an ‘id` will attempt to create a new price. Including an `id` will update the corresponding price, and including the `_destroy` flag set to true along with the `id` will remove that price. Note: Custom price points cannot be updated directly. They must be edited through the Subscription. handle of the component. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-product-handle` for a string handle. handle of the price point. When using the handle, it must be prefixed with `handle:`. Example: `123` for an integer ID, or `handle:example-price_point-handle` for a string handle. type description here

Parameters:

  • component_id (Integer | String)

    Required parameter: The id or

  • price_point_id (Integer | String)

    Required parameter: The id or

  • body (UpdateComponentPricePointRequest) (defaults to: nil)

    Optional parameter: TODO:

Returns:



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
263
264
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 230

def update_component_price_point(component_id,
                                 price_point_id,
                                 body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(component_id, key: 'component_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:UpdateComponentPricePointComponentId)
                                                 .validate(value)
                                end))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true)
                                .validator(proc do |value|
                                  UnionTypeLookUp.get(:UpdateComponentPricePointPricePointId)
                                                 .validate(value)
                                end))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorArrayMapResponseException))
    .execute
end

#update_currency_prices(price_point_id, body: nil) ⇒ ComponentCurrencyPricesResponse

Updates currency prices for a given currency defined at the site level. Note: Currency Prices are not able to be updated for custom price points. id of the price point description here

Parameters:

  • price_point_id (Integer)

    Required parameter: The Advanced Billing

  • body (UpdateCurrencyPricesRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/advanced_billing/controllers/component_price_points_controller.rb', line 421

def update_currency_prices(price_point_id,
                           body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/price_points/{price_point_id}/currency_prices.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentCurrencyPricesResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorArrayMapResponseException))
    .execute
end