Class: AdvancedBilling::ProductPricePointsController

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

Overview

ProductPricePointsController

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_product_price_point(product_id, price_point_id) ⇒ ProductPricePointResponse

Use this endpoint to archive a product price point. product. When using the handle, it must be prefixed with ‘handle:` the price point. When using the handle, it must be prefixed with `handle:`

Parameters:

  • product_id (Integer)

    Required parameter: The id or handle of the

  • price_point_id (Integer)

    Required parameter: The id or handle of

Returns:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 216

def archive_product_price_point(product_id,
                                price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/products/{product_id}/price_points/{price_point_id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_id, key: 'product_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(ProductPricePointResponse.method(:from_hash)))
    .execute
end

#create_product_currency_prices(product_price_point_id, body: nil) ⇒ ProductPricePointCurrencyPrice

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. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. Note: Currency Prices are not able to be created for custom product price points. id of the product price point Example:

Parameters:

Returns:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 185

def create_product_currency_prices(product_price_point_id,
                                   body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/product_price_points/{product_price_point_id}/currency_prices.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_price_point_id, key: 'product_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(ProductPricePointCurrencyPrice.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorMapResponseException))
    .execute
end

#create_product_price_point(product_id, body: nil) ⇒ ProductPricePointResponse

[Product Price Point Documentation](chargify.zendesk.com/hc/en-us/articles/440775582415 5) product. When using the handle, it must be prefixed with ‘handle:` Example:

Parameters:

  • product_id (Integer)

    Required parameter: The id or handle of the

  • body (CreateProductPricePointRequest) (defaults to: nil)

    Optional parameter:

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 63

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

#create_product_price_points(product_id, body: nil) ⇒ BulkCreateProductPricePointsResponse

Use this endpoint to create multiple product price points in one request. product to which the price points belong Example:

Parameters:

Returns:



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 152

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

#list_all_product_price_points(options = {}) ⇒ ListProductPricePointsResponse

This method allows retrieval of a list of Products Price Points belonging to a Site. order in which results are returned. Use in query ‘direction=asc`. fetching price points only if archived_at is present or not. Use in query: `filter=not_null`. 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. price points with matching id based on provided values. Use in query: ‘filter=1,2,3`. (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=catalog,custom`. 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`.

Parameters:

  • direction (SortingDirection | nil)

    Optional parameter: Controls the

  • filter_archived_at (IncludeNotNull)

    Optional parameter: Allows

  • 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

  • filter_ids (Array[Integer])

    Optional parameter: Allows fetching

  • 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

  • include (ListProductsPricePointsInclude)

    Optional parameter: Allows

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

Returns:



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 351

def list_all_product_price_points(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/products_price_points.json',
                                 Server::DEFAULT)
               .query_param(new_parameter(options['direction'], key: 'direction')
                             .validator(proc do |value|
                               UnionTypeLookUp.get(:ListAllProductPricePointsInputDirection)
                                              .validate(value)
                             end))
               .query_param(new_parameter(options['filter_archived_at'], key: 'filter[archived_at]'))
               .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['filter_ids'], key: 'filter[ids]'))
               .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['include'], key: 'include'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['per_page'], key: 'per_page'))
               .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(ListProductPricePointsResponse.method(:from_hash))
                .local_error('422',
                             'Unprocessable Entity (WebDAV)',
                             ErrorListResponseException))
    .execute
end

#list_product_price_points(options = {}) ⇒ ListProductPricePointsResponse

Use this endpoint to retrieve a list of product price points. product. When using the handle, it must be prefixed with ‘handle:` 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 10. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. fetching a product’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 product 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. query: ‘filter=catalog,default`.

Parameters:

  • product_id (Integer)

    Required parameter: The id or handle of the

  • page (Integer)

    Optional parameter: Result records are organized in

  • per_page (Integer)

    Optional parameter: This parameter indicates how

  • currency_prices (TrueClass | FalseClass)

    Optional parameter: When

  • filter_type (Array[PricePointType])

    Optional parameter: Use in

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 33

def list_product_price_points(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/products/{product_id}/price_points.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['product_id'], key: 'product_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['currency_prices'], key: 'currency_prices'))
               .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(ListProductPricePointsResponse.method(:from_hash)))
    .execute
end

#read_product_price_point(product_id, price_point_id, currency_prices: nil) ⇒ ProductPricePointResponse

Use this endpoint to retrieve details for a specific product price point. product. When using the handle, it must be prefixed with ‘handle:` the price point. When using the handle, it must be prefixed with `handle:` fetching a product’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 product 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.

Parameters:

  • product_id (Integer)

    Required parameter: The id or handle of the

  • price_point_id (Integer)

    Required parameter: The id or handle of

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

    Optional parameter: When

Returns:



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

def read_product_price_point(product_id,
                             price_point_id,
                             currency_prices: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/products/{product_id}/price_points/{price_point_id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_id, key: 'product_id')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(price_point_id, key: 'price_point_id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(currency_prices, key: 'currency_prices'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('BasicAuth')))
    .response(new_response_handler
                .is_nullify404(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProductPricePointResponse.method(:from_hash)))
    .execute
end

#set_default_price_point_for_product(product_id, price_point_id) ⇒ ProductPricePointResponse

Use this endpoint to make a product price point the default for the product. Note: Custom product price points are not able to be set as the default for a product. product to which the price point belongs product price point

Parameters:

  • product_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

Returns:



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 246

def set_default_price_point_for_product(product_id,
                                        price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/products/{product_id}/price_points/{price_point_id}/default.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_id, key: 'product_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(ProductPricePointResponse.method(:from_hash)))
    .execute
end

#unarchive_product_price_point(product_id, price_point_id) ⇒ ProductPricePointResponse

Use this endpoint to unarchive an archived product price point. product to which the price point belongs product price point

Parameters:

  • product_id (Integer)

    Required parameter: The Chargify id of the

  • price_point_id (Integer)

    Required parameter: The Chargify id of the

Returns:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 125

def unarchive_product_price_point(product_id,
                                  price_point_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/products/{product_id}/price_points/{price_point_id}/unarchive.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_id, key: 'product_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(ProductPricePointResponse.method(:from_hash)))
    .execute
end

#update_product_currency_prices(product_price_point_id, body: nil) ⇒ Array[ProductPricePointCurrencyPrice]

This endpoint allows you to update the ‘price`s of currency prices for a given currency that exists on the product price point. When updating the pricing, it needs to mirror the structure of your primary pricing. If the product price point defines a trial and/or setup fee, each currency must also define a trial and/or setup fee. Note: Currency Prices are not able to be updated for custom product price points. id of the product price point

Parameters:

  • product_price_point_id (Integer)

    Required parameter: The Chargify

  • body (UpdateCurrencyPricesRequest) (defaults to: nil)

    Optional parameter: Example:

Returns:



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

def update_product_currency_prices(product_price_point_id,
                                   body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/product_price_points/{product_price_point_id}/currency_prices.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_price_point_id, key: 'product_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(ProductPricePointCurrencyPrice.method(:from_hash))
                .is_response_array(true))
    .execute
end

#update_product_price_point(product_id, price_point_id, body: nil) ⇒ ProductPricePointResponse

Use this endpoint to update a product price point. Note: Custom product price points are not able to be updated. product. When using the handle, it must be prefixed with ‘handle:` the price point. When using the handle, it must be prefixed with `handle:` Example:

Parameters:

  • product_id (Integer)

    Required parameter: The id or handle of the

  • price_point_id (Integer)

    Required parameter: The id or handle of

  • body (UpdateProductPricePointRequest) (defaults to: nil)

    Optional parameter:

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/advanced_billing/controllers/product_price_points_controller.rb', line 94

def update_product_price_point(product_id,
                               price_point_id,
                               body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/products/{product_id}/price_points/{price_point_id}.json',
                                 Server::DEFAULT)
               .template_param(new_parameter(product_id, key: 'product_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(ProductPricePointResponse.method(:from_hash)))
    .execute
end