Desc: Clear all account subscribers balance for a given month and re-rate all the subscribers lines and reevaluate the subscriber's balance. Useful on plan change during the month and is effective from the start of the month instead on next month.
General operation:
This api will:
- Clear the subscribers balances of the effective billrun from the DB.
- Clear the billing data from the lines that was generated by the subscribers.
- Place the cleared lines back into the queue.
- After calling this API you will need to wait for the lines to be reprocessed by the system (up-to 4 hours).
- The account id list used to clear current balance cache.
Path : http://host/api/resetlines
HTTP Method: POST
Input :
- aid = comma separated list of accounts numbers : aid=223456,554321,12344,11111
- billrun_key = the billrun key of the billing cycle to reset
- query = an optional json array query used to apply a deeper lines filter. Sample as follows:
query=[[{
"field_name":"usaget",
"op":"$eq",
"value":"call"
}]]
Output format : JSON
Output structure :
- status :
- 1 = successful, all relevant account balances were reset successfully
- 0 = failed, there was an error see the desc field for more information.
- desc = description of the results
- input = the input object that was received.
Error output:
- all errors will have the “status” field === 0.
- all errors will have the “desc” field contain the error description.
- Possible errors :
- “Please supply at least one aid” : Invalid or missing aid input field .
- “Illegal aid” : none of the provided AIDs were found in the billing system or the aid input was invalid.
Desc: queries all billing lines by aid (or sid) on specific billrun
Status: deprecated call since version 5.0
Path: http://<host>/api/query
HTTP Method: GET
Input:
- aid (mandatory when no sid)- account id or list of account ids (separated by comma). Max: 1000
- sid (mandatory when no aid)- subscriber id or list of subscriber ids (separated by comma). Max: 1000
- billrun [optional]- effective billrun date (format: YYYYmm)
- query [optional] - the query to run into the DB (can be associative array). The query can be JSON or array.
Examples of query value that filter flat type or source api and promotion flag is on:
- query[$or][0][type]=flat&
query[$or][1][source]=api&
query[$or][1][service_name][$regex]=PROMOTION
- query={”$or”:[{“type”:”flat”},{”source”:”api”,”promotion”:true}]}
Note: use JSON when value-type is the case. With JSON the variable is type sensitive (i.e. boolean or number). Otherwise, if you send query through HTTP GET, all values will be passed as string.
- from [optional; since version 4.0]- the minimum datetime (ISO format), effect record time (utc field), compare >=
- to [optional; since version 4.0] - the maximum datetime (ISO format), effect record time (utc field), compare <=
- size [optional] - page size (default 1000), max size is 10,000
- page [optional] - pagination the results, when more than 1,000 results
- distinct [optional] - field to distinct the results set (no need to page nor size in case of distinct)
Output format: JSON
Output structure:
- status :
- 1 = successful
- 0 = failed, there was an error see the desc field for more information.
- desc = description of the results
- input = the input object that was received.
- details = array of billing lines
Error output:
- all errors will have the “status” field === 0.
- all errors will have the “desc” field contain the error description.
- Possible errors :
- “Require to supply aid or sid” : Invalid or missing sid and aid input fields.
- “Maximum of sid is <X>” : too many SIDs were asked in a single request.
- “Maximum of aid is <X>” : too many AIDs were asked in a single request.
Desc: query a specific billrun by aid or sid
Path: http://<host>/api/queryaggregate
Input:
- aid - account id or list of account ids (separated by comma). Max: 1000
- sid - subscriber id or list of subscriber ids (separated by comma). Max: 1000
- billrun - effective billrun date (format: YYYYmm), can be string or array of billrun items
- query [optional] - queries the DB (JSON or associative array).
Examples of query value:
- query[$or][0][type]=flat&
query[$or][1][source]=api&
query[$or][1][service_name][$regex]=PROMOTION
- query={”$or”:[{“type”:”flat”},{”source”:”api”,”promotion”:true}]}
Note: use JSON is for cases when value-type is the case. With JSON the variable is type sensitive (i.e. boolean or number). Otherwise, In case if you send query through HTTP GET, all values will be passed as string.
- aggregate [optional] - aggregate function. array of [key (result column name) -> array [key-value]] that represents a function to aggregate by (see example). The default aggregation method counts the number of lines (in case this parameter isn’t provided or left empty)
useful aggregation methods: $sum, $avg, $max, $min
- Note: in case count required just use $max of 1 (this will sum each line as 1)
- groupby [optional] - group by field(s). Array of fields that will be aggregate by
Output format: JSON
Output structure:
- status :
- 1 = successful
- 0 = failed, there was an error see the desc field for more information.
- desc = description of the results
- input = the input objects that were received.
- details = array of results
Example:
http://billrun/api/queryaggregate?sid=153531&query={"usaget":"data","type":"ggsn"}&groupby={"usaget":"$usaget","served":"$served_imsi"}&aggregate={"usagev":{"$sum":"$usagev"}}
Error output:
- all errors will have the “status” field === 0.
- all errors will have the “desc” field contain the error description.
- Possible errors :
- “Require to supply aid or sid” : Invalid or missing sid and aid input fields.
- “Maximum of sid is <X>” : to many SIDs were asked in a single request.
- “Maximum of aid is <X>” : to many AIDs were asked in a single request.