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) ⇒ ComponentResponse

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. the product family to which the component belongs the component or the handle for the component prefixed with ‘handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Chargify id of

  • component_id (String)

    Required parameter: Either the Chargify id of

Returns:



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/advanced_billing/controllers/components_controller.rb', line 238

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::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#archive_component_price_point(component_id, price_point_id) ⇒ ComponentPricePointResponse

A price point can be archived at any time. Subscriptions using a price point that has been archived will continue using it until they’re moved to another price point. component to which the price point belongs price point

Parameters:

  • component_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

Returns:



310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/advanced_billing/controllers/components_controller.rb', line 310

def archive_component_price_point(component_id,
                                  price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/components/{component_id}/price_points/{price_point_id}.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash)))
    .execute
end

#create_component(product_family_id, component_kind, body: nil) ⇒ ComponentResponse

This request will create a component definition under the specified product family. These component definitions determine what components are named, how they are measured, and how much they cost. Components can then be added and “allocated” for each subscription to a product in the product family. These component line-items affect how much a subscription will be charged, depending on the current allocations (i.e. 4 IP Addresses, or SSL “enabled”) This documentation covers both component definitions and component line-items. Please understand the difference. Please note that you may not edit components via API. To do so, please log into the application. ### Component Documentation For more information on components, please see our documentation [here](maxio-chargify.zendesk.com/hc/en-us/articles/5405020625677) . For information on how to record component usage against a subscription, please see the following resources: + [Proration and Component Allocations](maxio-chargify.zendesk.com/hc/en-us/articles/54050206 25677#applying-proration-and-recording-components) + [Recording component usage against a subscription](maxio-chargify.zendesk.com/hc/en-us/articles/5404606 587917#recording-component-usage) the product family to which the component belongs component kind CreateOnOffComponent | CreatePrepaidComponent | CreateEBBComponent | nil] body Optional parameter: Example:

Parameters:

Returns:



198
199
200
201
202
203
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
# File 'lib/advanced_billing/controllers/components_controller.rb', line 198

def create_component(product_family_id,
                     component_kind,
                     body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families/{product_family_id}/{component_kind}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_family_id, key: 'product_family_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(component_kind, key: 'component_kind')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .validator(proc do |value|
                              UnionTypeLookUp.get(:CreateComponentBody)
                                             .validate(value)
                            end))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(APIHelper.method(:json_serialize))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#create_component_price_point(component_id, body: nil) ⇒ ComponentPricePointResponse

This endpoint can be used to create a new price point for an existing component. component Example:

Parameters:

Returns:



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/advanced_billing/controllers/components_controller.rb', line 338

def create_component_price_point(component_id,
                                 body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash)))
    .execute
end

#create_component_price_points(component_id, body: nil) ⇒ ComponentPricePointsResponse

Use this endpoint to create multiple component price points in one request. component for which you want to fetch price points. Example:

Parameters:

Returns:



637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
# File 'lib/advanced_billing/controllers/components_controller.rb', line 637

def create_component_price_points(component_id,
                                  body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/components/{component_id}/price_points/bulk.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointsResponse.method(:from_hash)))
    .execute
end

#create_currency_prices(price_point_id, body: nil) ⇒ Array[CurrencyPrice]

This endpoint allows you to create currency prices for a given currency that has been defined on the site level in your settings. 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. price point

Parameters:

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

  • body (CreateCurrencyPricesRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/advanced_billing/controllers/components_controller.rb', line 696

def create_currency_prices(price_point_id,
                           body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/price_points/{price_point_id}/currency_prices.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CurrencyPrice.method(:from_hash))
                .is_response_array(true))
    .execute
end

#list_all_component_price_points(options = {}) ⇒ ListComponentsPricePointsResponse

This method allows to retrieve a list of Components Price Points belonging to a Site. filter you would like to apply to your search. Use in query: ‘filter=created_at`. YYYY-MM-DD) with which to filter the date_field. Returns price points with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns price points 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. 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`. (format YYYY-MM-DD) with which to filter the date_field. Returns price points with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns price points 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. price points with matching type. Use in query: ‘filter=custom,catalog`. order in which results are returned. Use in query `direction=asc`. price points with matching id based on provided values. Use in query: `filter=1,2,3`. fetching price points only if archived_at is present or not. Use in query: `filter=not_null`.

Parameters:

  • filter_date_field (BasicDateField)

    Optional parameter: The type of

  • filter_end_date (String)

    Optional parameter: The end date (format

  • filter_end_datetime (String)

    Optional parameter: The end date and

  • include (ListComponentsPricePointsInclude)

    Optional parameter:

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • filter_start_date (String)

    Optional parameter: The start date

  • filter_start_datetime (String)

    Optional parameter: The start date

  • filter_type (PricePointType)

    Optional parameter: Allows fetching

  • direction (SortingDirection | nil)

    Optional parameter: Controls the

  • filter_ids (Array[Integer])

    Optional parameter: Allows fetching

  • filter_archived_at (IncludeNotNull)

    Optional parameter: Allows

Returns:



520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'lib/advanced_billing/controllers/components_controller.rb', line 520

def list_all_component_price_points(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components_price_points.json',
                                 Server::DEFAULT)
               .query_param(new_parameter(options['filter_date_field'], key: 'filter[date_field]'))
               .query_param(new_parameter(options['filter_end_date'], key: 'filter[end_date]'))
               .query_param(new_parameter(options['filter_end_datetime'], key: 'filter[end_datetime]'))
               .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['filter_start_date'], key: 'filter[start_date]'))
               .query_param(new_parameter(options['filter_start_datetime'], key: 'filter[start_datetime]'))
               .query_param(new_parameter(options['filter_type'], key: 'filter[type]'))
               .query_param(new_parameter(options['direction'], key: 'direction')
                             .validator(proc do |value|
                               UnionTypeLookUp.get(:ListAllComponentPricePointsInputDirection)
                                              .validate(value)
                             end))
               .query_param(new_parameter(options['filter_ids'], key: 'filter[ids]'))
               .query_param(new_parameter(options['filter_archived_at'], key: 'filter[archived_at]'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ListComponentsPricePointsResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#list_component_price_points(options = {}) ⇒ ComponentPricePointsResponse

Use this endpoint to read current price points that are 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. 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 Chargify id of the

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



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/advanced_billing/controllers/components_controller.rb', line 447

def list_component_price_points(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/{component_id}/price_points.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointsResponse.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`. components with matching id based on provided value. Use in query `filter=1,2,3`. parameter: Allows fetching components with matching use_site_exchange_rate based on provided value (refers to default price point). Use in query `filter=true`.

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_ids (Array[String])

    Optional parameter: Allows fetching

  • filter_use_site_exchange_rate (TrueClass | FalseClass)

    Optional

Returns:



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

def list_components(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components.json',
                                 Server::DEFAULT)
               .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_ids'], key: 'filter[ids]'))
               .query_param(new_parameter(options['filter_use_site_exchange_rate'], key: 'filter[use_site_exchange_rate]'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .is_nullify404(true)
                .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. the product family Include archived items. components with matching id based on provided value. Use in query ‘filter=1,2`. 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`. 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. parameter: Allows fetching components with matching use_site_exchange_rate based on provided value (refers to default price point). Use in query ‘filter=true`.

Parameters:

  • product_family_id (Integer)

    Required parameter: The Chargify id of

  • include_archived (TrueClass | FalseClass)

    Optional parameter:

  • filter_ids (Array[Integer])

    Optional parameter: Allows fetching

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • 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

  • filter_use_site_exchange_rate (TrueClass | FalseClass)

    Optional

Returns:



601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
# File 'lib/advanced_billing/controllers/components_controller.rb', line 601

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::DEFAULT)
               .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['filter_ids'], key: 'filter[ids]'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .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'))
               .query_param(new_parameter(options['filter_use_site_exchange_rate'], key: 'filter[use_site_exchange_rate]'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth'))
               .array_serialization_format(ArraySerializationFormat::CSV))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash))
                .is_response_array(true))
    .execute
end

#read_component_by_handle(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:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/advanced_billing/controllers/components_controller.rb', line 15

def read_component_by_handle(handle)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/components/lookup.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash)))
    .execute
end

#read_component_by_id(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:`. the product family to which the component belongs the component or the handle for the component prefixed with `handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Chargify id of

  • component_id (String)

    Required parameter: Either the Chargify id of

Returns:



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/advanced_billing/controllers/components_controller.rb', line 109

def read_component_by_id(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::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash)))
    .execute
end

#unarchive_component_price_point(component_id, price_point_id) ⇒ ComponentPricePointResponse

Use this endpoint to unarchive a component price point. component to which the price point belongs price point

Parameters:

  • component_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

Returns:



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/advanced_billing/controllers/components_controller.rb', line 664

def unarchive_component_price_point(component_id,
                                    price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/unarchive.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash)))
    .execute
end

#update_component(component_id, body: nil) ⇒ void

This method returns an undefined value.

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:



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/advanced_billing/controllers/components_controller.rb', line 399

def update_component(component_id,
                     body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}.json',
                                 Server::DEFAULT)
               .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))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .is_response_void(true))
    .execute
end

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

When updating a price point, it’s prices can be updated as well by creating new prices or editing / removing existing ones. 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. component to which the price point belongs price point Example:

Parameters:

  • component_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

  • body (UpdateComponentPricePointRequest) (defaults to: nil)

    Optional parameter:

Returns:



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/advanced_billing/controllers/components_controller.rb', line 277

def update_component_price_point(component_id,
                                 price_point_id,
                                 body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}.json',
                                 Server::DEFAULT)
               .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: '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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentPricePointResponse.method(:from_hash)))
    .execute
end

#update_currency_prices(price_point_id, body: nil) ⇒ Array[CurrencyPrice]

This endpoint allows you to update currency prices for a given currency that has been defined on the site level in your settings. Note: Currency Prices are not able to be updated for custom price points. price point

Parameters:

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

  • body (UpdateCurrencyPricesRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
# File 'lib/advanced_billing/controllers/components_controller.rb', line 725

def update_currency_prices(price_point_id,
                           body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/price_points/{price_point_id}/currency_prices.json',
                                 Server::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CurrencyPrice.method(:from_hash))
                .is_response_array(true))
    .execute
end

#update_default_price_point_for_component(component_id, price_point_id) ⇒ void

This method returns an undefined value.

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](chargify.zendesk.com/hc/en-us/articles/440775586588 3#price-points) 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. component to which the price point belongs price point

Parameters:

  • component_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# File 'lib/advanced_billing/controllers/components_controller.rb', line 373

def update_default_price_point_for_component(component_id,
                                             price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/components/{component_id}/price_points/{price_point_id}/default.json',
                                 Server::DEFAULT)
               .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))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .is_response_void(true))
    .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:`. the product family to which the component belongs the component or the handle for the component prefixed with `handle:`

Parameters:

  • product_family_id (Integer)

    Required parameter: The Chargify id of

  • component_id (String)

    Required parameter: Either the Chargify id of

  • body (UpdateComponentRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/advanced_billing/controllers/components_controller.rb', line 139

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::DEFAULT)
               .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
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ComponentResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end