Class: AdvancedBilling::InsightsController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::InsightsController
- Defined in:
- lib/advanced_billing/controllers/insights_controller.rb
Overview
InsightsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#list_mrr_movements(options = {}) ⇒ ListMRRResponse
Lists your site's MRR movements.
-
#list_mrr_per_subscription(options = {}) ⇒ SubscriptionMRRResponse
Lists your site's current MRR, including plan and usage breakouts split per subscription.
-
#read_mrr(at_time: nil, subscription_id: nil) ⇒ MRRResponse
Returns your site's current MRR, including plan and usage breakouts.
-
#read_site_stats ⇒ SiteSummary
Returns basic site-level stats.
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
#list_mrr_movements(options = {}) ⇒ ListMRRResponse
Lists your site's MRR movements.
Understanding MRR movements
This endpoint will aid in accessing your site's [MRR
Report](https://maxio.zendesk.com/hc/en-us/articles/24285894587021-MRR-Ana
lytics) data.
Whenever a subscription event occurs that causes your site's MRR to change
(such as a signup or upgrade), we record an MRR movement. These records
are accessible via the MRR Movements endpoint.
Each MRR Movement belongs to a subscription and contains a timestamp,
category, and an amount. line_items represent the subscription's product
configuration at the time of the movement.
Plan & Usage Breakouts
In the MRR Report UI, we support a setting to [include or
exclude](https://maxio.zendesk.com/hc/en-us/articles/24285894587021-MRR-An
alytics#displaying-component-based-metered-usage-in-mrr) usage revenue. In
the MRR APIs, responses include plan and usage breakouts.
Plan includes revenue from:
- Products
- Quantity-Based Components
- On/Off Components Usage includes revenue from:
- Metered Components
- Prepaid Usage Components
results by subscription.
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 50; any per_page value over 50 will be changed to 50. Use in queryper_page=20. in which results are returned. Use in querydirection=asc.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/controllers/insights_controller.rb', line 94 def list_mrr_movements( = {}) warn 'Endpoint list_mrr_movements in InsightsController is deprecated' @api_call .request(new_request_builder(HttpMethodEnum::GET, '/mrr_movements.json', Server::PRODUCTION) .query_param(new_parameter(['subscription_id'], key: 'subscription_id')) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['direction'], key: 'direction')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListMRRResponse.method(:from_hash))) .execute end |
#list_mrr_per_subscription(options = {}) ⇒ SubscriptionMRRResponse
Lists your site's current MRR, including plan and usage breakouts split
per subscription.
MRR per subscription operation
format to request MRR for a historic time. Use in query:
at_time=2022-01-10T10:00:00-05:00.
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.
which results are returned. Records are ordered by subscription_id in
ascending order by default. Use in query direction=desc.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/advanced_billing/controllers/insights_controller.rb', line 134 def list_mrr_per_subscription( = {}) warn 'Endpoint list_mrr_per_subscription in InsightsController is deprec'\ 'ated' @api_call .request(new_request_builder(HttpMethodEnum::GET, '/subscriptions_mrr.json', Server::PRODUCTION) .query_param(new_parameter(['filter'], key: 'filter')) .query_param(new_parameter(['at_time'], key: 'at_time')) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['direction'], key: 'direction')) .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(SubscriptionMRRResponse.method(:from_hash)) .local_error_template('400', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', SubscriptionsMrrErrorResponseException)) .execute end |
#read_mrr(at_time: nil, subscription_id: nil) ⇒ MRRResponse
Returns your site's current MRR, including plan and usage breakouts. ISO8601 format to request MRR for a historic time. subscription in order to limit results.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/advanced_billing/controllers/insights_controller.rb', line 38 def read_mrr(at_time: nil, subscription_id: nil) warn 'Endpoint read_mrr in InsightsController is deprecated' @api_call .request(new_request_builder(HttpMethodEnum::GET, '/mrr.json', Server::PRODUCTION) .query_param(new_parameter(at_time, key: 'at_time')) .query_param(new_parameter(subscription_id, key: 'subscription_id')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(MRRResponse.method(:from_hash))) .execute end |
#read_site_stats ⇒ SiteSummary
Returns basic site-level stats. This API call only answers with JSON responses. An XML version is not provided.
Stats Documentation
There currently is not a complimentary matching set of documentation that compliments this endpoint. However, each Site's dashboard will reflect the summary of information provided in the Stats response.
https://subdomain.chargify.com/dashboard
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/advanced_billing/controllers/insights_controller.rb', line 19 def read_site_stats @api_call .request(new_request_builder(HttpMethodEnum::GET, '/stats.json', Server::PRODUCTION) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(SiteSummary.method(:from_hash))) .execute end |