Class: AdvancedBilling::ReasonCodesController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::ReasonCodesController
- Defined in:
- lib/advanced_billing/controllers/reason_codes_controller.rb
Overview
ReasonCodesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_reason_code(body: nil) ⇒ ReasonCodeResponse
Creates a reason code for a given site.
-
#delete_reason_code(reason_code_id) ⇒ OkResponse
Deletes a reason code from the Churn Reason Codes.
-
#list_reason_codes(options = {}) ⇒ Array[ReasonCodeResponse]
Lists all current churn codes for a given site.
-
#read_reason_code(reason_code_id) ⇒ ReasonCodeResponse
Returns a particular churn reason code for a given site by its unique ID.
-
#update_reason_code(reason_code_id, body: nil) ⇒ ReasonCodeResponse
Updates an existing reason code for a given site.
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
#create_reason_code(body: nil) ⇒ ReasonCodeResponse
Creates a reason code for a given site. Reason Codes are a way to gain a high-level view of why your customers are cancelling the subscription to your product or service. Add a set of churn reason codes to be displayed in-app and/or the Maxio Billing Portal. As your subscribers decide to cancel their subscription, learn why they decided to cancel. For more information, see [Churn Reason Codes](https://maxio.zendesk.com/hc/en-us/articles/24286647554701-Churn-Re ason-Codes). description here
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 21 def create_reason_code(body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/reason_codes.json', Server::PRODUCTION) .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(ReasonCodeResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#delete_reason_code(reason_code_id) ⇒ OkResponse
Deletes a reason code from the Churn Reason Codes. This code will be immediately removed. This action is not reversible. id of the reason code
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 135 def delete_reason_code(reason_code_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/reason_codes/{reason_code_id}.json', Server::PRODUCTION) .template_param(new_parameter(reason_code_id, key: 'reason_code_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(OkResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException)) .execute end |
#list_reason_codes(options = {}) ⇒ Array[ReasonCodeResponse]
Lists all current churn codes for a given site.
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.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 54 def list_reason_codes( = {}) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/reason_codes.json', Server::PRODUCTION) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReasonCodeResponse.method(:from_hash)) .is_response_array(true) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#read_reason_code(reason_code_id) ⇒ ReasonCodeResponse
Returns a particular churn reason code for a given site by its unique ID. id of the reason code
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 78 def read_reason_code(reason_code_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/reason_codes/{reason_code_id}.json', Server::PRODUCTION) .template_param(new_parameter(reason_code_id, key: 'reason_code_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(ReasonCodeResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException)) .execute end |
#update_reason_code(reason_code_id, body: nil) ⇒ ReasonCodeResponse
Updates an existing reason code for a given site. id of the reason code description here
103 104 105 106 107 108 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/reason_codes_controller.rb', line 103 def update_reason_code(reason_code_id, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/reason_codes/{reason_code_id}.json', Server::PRODUCTION) .template_param(new_parameter(reason_code_id, key: 'reason_code_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(ReasonCodeResponse.method(:from_hash)) .local_error_template('404', 'Not Found:\'{$response.body}\'', APIException) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |