Difference between revisions of "M4 API quickstats get"

From Kolmisoft Wiki
Jump to navigationJump to search
 
(14 intermediate revisions by 6 users not shown)
Line 1: Line 1:
=Description=
=Description=


Retrieves today's [[Quick Stats]] and [[Active Calls]] count<br><br>
Retrieves [[Quick Stats]] and [[Active Calls]] for today and a current month<br><br>
 
Data can be retrieved by '''Admin''' only


Data can be retrieved for the '''System Admin''', '''Manager''' and a '''Simple User'''.<br>
'''Note''' Managers can retrieve data only if have permission to manage DASHBOARD> Quick Stats
<br><br>
'''Simpe User Notes:'''
* Active Calls can be retrieved for Simple Users only if a Setting: '''MAINTENANCE > Settings > Show Active Calls for Users''' is on.
* Simple users can only see the number of Calls, Call Duration, Call Price, and Balance.
<br>
<br>


=Usage=
=Usage=


* '''M2''' call: '''/api/quickstats_get'''
* '''M4''' call: '''/api/quickstats_get'''
* Methods: POST, GET(if allowed, not recomended)
* Methods: POST, GET(if allowed, not recommended)
<br><br>
<br><br>
===Parameters===   
===Parameters===   


* [[MOR API hash construction | hash]] - SHA1 hash constructed using API_Secret_Key ([[MOR API hash construction | More described in Constructing hash]]). '''Required''' (if setting '''Disable hash checking''' is not checked).  
* [[MOR API hash construction | hash]] - SHA1 hash constructed using API_Secret_Key ([[MOR API hash construction | More described in Constructing hash]]). '''Required''' (if setting '''Disable hash checking''' is not checked).  
* u - username  for authentication. '''Required'''.  
* u - username  for authentication. '''Required'''.
 
'''Note that u is included in the HASH only if u is not the System Admin'''
<br><br>
<br><br>
===Request===
===Request===


Line 25: Line 32:
  HTML POST: http://<SERVER_IP>/billing/api/quickstats_get?u=admin&hash=e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4
  HTML POST: http://<SERVER_IP>/billing/api/quickstats_get?u=admin&hash=e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4


'''* Note that username (u) is not included in hash'''
'''* Note that username (u) is not included in the hash'''
<br><br>
<br><br>
===Returns===
===Returns===


Line 33: Line 41:
  <?xml version="1.0" encoding="UTF-8"?>
  <?xml version="1.0" encoding="UTF-8"?>
  <page>
  <page>
  <quickstats>
  <quickstats>
    <today>
    <today>
      <calls> Calls count </calls>
      <calls>4</calls>
      <duration> billsec in seconds </duration>
      <duration>345</duration>
      <revenue> revenue today</revenue>
      <revenue>1.4475</revenue>
      <self_cost> expenditure today</self_cost>
      <self_cost>0.6725</self_cost>
      <profit> difference of revenue and expences</profit>
      <profit>0.775</profit>
    </today>
      <margin>54</margin>
    <active_calls>
    </today>
      <total> Active Calls count </total>
    <month>
      <answered_calls> Answered Calls count </answered_calls>
      <calls>19</calls>
    </active_calls>
      <duration>2182</duration>
  </quickstats>
      <revenue>6.04</revenue>
      <self_cost>3.734166</self_cost>
      <profit>2.305834</profit>
      <margin>38</margin>
    </month>
    <active_calls>
      <total>0</total>
      <answered_calls>0</answered_calls>
    </active_calls>
  </quickstats>
  </page>
  </page>


Line 63: Line 80:
   </status>
   </status>
<br><br>
<br><br>
=See also=
=See also=


* [[M2 API]]
* [[M4 API]]

Latest revision as of 11:12, 28 November 2022

Description

Retrieves Quick Stats and Active Calls for today and a current month

Data can be retrieved for the System Admin, Manager and a Simple User.
Note Managers can retrieve data only if have permission to manage DASHBOARD> Quick Stats

Simpe User Notes:

  • Active Calls can be retrieved for Simple Users only if a Setting: MAINTENANCE > Settings > Show Active Calls for Users is on.
  • Simple users can only see the number of Calls, Call Duration, Call Price, and Balance.


Usage

  • M4 call: /api/quickstats_get
  • Methods: POST, GET(if allowed, not recommended)



Parameters

Note that u is included in the HASH only if u is not the System Admin

Request

If API Secret Key = secret

You send:

HTML POST: http://<SERVER_IP>/billing/api/quickstats_get?u=admin&hash=e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4

* Note that username (u) is not included in the hash

Returns

Success: Everything is ok. You get the list of calls if there is any:

<?xml version="1.0" encoding="UTF-8"?>
<page>
  <quickstats>
    <today>
      <calls>4</calls>
      <duration>345</duration>
      <revenue>1.4475</revenue>
      <self_cost>0.6725</self_cost>
      <profit>0.775</profit>
      <margin>54</margin>
    </today>
    <month>
      <calls>19</calls>
      <duration>2182</duration>
      <revenue>6.04</revenue>
      <self_cost>3.734166</self_cost>
      <profit>2.305834</profit>
      <margin>38</margin>
    </month>
    <active_calls>
      <total>0</total>
      <answered_calls>0</answered_calls>
    </active_calls>
  </quickstats>
</page>

Errors:

  • <error>API Requests are disabled</error> – Allow API globally setting is unchecked
  • <error>GET Requests are disabled</error> – Allow GET API setting is unchecked
  • <error>Access Denied</error> – user with such username cannot use this method
  • <error>Bad login</error> – such username does not exist in the database or it was not specified
  • <error>Incorrect hash</error> – Hash was not correct. Check API_Secret_Key and order or params while concatenating hash_string
  • <error>Cannot connect to Elasticsearch</error> – data is not reachable

Example:

 <status>
   <error>API Requests are disabled</error>
 </status>



See also