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
# Reason Codes Intro ReasonCodes are a way to gain a high level view of why your customers are cancelling the subcription to your product or service.
-
#delete_reason_code(reason_code_id) ⇒ ReasonCodesJsonResponse
This method gives a merchant the option to delete one reason code from the Churn Reason Codes.
-
#list_reason_codes(options = {}) ⇒ Array[ReasonCodeResponse]
This method gives a merchant the option to retrieve a list of all of the current churn codes for a given site.
-
#read_reason_code(reason_code_id) ⇒ ReasonCodeResponse
This method gives a merchant the option to retrieve a list of a particular code for a given Site by providing the unique numerical ID of the code.
-
#update_reason_code(reason_code_id, body: nil) ⇒ ReasonCodeResponse
This method gives a merchant the option to update an existing reason code for a given site.
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_reason_code(body: nil) ⇒ ReasonCodeResponse
# Reason Codes Intro ReasonCodes are a way to gain a high level view of why your customers are cancelling the subcription to your product or service. Add a set of churn reason codes to be displayed in-app and/or the Chargify Billing Portal. As your subscribers decide to cancel their subscription, learn why they decided to cancel. ## Reason Code Documentation Full documentation on how Reason Codes operate within Chargify can be located under the following links. [Churn Reason Codes](chargify.zendesk.com/hc/en-us/articles/4407896775579#churn- reason-codes) ## Create Reason Code This method gives a merchant the option to create a reason codes for a given Site.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 138 def create_reason_code(body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/reason_codes.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(ReasonCodeResponse.method(:from_hash)) .local_error('422', 'Unprocessable Entity (WebDAV)', ErrorListResponseException)) .execute end |
#delete_reason_code(reason_code_id) ⇒ ReasonCodesJsonResponse
This method gives a merchant the option to delete one reason code from the Churn Reason Codes. This code will be immediately removed. This action is not reversable. reason code
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 40 def delete_reason_code(reason_code_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/reason_codes/{reason_code_id}.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReasonCodesJsonResponse.method(:from_hash)) .local_error('404', 'Not Found', APIException)) .execute end |
#list_reason_codes(options = {}) ⇒ Array[ReasonCodeResponse]
This method gives a merchant the option to retrieve a list of all of the 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`.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 74 def list_reason_codes( = {}) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/reason_codes.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReasonCodeResponse.method(:from_hash)) .is_response_array(true)) .execute end |
#read_reason_code(reason_code_id) ⇒ ReasonCodeResponse
This method gives a merchant the option to retrieve a list of a particular code for a given Site by providing the unique numerical ID of the code. reason code
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 14 def read_reason_code(reason_code_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/reason_codes/{reason_code_id}.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReasonCodeResponse.method(:from_hash)) .local_error('404', 'Not Found', APIException)) .execute end |
#update_reason_code(reason_code_id, body: nil) ⇒ ReasonCodeResponse
This method gives a merchant the option to update an existing reason code for a given site. reason code
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/advanced_billing/controllers/reason_codes_controller.rb', line 97 def update_reason_code(reason_code_id, body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/reason_codes/{reason_code_id}.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ReasonCodeResponse.method(:from_hash)) .local_error('404', 'Not Found', APIException)) .execute end |