Difference between revisions of "M4 API tariff rates get"

From Kolmisoft Wiki
Jump to navigationJump to search
Line 27: Line 27:
===Request===
===Request===


We have API Secret Key = 456789, tariff_id = 100
We have API Secret Key = 456789, tariff_id = 2


We send:
We send:


  HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&p=admin&tariff_id=100&hash=71516eea4850f7e0300ac86adf9fb64bca845aa7
  HTML POST: http://<SERVER_IP>/billing/api/get_tariff?u=admin&tariff_id=2&hash=d674ef6e3ceb3145e825709ac2233c710db15af8


'''* Note that username and password are not included in hash'''
Returning XML is put in file. That file is gziped and returned as a response content.
Returning XML is put in file. That file is gziped 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, user can only retrieve to his own tariff.
<br><br>
<br><br>
===Returns===
===Returns===



Revision as of 10:34, 11 October 2016

Description

MOR API Tariff rates - allows to get rates by specific tariff.

Usage

M2 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 which are included into 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 device has both Orginator point and Terminator point tariffs, Originator point tariff is returned. When sending device_id parameter tariff_id parameter is ignored.

* Note that tariff_id or device_id must by provided in to the request


Parameters which are not included into hash:



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 file. That file is gziped and returned as a response content.

Please note that admin can retrieve any tariff, user can only retrieve to his own tariff.

Returns

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>
   <destination_group_type> destination type </destination_group_type>
   <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>
   <subcode> subcode </subcode>
   < code> 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>
  </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>