Difference between revisions of "MOR API"

From Kolmisoft Wiki
Jump to navigationJump to search
Line 60: Line 60:
* [[MOR API create_device_api| device_create]] - create device
* [[MOR API create_device_api| device_create]] - create device
* [[MOR API delete_device_api| delete_device]] - delete device
* [[MOR API delete_device_api| delete_device]] - delete device
==Monitorings addon==
===Installing ruby script===
1. Connect to SQL and add email if it is still not in the database:
<code>INSERT INTO emails (`name`, `format`, `body`, `owner_id`, `subject`, `template`, `callcenter`, `date_created`) VALUES('monitoring_activation', 'plain', x'4d6f6e69746f72696e672064657461696c733a0d0a0d0a547970653a203c253d6d6f6e69746f72696e675f74797065253e0d0a42616c616e63653a203c253d6d6f6e69746f72696e675f616d6f756e74253e0d0a426c6f636b3a203c253d6d6f6e69746f72696e675f626c6f636b253e0d0a0d0a41666665637465642075736572733a0d0a0d0a3c253d6d6f6e69746f72696e675f7573657273253e', 0,'Monitoring was activated', 1, 0, '2010-06-11 12:54:58');</code>
2. Execute this line: <code>update calls set calldate = now();</code>
3. Create a monitoring with low charge. See the [[Monitorings]] page for information how to do it.
4. Choose sending an email.
5. Turn on API. Specifying the key is optional, it depends on the way you execute the script.
6. Execute the script: <code>ruby /home/mor/lib/scripts/monitoring_script.rb -ahttp://192.168.0.30/billing/api/ma_activate -p mor -umor -nmor -kkey
</code>
In this example we assume that API key is "key".
7. Check what is in <code>/tmp/monitoring_debug.txt</code> file. It should be similar to:
<code>
*******************************************************************************************************
2010-06-12 10:24:19 --- STARTING MONITORING
found users size : 4 in monitoring id :1
2010-06-12 10:24:21 --- MONITORING notice send to http://192.168.0.30/billing/api/ma_activate
<?xml version="1.0" encoding="UTF-8"?>
<status>
  <success>success</success>
  <users>
    <user>
      <id>0</id>
      <status> email sent</status>
    </user>
    <user>
      <id>2</id>
      <status> email sent</status>
    </user>
    <user>
      <id>3</id>
      <status> email sent</status>
    </user>
    <user>
      <id>5</id>
      <status> email sent</status>
    </user>
  </users>
</status>
</code>
8. Check for errors. If there is something wrong it will be showed (for example if API is off).


==Phonebooks==
==Phonebooks==

Revision as of 19:03, 2 June 2012

About

MOR API lets other software interact with MOR without knowing the internal structure of the database (DB) and other logic.

MOR accepts requests by HTML POST and returns results in XML.


MOR users that are allowed to use MOR API

  • Admin
  • Reseller
  • Accountant



Functions

API Related

Login

  • login - logs user in to MOR.
  • logout - logs user out from MOR.

User

Callback

Accounting

  • invoices - retrieves a list of invoices in a selected time period.

Calls

  • user_calls - retrieves a list of calls in a selected time period for a user/device.

Balance

Rates

Device

Monitorings addon

Installing ruby script

1. Connect to SQL and add email if it is still not in the database:

INSERT INTO emails (`name`, `format`, `body`, `owner_id`, `subject`, `template`, `callcenter`, `date_created`) VALUES('monitoring_activation', 'plain', x'4d6f6e69746f72696e672064657461696c733a0d0a0d0a547970653a203c253d6d6f6e69746f72696e675f74797065253e0d0a42616c616e63653a203c253d6d6f6e69746f72696e675f616d6f756e74253e0d0a426c6f636b3a203c253d6d6f6e69746f72696e675f626c6f636b253e0d0a0d0a41666665637465642075736572733a0d0a0d0a3c253d6d6f6e69746f72696e675f7573657273253e', 0,'Monitoring was activated', 1, 0, '2010-06-11 12:54:58');

2. Execute this line: update calls set calldate = now();

3. Create a monitoring with low charge. See the Monitorings page for information how to do it.

4. Choose sending an email.

5. Turn on API. Specifying the key is optional, it depends on the way you execute the script.

6. Execute the script: ruby /home/mor/lib/scripts/monitoring_script.rb -ahttp://192.168.0.30/billing/api/ma_activate -p mor -umor -nmor -kkey

In this example we assume that API key is "key".

7. Check what is in /tmp/monitoring_debug.txt file. It should be similar to:

2010-06-12 10:24:19 --- STARTING MONITORING found users size : 4 in monitoring id :1 2010-06-12 10:24:21 --- MONITORING notice send to http://192.168.0.30/billing/api/ma_activate <?xml version="1.0" encoding="UTF-8"?> <status>

 <success>success</success>
 <users>
   <user>
     <id>0</id>
     <status> email sent</status>
   </user>
   <user>
     <id>2</id>
     <status> email sent</status>
   </user>
   <user>
     <id>3</id>
     <status> email sent</status>
   </user>
   <user>
     <id>5</id>
     <status> email sent</status>
   </user>
 </users>

</status>

8. Check for errors. If there is something wrong it will be showed (for example if API is off).

Phonebooks

Payments list

Credit notes

Financial statements

Payments

Calling cards

MOR version


Examples





HTML POST

All requests are in a similar format:

HTML POST: http://<SERVER_IP>/billing/api/<function>?u=username&p=password
  • username/password - the user name and password of the user who is asking for the data.

If the user has 'admin' rights, he will get more results and can perform more actions compared to a user who does not have such rights.




See also