Class: AdvancedBilling::ComponentsController

Inherits:
BaseController show all
Defined in:
lib/advanced_billing/controllers/components_controller.rb

Overview

ComponentsController

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_api_call_builder, #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(product_family_id, component_id) ⇒ Component

Sending a DELETE request to this endpoint will archive the component. All current subscribers will be unffected; their subscription/purchase will continue to be charged as usual. Billing id of the product family to which the component belongs Billing id of the component or the handle for the component prefixed with ‘handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Advanced

  • component_id (String)

    Required parameter: Either the Advanced

Returns:

  • (Component)

    response from the API call.



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/components_controller.rb', line 329

def archive_component(product_family_id,
                      component_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/product_families/{product_family_id}/components/{component_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(component_id, key: 'component_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(Component.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#create_event_based_component(product_family_id, body: nil) ⇒ ComponentResponse

This request will create a component definition of kind event_based_component under the specified product family. Event-based component can then be added and “allocated” for a subscription. Event-based components are similar to other component types, in that you define the component parameters (such as name and taxability) and the pricing. A key difference for the event-based component is that it must be attached to a metric. This is because the metric provides the component with the actual quantity used in computing what and how much will be billed each period for each subscription. So, instead of reporting usage directly for each component (as you would with metered components), the usage is derived from analysis of your events. For more information on components, please see our documentation [here](maxio.zendesk.com/hc/en-us/articles/24261141522189-Componen ts-Overview). family’s id or its handle prefixed with ‘handle:`

Parameters:

  • product_family_id (String)

    Required parameter: Either the product

  • body (CreateEBBComponent) (defaults to: nil)

    Optional parameter: Example:

Returns:



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/advanced_billing/controllers/components_controller.rb', line 204

def create_event_based_component(product_family_id,
                                 body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/event_based_components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_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(ComponentResponse.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_metered_component(product_family_id, body: nil) ⇒ ComponentResponse

This request will create a component definition of kind metered_component under the specified product family. Metered component can then be added and “allocated” for a subscription. Metered components are used to bill for any type of unit that resets to 0 at the end of the billing period (think daily Google Adwords clicks or monthly cell phone minutes). This is most commonly associated with usage-based billing and many other pricing schemes. Note that this is different from recurring quantity-based components, which DO NOT reset to zero at the start of every billing period. If you want to bill for a quantity of something that does not change unless you change it, then you want quantity components, instead. For more information on components, please see our documentation [here](maxio.zendesk.com/hc/en-us/articles/24261141522189-Componen ts-Overview). family’s id or its handle prefixed with ‘handle:`

Parameters:

  • product_family_id (String)

    Required parameter: Either the product

  • body (CreateMeteredComponent) (defaults to: nil)

    Optional parameter: Example:

Returns:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/controllers/components_controller.rb', line 27

def create_metered_component(product_family_id,
                             body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/metered_components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_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(ComponentResponse.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_on_off_component(product_family_id, body: nil) ⇒ ComponentResponse

This request will create a component definition of kind on_off_component under the specified product family. On/Off component can then be added and “allocated” for a subscription. On/off components are used for any flat fee, recurring add on (think $99/month for tech support or a flat add on shipping fee). For more information on components, please see our documentation [here](maxio.zendesk.com/hc/en-us/articles/24261141522189-Componen ts-Overview). family’s id or its handle prefixed with ‘handle:`

Parameters:

  • product_family_id (String)

    Required parameter: Either the product

  • body (CreateOnOffComponent) (defaults to: nil)

    Optional parameter: Example:

Returns:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/advanced_billing/controllers/components_controller.rb', line 115

def create_on_off_component(product_family_id,
                            body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/on_off_components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_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(ComponentResponse.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_prepaid_usage_component(product_family_id, body: nil) ⇒ ComponentResponse

This request will create a component definition of kind prepaid_usage_component under the specified product family. Prepaid component can then be added and “allocated” for a subscription. Prepaid components allow customers to pre-purchase units that can be used up over time on their subscription. In a sense, they are the mirror image of metered components; while metered components charge at the end of the period for the amount of units used, prepaid components are charged for at the time of purchase, and we subsequently keep track of the usage against the amount purchased. For more information on components, please see our documentation [here](maxio.zendesk.com/hc/en-us/articles/24261141522189-Componen ts-Overview). family’s id or its handle prefixed with ‘handle:`

Parameters:

  • product_family_id (String)

    Required parameter: Either the product

  • body (CreatePrepaidComponent) (defaults to: nil)

    Optional parameter: Example:

Returns:



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/advanced_billing/controllers/components_controller.rb', line 158

def create_prepaid_usage_component(product_family_id,
                                   body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/prepaid_usage_components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_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(ComponentResponse.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_quantity_based_component(product_family_id, body: nil) ⇒ ComponentResponse

This request will create a component definition of kind quantity_based_component under the specified product family. Quantity Based component can then be added and “allocated” for a subscription. When defining Quantity Based component, You can choose one of 2 types: #### Recurring Recurring quantity-based components are used to bill for the number of some unit (think monthly software user licenses or the number of pairs of socks in a box-a-month club). This is most commonly associated with billing for user licenses, number of users, number of employees, etc. #### One-time One-time quantity-based components are used to create ad hoc usage charges that do not recur. For example, at the time of signup, you might want to charge your customer a one-time fee for onboarding or other services. The allocated quantity for one-time quantity-based components immediately gets reset back to zero after the allocation is made. For more information on components, please see our documentation [here](maxio.zendesk.com/hc/en-us/articles/24261141522189-Componen ts-Overview). family’s id or its handle prefixed with ‘handle:`

Parameters:

  • product_family_id (String)

    Required parameter: Either the product

  • body (CreateQuantityBasedComponent) (defaults to: nil)

    Optional parameter: Example:

Returns:



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/advanced_billing/controllers/components_controller.rb', line 76

def create_quantity_based_component(product_family_id,
                                    body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/quantity_based_components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_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(ComponentResponse.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

#find_component(handle) ⇒ ComponentResponse

This request will return information regarding a component having the handle you provide. You can identify your components with a handle so you don’t have to save or reference the IDs we generate. find

Parameters:

  • handle (String)

    Required parameter: The handle of the component to

Returns:



237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/advanced_billing/controllers/components_controller.rb', line 237

def find_component(handle)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/lookup.json',
                                 Server::PRODUCTION)
               .query_param(new_parameter(handle, key: 'handle')
                             .is_required(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

#list_components(options = {}) ⇒ Array[ComponentResponse]

This request will return a list of components for a site. you would like to apply to your search. YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of start_date. (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of end_date. optional Include archived items 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`. List Components operations

Parameters:

  • date_field (BasicDateField)

    Optional parameter: The type of filter

  • start_date (String)

    Optional parameter: The start date (format

  • end_date (String)

    Optional parameter: The end date (format

  • start_datetime (String)

    Optional parameter: The start date and time

  • end_datetime (String)

    Optional parameter: The end date and time

  • include_archived (TrueClass | FalseClass)

    Optional parameter:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter (ListComponentsFilter)

    Optional parameter: Filter to use for

Returns:



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

def list_components(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components.json',
                                 Server::PRODUCTION)
               .query_param(new_parameter(options['date_field'], key: 'date_field'))
               .query_param(new_parameter(options['start_date'], key: 'start_date'))
               .query_param(new_parameter(options['end_date'], key: 'end_date'))
               .query_param(new_parameter(options['start_datetime'], key: 'start_datetime'))
               .query_param(new_parameter(options['end_datetime'], key: 'end_datetime'))
               .query_param(new_parameter(options['include_archived'], key: 'include_archived'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .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(ComponentResponse.method(:from_hash))
                .is_response_array(true))
    .execute
end

#list_components_for_product_family(options = {}) ⇒ Array[ComponentResponse]

This request will return a list of components for a particular product family. Billing id of the product family Include archived items. 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`. List Components operations you would like to apply to your search. Use in query `date_field=created_at`. YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of end_date. optional. YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of start_date.

Parameters:

  • product_family_id (Integer)

    Required parameter: The Advanced

  • include_archived (TrueClass | FalseClass)

    Optional parameter:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter (ListComponentsFilter)

    Optional parameter: Filter to use for

  • date_field (BasicDateField)

    Optional parameter: The type of filter

  • end_date (String)

    Optional parameter: The end date (format

  • end_datetime (String)

    Optional parameter: The end date and time

  • start_date (String)

    Optional parameter: The start date (format

  • start_datetime (String)

    Optional parameter: The start date and time

Returns:



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/advanced_billing/controllers/components_controller.rb', line 488

def list_components_for_product_family(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/product_families/{product_family_id}/components.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(options['product_family_id'], key: 'product_family_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(options['include_archived'], key: 'include_archived'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .query_param(new_parameter(options['filter'], key: 'filter'))
               .query_param(new_parameter(options['date_field'], key: 'date_field'))
               .query_param(new_parameter(options['end_date'], key: 'end_date'))
               .query_param(new_parameter(options['end_datetime'], key: 'end_datetime'))
               .query_param(new_parameter(options['start_date'], key: 'start_date'))
               .query_param(new_parameter(options['start_datetime'], key: 'start_datetime'))
               .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(ComponentResponse.method(:from_hash))
                .is_response_array(true))
    .execute
end

#read_component(product_family_id, component_id) ⇒ ComponentResponse

This request will return information regarding a component from a specific product family. You may read the component by either the component’s id or handle. When using the handle, it must be prefixed with ‘handle:`. Billing id of the product family to which the component belongs Billing id of the component or the handle for the component prefixed with `handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Advanced

  • component_id (String)

    Required parameter: Either the Advanced

Returns:



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/advanced_billing/controllers/components_controller.rb', line 262

def read_component(product_family_id,
                   component_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/product_families/{product_family_id}/components/{component_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(component_id, key: 'component_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

#update_component(component_id, body: nil) ⇒ ComponentResponse

This request will update a component. You may read the component by either the component’s id or handle. When using the handle, it must be prefixed with ‘handle:`. component

Parameters:

  • component_id (String)

    Required parameter: The id or handle of the

  • body (UpdateComponentRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



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

def update_component(component_id,
                     body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}.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(ComponentResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end

#update_product_family_component(product_family_id, component_id, body: nil) ⇒ ComponentResponse

This request will update a component from a specific product family. You may read the component by either the component’s id or handle. When using the handle, it must be prefixed with ‘handle:`. Billing id of the product family to which the component belongs Billing id of the component or the handle for the component prefixed with `handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Advanced

  • component_id (String)

    Required parameter: Either the Advanced

  • body (UpdateComponentRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/advanced_billing/controllers/components_controller.rb', line 292

def update_product_family_component(product_family_id,
                                    component_id,
                                    body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/product_families/{product_family_id}/components/{component_id}.json',
                                 Server::PRODUCTION)
               .template_param(new_parameter(product_family_id, key: 'product_family_id')
                                .is_required(true)
                                .should_encode(true))
               .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(ComponentResponse.method(:from_hash))
                .local_error_template('422',
                                      'HTTP Response Not OK. Status code: {$statusCode}.'\
                                       ' Response: \'{$response.body}\'.',
                                      ErrorListResponseException))
    .execute
end