Difference between revisions of "M4 API tariff rates get"
From Kolmisoft Wiki
Jump to navigationJump to search
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
=Description= | =Description= | ||
Tariff rates - allows getting rates by a specific tariff. | |||
<br><br> | <br><br> | ||
=Usage= | =Usage= | ||
''' | '''M4''' call: '''/api/tariff_rates_get''' | ||
* For Backwards-compatibility old name 'get_tariff' is also usable. Call: '''/api/get_tariff''' | * For Backwards-compatibility old name 'get_tariff' is also usable. Call: '''/api/get_tariff''' | ||
* Methods: POST, GET(if allowed, not recomended) | * Methods: POST, GET(if allowed, not recomended) | ||
<br><br> | <br><br> | ||
===Parametres=== | ===Parametres=== | ||
Parameters | Parameters that are '''included''' into the hash (if it is used): | ||
* tariff_id - tariff_id parameter returns tariff and rates by specific tariff_id. | * tariff_id - tariff_id parameter returns tariff and rates by specific tariff_id. | ||
* device_id - tariff parameter returns tariff and rates by device id. If device has both | * device_id - tariff parameter returns tariff and rates by device id. If a device has both Originator point and Terminator point tariffs, the Originator point tariff is returned. When sending device_id parameter tariff_id parameter is ignored. | ||
'''* Note that tariff_id or device_id must | '''* Note that tariff_id or device_id is required and must be provided into the request'''. | ||
<br> | <br> | ||
Parameters | Parameters that are not included in the hash: | ||
* u - username for authentication. '''Required'''. | * u - username for authentication. '''Required'''. | ||
* [[MOR API hash construction | hash]] - SHA1 hash constructed using '''tariff_id''' and/or '''user_id''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''. | * [[MOR API hash construction | hash]] - SHA1 hash constructed using '''tariff_id''' and/or '''user_id''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required'''. | ||
Line 33: | Line 33: | ||
HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&tariff_id=2&hash=d674ef6e3ceb3145e825709ac2233c710db15af8 | HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&tariff_id=2&hash=d674ef6e3ceb3145e825709ac2233c710db15af8 | ||
Returning XML is put in file. That file is | Returning XML is put in a file. That file is gzipped and returned as response content. | ||
Please note that admin can retrieve any tariff, user can only retrieve | Please note that the admin can retrieve any tariff, the user can only retrieve his own tariff. | ||
<br><br> | <br><br> | ||
Line 41: | Line 41: | ||
'''Success''' | '''Success''' | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
Line 78: | Line 50: | ||
<rates> | <rates> | ||
<rate> | <rate> | ||
<direction> '' </direction> | |||
<destination> '' </destination> | |||
<prefix> '' </prefix> | |||
<tariff_rate> '' </tariff_rate> | |||
<con_fee> '' </con_fee> | |||
<increment> '' </increment> | |||
<min_time> '' </min_time> | |||
<start_time> '' </start_time> | |||
<end_time> '' </end_time> | |||
<daytype> '' <daytype/> | |||
</rate> | </rate> | ||
</rates> | </rates> | ||
</page> | </page> | ||
---- | ---- | ||
Line 107: | Line 77: | ||
</page> | </page> | ||
* User was not found by username | * User was not found by username. Use the correct username. Make sure that username (u). | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
Line 122: | Line 92: | ||
<error>Incorrect hash</error> | <error>Incorrect hash</error> | ||
</status> | </status> | ||
* Parameters device_id or tariff_id must be provided. | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<status> | |||
<error>device_id or tariff_id was not found</error> | |||
</status> | |||
* User can access only his own tariffs. | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<status> | |||
<error>Access Denied</error> | |||
</status> | |||
* Manager does not have permission to access tariffs functionality. | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<status> | |||
<error>You are not authorized to manage tariffs</error> | |||
</status> | |||
<br><br> | <br><br> |
Latest revision as of 11:15, 28 November 2022
Description
Tariff rates - allows getting rates by a specific tariff.
Usage
M4 call: /api/tariff_rates_get
- For Backwards-compatibility old name 'get_tariff' is also usable. Call: /api/get_tariff
- Methods: POST, GET(if allowed, not recomended)
Parametres
Parameters that are included into the hash (if it is used):
- tariff_id - tariff_id parameter returns tariff and rates by specific tariff_id.
- device_id - tariff parameter returns tariff and rates by device id. If a device has both Originator point and Terminator point tariffs, the Originator point tariff is returned. When sending device_id parameter tariff_id parameter is ignored.
* Note that tariff_id or device_id is required and must be provided into the request.
Parameters that are not included in the hash:
- u - username for authentication. Required.
- hash - SHA1 hash constructed using tariff_id and/or user_id and API_Secret_Key ( More described in Constructing hash). Required.
Request
We have API Secret Key = 456789, tariff_id = 2
We send:
HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&tariff_id=2&hash=d674ef6e3ceb3145e825709ac2233c710db15af8
Returning XML is put in a file. That file is gzipped and returned as response content.
Please note that the admin can retrieve any tariff, the user can only retrieve his own tariff.
Returns
Success
<?xml version="1.0" encoding="UTF-8"?> <page> <pagename> Tariff </pagename> <tariff_name> tariff name </tariff_name> <purpose> tariff type </purpose> <currency> currency </currency> <rates> <rate> <direction> </direction> <destination> </destination> <prefix> </prefix> <tariff_rate> </tariff_rate> <con_fee> </con_fee> <increment> </increment> <min_time> </min_time> <start_time> </start_time> <end_time> </end_time> <daytype> <daytype/> </rate> </rates> </page>
Errors
- Tariff was not found.
<?xml version="1.0" encoding="UTF-8"?> <page> <status> <error>No tariff found</error> </status> </page>
- User was not found by username. Use the correct username. Make sure that username (u).
<?xml version="1.0" encoding="UTF-8"?> <page> <status> <error>Bad login</error> </status> </page>
- Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string.
<?xml version="1.0" encoding="UTF-8"?> <status> <error>Incorrect hash</error> </status>
- Parameters device_id or tariff_id must be provided.
<?xml version="1.0" encoding="UTF-8"?> <status> <error>device_id or tariff_id was not found</error> </status>
- User can access only his own tariffs.
<?xml version="1.0" encoding="UTF-8"?> <status> <error>Access Denied</error> </status>
- Manager does not have permission to access tariffs functionality.
<?xml version="1.0" encoding="UTF-8"?> <status> <error>You are not authorized to manage tariffs</error> </status>