Class: AdvancedBilling::ProductsController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::ProductsController
- Defined in:
- lib/advanced_billing/controllers/products_controller.rb
Overview
ProductsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#archive_product(product_id) ⇒ ProductResponse
Archives the product.
-
#create_product(product_family_id, body: nil) ⇒ ProductResponse
Creates a product in your site.
-
#list_products(options = {}) ⇒ Array[ProductResponse]
Lists products belonging to a site.
-
#read_product(product_id) ⇒ ProductResponse
Reads the current details of a product.
-
#read_product_by_handle(api_handle) ⇒ ProductResponse
Retrieves a Product object by its
api_handle. -
#update_product(product_id, body: nil) ⇒ ProductResponse
Updates aspects of an existing product.
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_product(product_id) ⇒ ProductResponse
Archives the product. All current subscribers will be unaffected; their subscription/purchase will continue to be charged monthly. This will restrict the option to chose the product for purchase via the Billing Portal, as well as disable Public Signup Pages for the product. the product
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 115 def archive_product(product_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/products/{product_id}.json', Server::PRODUCTION) .template_param(new_parameter(product_id, key: 'product_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(ProductResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#create_product(product_family_id, body: nil) ⇒ ProductResponse
Creates a product in your site.
If you have the new [Catalog
experience](page:help/announcements/2026-announcements#new-catalog-experie
nce-and-terminology) enabled, the auto_create_signup_page parameter is
not supported. If auto_create_signup_page is included (with any value)
an error is returned.
For more information, see:
- [Products Overview](https://maxio.zendesk.com/hc/en-us/articles/24261090117645-Produ cts-Overview)
- [Changing a Subscription's
Product](https://maxio.zendesk.com/hc/en-us/articles/24252069837581-Produc
t-Changes-and-Migrations)
family's id or its handle prefixed with
handle:description here
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 27 def create_product(product_family_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/product_families/{product_family_id}/products.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(ProductResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#list_products(options = {}) ⇒ Array[ProductResponse]
Lists products belonging to a site.
you would like to apply to your search. Use in query:
date_field=created_at.
List Products operations
YYYY-MM-DD) with which to filter the date_field. Returns products 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
products 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.
YYYY-MM-DD) with which to filter the date_field. Returns products with a
timestamp at or after midnight (12:00:00 AM) 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 products 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.
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.
Include archived products. Use in query: include_archived=true.
additional data in the response. Use in query
include=prepaid_product_price_point.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 196 def list_products( = {}) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/products.json', Server::PRODUCTION) .query_param(new_parameter(['date_field'], key: 'date_field')) .query_param(new_parameter(['filter'], key: 'filter')) .query_param(new_parameter(['end_date'], key: 'end_date')) .query_param(new_parameter(['end_datetime'], key: 'end_datetime')) .query_param(new_parameter(['start_date'], key: 'start_date')) .query_param(new_parameter(['start_datetime'], key: 'start_datetime')) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['include_archived'], key: 'include_archived')) .query_param(new_parameter(['include'], key: 'include')) .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(ProductResponse.method(:from_hash)) .is_response_array(true)) .execute end |
#read_product(product_id) ⇒ ProductResponse
Reads the current details of a product. the product
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 55 def read_product(product_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/products/{product_id}.json', Server::PRODUCTION) .template_param(new_parameter(product_id, key: 'product_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(ProductResponse.method(:from_hash))) .execute end |
#read_product_by_handle(api_handle) ⇒ ProductResponse
Retrieves a Product object by its api_handle.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 138 def read_product_by_handle(api_handle) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/products/handle/{api_handle}.json', Server::PRODUCTION) .template_param(new_parameter(api_handle, key: 'api_handle') .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(ProductResponse.method(:from_hash))) .execute end |
#update_product(product_id, body: nil) ⇒ ProductResponse
Updates aspects of an existing product.
Input Attributes Update Notes
update_return_paramsThe parameters we will append to yourupdate_return_url. See Return URLs and Parameters
Product Price Point
Updating a product using this endpoint will create a new price point and set it as the default price point for this product. If you should like to update an existing product price point, that must be done separately. the product description here
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/advanced_billing/controllers/products_controller.rb', line 84 def update_product(product_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/products/{product_id}.json', Server::PRODUCTION) .template_param(new_parameter(product_id, key: 'product_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(ProductResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |