Class: AdvancedBilling::ProductFamiliesController

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

Overview

ProductFamiliesController

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

#create_product_family(body: nil) ⇒ ProductFamilyResponse

This method will create a Product Family within your Chargify site. Create a Product Family to act as a container for your products, components and coupons. Full documentation on how Product Families operate within the Chargify UI can be located [here](maxio-chargify.zendesk.com/hc/en-us/articles/5405369633421) .

Parameters:

Returns:



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

def create_product_family(body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_families.json',
                                 Server::DEFAULT)
               .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(ProductFamilyResponse.method(:from_hash)))
    .execute
end

#list_product_families(options = {}) ⇒ Array[ProductFamilyResponse]

This method allows to retrieve a list of Product Families for a site. 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 products 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 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 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 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.

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

Returns:



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/advanced_billing/controllers/product_families_controller.rb', line 143

def list_product_families(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/product_families.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'))
               .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(ProductFamilyResponse.method(:from_hash))
                .is_response_array(true))
    .execute
end

#list_products_for_product_family(options = {}) ⇒ Array[ProductResponse]

This method allows to retrieve a list of Products belonging to a Product Family. the product family to which the product belongs 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 products 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 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 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 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. Include archived products additional data in the response. Use in query ‘include=prepaid_product_price_point`. filter_prepaid_product_price_point_product_price_point_id Optional parameter: Allows fetching products only if a prepaid product price point is present or not. To use this filter you also have to include the following param in the request `include=prepaid_product_price_point`. Use in query `filter[product_price_point_id]=not_null`. parameter: Allows fetching products 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

  • 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

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

  • include (ListProductsInclude)

    Optional parameter: Allows including

  • (IncludeNotNull)
  • filter_use_site_exchange_rate (TrueClass | FalseClass)

    Optional

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/advanced_billing/controllers/product_families_controller.rb', line 62

def list_products_for_product_family(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/product_families/{product_family_id}/products.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['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['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['include'], key: 'include'))
               .query_param(new_parameter(options['filter_prepaid_product_price_point_product_price_point_id'], key: 'filter[prepaid_product_price_point][product_price_point_id]'))
               .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')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProductResponse.method(:from_hash))
                .is_response_array(true)
                .local_error('404',
                             'Not Found',
                             APIException))
    .execute
end

#read_product_family(id) ⇒ ProductFamilyResponse

This method allows to retrieve a Product Family via the ‘product_family_id`. The response will contain a Product Family object. The product family can be specified either with the id number, or with the `handle:my-family` format. family

Parameters:

  • id (Integer)

    Required parameter: The Chargify id of the product

Returns:



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/advanced_billing/controllers/product_families_controller.rb', line 170

def read_product_family(id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/product_families/{id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: '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(ProductFamilyResponse.method(:from_hash)))
    .execute
end