Difference between revisions of "MOR API rate get"

From Kolmisoft Wiki
Jump to navigationJump to search
Line 1: Line 1:
<!---This functionality is available from MOR 10, but was also backported to MOR 9 --->
<!---This functionality is available from MOR 10, but was also backported to MOR 9 --->
=About=
=Description=
This feature enables you to check rate over http.
[[MOR API]] rate_get feature enables you to check rate over http.
<br><br>  
<br><br>  
==Enable check check rate over http feature==
=Configuration=


Go to '''SETTINGS - Setup -> Settings'''
Go to '''SETTINGS –> Setup > Settings'''
<br><br>  
<br><br>  
[[File:settings_path.png]]
[[File:settings_path.png]]
<br><br>
<br><br>
In API tab ensure that MOR API is enabled and check ''' Allow devices to check rate over HTTP''' option :
In API tab ensure that MOR API is enabled and check '''Allow devices to check rate over HTTP''' option :
<br><br>
<br><br>
[[File:Settings_various_rate_over_http.png]]
[[File:Settings_various_rate_over_http.png]]
<br><br>
<br><br>
=Usage=


==Request==
* Call: /api/rate_get
* For Backwards-compatibility old name 'rate' is also usable. Call: /billing/api/rate
* Methods: POST, GET(if allowed, not recomended)
<br><br>
===Parametres===


HTML POST: http://<SERVER_IP>/billing/api/rate?username=USERNAME&prefix=PREFIX
* username – username of user whose rates you want to see.
Example: http://127.0.0.1/billing/api/rate?username=admin&prefix=370
* prefix – prefix number of destination you want to see.
* [[MOR API hash construction | hash]] - SHA1 hash constructed using '''params''' and '''API_Secret_Key''' ([[MOR API hash construction | More described in Constructing hash]]). '''Required''' (if setting '''Disable hash checking''' is not checked).
<br><br>
<br><br>
==Result==
===Request===
 
HTML POST: http://<SERVER_IP>/billing/api/rate_get?username=USERNAME&prefix=PREFIX&hash=HASH
 
Example:
 
http://127.0.0.1/billing/api/rate?username=admin&prefix=370&hash=47fc73b6d374bd0a85e3984c1e1623451681569c
<br><br>
===Returns===
 
'''Success'''
 
Result is returned in format: rate#destination#prefix


  Result is returned in format: rate#destination#prefix
  <?xml version="1.0" encoding="UTF-8"?>
  Example: 35.0#Lithuania#370
  <page>
  <rate>0.987#Lithuania#370</rate>
</page>


'''NOTE.''' MOR API rate method shows rate, which is applied to User. If rate by prefix is not found in [[Custom Rates]], it will be taken from Tariff assigned to User.
'''NOTE.''' MOR API rate method shows rate, which is applied to User. If rate by prefix is not found in [[Custom Rates]], it will be taken from Tariff assigned to User.
<br><br>
<br><br>
==Problems and solutions==
----
'''Errors'''
 
* User do not have rates for selected destination:
 
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Rate was not found</error>
</page>
 
* User with selected username does not exist:
 
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User was not found</error>
</page>
 
* '''Allow devices to check rate over HTTP''' option in API Settings is not set:
 
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Feature disabled</error>
</page>
 
* API is not allowed:


'''<status>GET Requests are disabled</status>''' <!--Rate was not found - useris neturi rates tam prefixui -->
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>API Requests are disabled</error>
</status>


*You did not enabled GET API - enable it as described in step 3
<br><br>
<br><br>
=See Also=
=See Also=


* [[MOR API]]
* [[MOR API]]

Revision as of 08:05, 25 May 2013

Description

MOR API rate_get feature enables you to check rate over http.

Configuration

Go to SETTINGS –> Setup –> Settings

Settings path.png

In API tab ensure that MOR API is enabled and check Allow devices to check rate over HTTP option :

Settings various rate over http.png

Usage

  • Call: /api/rate_get
  • For Backwards-compatibility old name 'rate' is also usable. Call: /billing/api/rate
  • Methods: POST, GET(if allowed, not recomended)



Parametres

  • username – username of user whose rates you want to see.
  • prefix – prefix number of destination you want to see.
  • hash - SHA1 hash constructed using params and API_Secret_Key ( More described in Constructing hash). Required (if setting Disable hash checking is not checked).



Request

HTML POST: http://<SERVER_IP>/billing/api/rate_get?username=USERNAME&prefix=PREFIX&hash=HASH

Example:

http://127.0.0.1/billing/api/rate?username=admin&prefix=370&hash=47fc73b6d374bd0a85e3984c1e1623451681569c



Returns

Success

Result is returned in format: rate#destination#prefix

<?xml version="1.0" encoding="UTF-8"?>
<page>
 <rate>0.987#Lithuania#370</rate>
</page>

NOTE. MOR API rate method shows rate, which is applied to User. If rate by prefix is not found in Custom Rates, it will be taken from Tariff assigned to User.


Errors

  • User do not have rates for selected destination:
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Rate was not found</error>
</page>
  • User with selected username does not exist:
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>User was not found</error>
</page>
  • Allow devices to check rate over HTTP option in API Settings is not set:
<?xml version="1.0" encoding="UTF-8"?>
<page>
  <error>Feature disabled</error>
</page>
  • API is not allowed:
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>API Requests are disabled</error>
</status>



See Also