Difference between revisions of "MOR API tariff rates get"
From Kolmisoft Wiki
Jump to navigationJump to search
(19 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
=Description= | =Description= | ||
<!---This functionality is available from MOR 11---> | <!---This functionality is available from MOR 11---> | ||
Exports Wholesale Tariff rates | |||
<br> | <br> | ||
If Admin has checked Allow Resellers to use Admin Tariffs in [[API Configuration]] then using this API Reseller can get Tariffs which belongs to Admin. | If Admin has checked Allow Resellers to use Admin Tariffs in [[API Configuration]] then using this API Reseller can get Tariffs which belongs to Admin. | ||
Line 8: | Line 8: | ||
=Usage= | =Usage= | ||
* | * 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> | ||
=== | ===Parameters=== | ||
* u - username for authentication. '''Required'''. | * u - username for authentication. '''Required'''. | ||
* tariff_id - user tariff id (option for admin or reseller). If not sent, user gets his tariff rates and custom rates. | * tariff_id - user tariff id (option for admin or reseller). If not sent, user gets his tariff rates and custom rates. | ||
* user_id - this specifies user id whose custom rates and tariffs to show. When sending user_id parameter tariff_id parameter is ignored. | * user_id - this specifies user id whose custom rates and tariffs to show. When sending user_id parameter tariff_id parameter is ignored. | ||
* additional_retail_info=1 - this includes additional information about retail tariffs, destination names and prefixes for these destinations. | |||
* [[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'''. | ||
<br><br> | <br><br> | ||
===Request=== | ===Request=== | ||
Line 28: | Line 30: | ||
'''* Note that username and password are not included in hash''' | '''* Note that username and password are not included in hash''' | ||
Returning XML is put in file. That file is | Returning XML is put in file. That file is ziped and returned as a response content. | ||
Please note that admin can retrieve any tariff, reseller - only users' tariffs and the one assigned to him by admin and user can only retrieve to his own tariff. | Please note that admin can retrieve any tariff, reseller - only users' tariffs and the one assigned to him by admin and user can only retrieve to his own tariff. | ||
Line 35: | Line 37: | ||
===Returns=== | ===Returns=== | ||
<span style="color:#ff0000">'''IMPORTANT: response is returned in the archived zip format. Make sure to extract it from the zip format first.'''</span> | |||
<br><br> | |||
<!-- | |||
Example in PHP how to extract from GZIP [http://php.net/manual/en/function.gzdecode.php here]. */ | |||
--> | |||
<br> | |||
'''Success''' | '''Success''' | ||
Line 48: | Line 56: | ||
<destination> | <destination> | ||
<destination_group_name> ''name'' </destination_group_name> | <destination_group_name> ''name'' </destination_group_name> | ||
<rate> | <rate> | ||
<duration> ''duration'' </duration> | <duration> ''duration'' </duration> | ||
Line 62: | Line 69: | ||
</rates> | </rates> | ||
</page> | </page> | ||
* Retail with '''additional_retail_info = 1''': | |||
<?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> | |||
<destination> | |||
<destination_group_name> ''name'' </destination_group_name> | |||
<destinations> | |||
<destination_name>''Destination name''</destination_name> | |||
<prefix>''Prefix''</prefix> | |||
</destinations> | |||
<rate> | |||
<duration> ''duration'' </duration> | |||
<type> ''type'' </type> | |||
<round_by> ''round by'' </round_by> | |||
<tariff_rate> ''rate'' </tariff_rate> | |||
<start_time> ''start time'' </start_time> | |||
<end_time> ''end time'' </end_time> | |||
<from> ''from'' </from> | |||
<daytype> ''daytype'' </daytype> | |||
</rate> | |||
</destination> | |||
</rates> | |||
</page> | |||
* Wholesale: | * Wholesale: | ||
Line 76: | Line 113: | ||
<destination> ''destination'' </destination> | <destination> ''destination'' </destination> | ||
<prefix> ''prefix'' </prefix> | <prefix> ''prefix'' </prefix> | ||
<code> ''code'' </code> | |||
< code> ''code'' </code> | |||
<tariff_rate> ''rate'' </tariff_rate> | <tariff_rate> ''rate'' </tariff_rate> | ||
<con_fee> ''connection fee'' </con_fee> | <con_fee> ''connection fee'' </con_fee> | ||
Line 85: | Line 121: | ||
<end_time> ''end time'' </end_time> | <end_time> ''end time'' </end_time> | ||
<daytype> ''daytype'' </daytype> | <daytype> ''daytype'' </daytype> | ||
<effective_from> ''effective from date'' </effective_from> | |||
</rate> | </rate> | ||
</rates> | </rates> | ||
Line 118: | Line 155: | ||
</status> | </status> | ||
<br><br> | <br><br> | ||
=See also= | |||
* [[API returns garbage]] |
Latest revision as of 14:14, 5 November 2019
Description
Exports Wholesale Tariff rates
If Admin has checked Allow Resellers to use Admin Tariffs in API Configuration then using this API Reseller can get Tariffs which belongs to Admin.
Usage
- 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)
Parameters
- u - username for authentication. Required.
- tariff_id - user tariff id (option for admin or reseller). If not sent, user gets his tariff rates and custom rates.
- user_id - this specifies user id whose custom rates and tariffs to show. When sending user_id parameter tariff_id parameter is ignored.
- additional_retail_info=1 - this includes additional information about retail tariffs, destination names and prefixes for these destinations.
- 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 = 100
We send:
HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&user_id=5&tariff_id=100&hash=71516eea4850f7e0300ac86adf9fb64bca845aa7
* Note that username and password are not included in hash Returning XML is put in file. That file is ziped and returned as a response content.
Please note that admin can retrieve any tariff, reseller - only users' tariffs and the one assigned to him by admin and user can only retrieve to his own tariff.
Returns
IMPORTANT: response is returned in the archived zip format. Make sure to extract it from the zip format first.
Success
- Retail:
<?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> <destination> <destination_group_name> name </destination_group_name> <rate> <duration> duration </duration> <type> type </type> <round_by> round by </round_by> <tariff_rate> rate </tariff_rate> <start_time> start time </start_time> <end_time> end time </end_time> <from> from </from> <daytype> daytype </daytype> </rate> </destination> </rates> </page>
- Retail with additional_retail_info = 1:
<?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> <destination> <destination_group_name> name </destination_group_name> <destinations> <destination_name>Destination name</destination_name> <prefix>Prefix</prefix> </destinations> <rate> <duration> duration </duration> <type> type </type> <round_by> round by </round_by> <tariff_rate> rate </tariff_rate> <start_time> start time </start_time> <end_time> end time </end_time> <from> from </from> <daytype> daytype </daytype> </rate> </destination> </rates> </page>
- Wholesale:
<?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 </direction>
<destination> destination </destination>
<prefix> prefix </prefix>
code
<tariff_rate> rate </tariff_rate>
<con_fee> connection fee </con_fee>
<increment> increment </increment>
<min_time> minimal time </min_time>
<start_time> start time </start_time>
<end_time> end time </end_time>
<daytype> daytype </daytype>
<effective_from> effective from date </effective_from>
</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 and password. Use correct username and password. Make sure that username (u) and password (p) are specified.
<?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>