Difference between revisions of "MOR API rate get"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(25 intermediate revisions by 8 users not shown)
Line 1: Line 1:
''This feature is available starting from [[MOR_10_documentation | MOR 10]], but was also backported to [[MOR_9_documentation | MOR 9]]''
<!---This functionality is available from MOR 10, but was also backported to MOR 9 --->
=Description=
[[MOR API]] rate_get feature enables you to check rate over http.
<br><br>
<!---From X5--->
Admin able to check Rates of his Users.
Accountant with Permissions able to check Rates of Admins Users.
Reseller able to check Rates of his Users.
<br>
Note if Admin has checked Allow Resellers to use Admin Tariffs in [[API Configuration]] then using this API Reseller can get Rates which belongs to Admin.


=About=
=Configuration=
This feature enables you to check rate over http.


==Enable check check rate over http feature==
Go to '''SETTINGS –> Setup > Settings'''
 
1. Go to '''SETTINGS - Setup -> Settings'''
<br><br>  
<br><br>  
[[File:settings_path.png]]
[[File:settings_path.png]]
<br><br>
<br><br>
2. In Various tab check the marked option:
In API tab ensure that MOR API is enabled and check '''Allow devices to check rate over HTTP''' option :
<br><br>
[[File:Settings_api.png]]
<br><br>
 
=Usage=
 
* From '''MOR X4''' call: '''/api/rate_get'''
* For Backwards-compatibility old name 'rate' is also usable. Call: '''/api/rate'''
* Methods: POST, GET(if allowed, not recomended)
<br><br>
<br><br>
[[File:Settings_various_rate_over_http.png]]
===Parameters===
 
* u - username for authentication. '''From X5 - Required'''. If the u parameter is the username of a simple user, the global setting [https://wiki.kolmisoft.com/index.php/Configuration_from_GUI#Tariffs/Rates 'Show rates for users'] must be enabled.
* username – username of the user whose rates you want to see.
* prefix – prefix number of the destination you want to see.
* by_full_dst - changes ''prefix'' parameter behavior. If parameter ''by_full_dst=1'', then you can pass full numbers in ''prefix'' parameter and best matching rates will be returned. If parameter ''by_full_dst'' is not included, then MOR will return rate for the exact prefix passed in ''prefix'' parameter.
* [[MOR API hash construction | hash]] - SHA1 hash constructed using '''username''' 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>
3. Ensure that MOR API is enabled
 
===Request===
 
HTML POST: http://<SERVER_IP>/billing/api/rate_get?u=admin&username=USERNAME&prefix=PREFIX&hash=HASH
 
Example:
 
http://127.0.0.1/billing/api/rate?u=admin&username=admin&prefix=370&hash=47fc73b6d374bd0a85e3984c1e1623451681569c
<br><br>
<br><br>
[[File:Mor_api_rate_api_cfg.png]]
 
===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.
<br><br>
<br><br>
----
'''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 [[MOR_API_rate_get#Configuration | 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>


==Request==
* User does not belong to the user who is trying to check rate or it was not found in the system:


  HTML POST: http://<SERVER_IP>/billing/api/rate?username=USERNAME&prefix=PREFIX
  <?xml version="1.0" encoding="UTF-8"?>
  Example: http://127.0.0.1/billing/api/rate?username=admin&prefix=370
  <status>
  <error>User was not found</error>
</status>


==Result==
* Accountant must have See Financial Data read or write [[Accountant_permissions | permission]] and Manage Tariffs read or write permission enabled:


  Result is returned in format: rate#destination#prefix
  <?xml version="1.0" encoding="UTF-8"?>
  Example: 35.0#Lithuania#370
  <status>
  <error>You are not authorized to view this page</error>
</status>


==Problems and solutions==
===<status>GET Requests are disabled</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]]

Latest revision as of 08:29, 13 September 2023

Description

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

Admin able to check Rates of his Users. Accountant with Permissions able to check Rates of Admins Users. Reseller able to check Rates of his Users.
Note if Admin has checked Allow Resellers to use Admin Tariffs in API Configuration then using this API Reseller can get Rates which belongs to Admin.

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 api.png

Usage

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



Parameters

  • u - username for authentication. From X5 - Required. If the u parameter is the username of a simple user, the global setting 'Show rates for users' must be enabled.
  • username – username of the user whose rates you want to see.
  • prefix – prefix number of the destination you want to see.
  • by_full_dst - changes prefix parameter behavior. If parameter by_full_dst=1, then you can pass full numbers in prefix parameter and best matching rates will be returned. If parameter by_full_dst is not included, then MOR will return rate for the exact prefix passed in prefix parameter.
  • hash - SHA1 hash constructed using username 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?u=admin&username=USERNAME&prefix=PREFIX&hash=HASH

Example:

http://127.0.0.1/billing/api/rate?u=admin&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>
  • User does not belong to the user who is trying to check rate or it was not found in the system:
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>User was not found</error>
</status>
  • Accountant must have See Financial Data read or write permission and Manage Tariffs read or write permission enabled:
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <error>You are not authorized to view this page</error>
</status>



See Also