Introduced in version 18313 of the Switchvox SMB 4.0 Product is support for performing batch requests through the Extend API Core Methods. Many times developers will need to make multiple requests through the Extend API and don’t want to incur the latency of separate HTTP requests for every API method. This is where batch requests come into play. Developers can now include multiple requests into one large batch request and submit that to the Extend API and receive one batch response.
Ok enough theory, time for a real world example.
Say you are a developer and your company has asked you to get some information off the PBX for an extension. This information needs to include: Any extra numbers in an extension’s profile, the call logs for the past two days for an extension, and a list of an extension’s call rule sets.
Without batched requests, this would be 3 separate calls to these Extend API Core Methods:
switchvox.users.profile.extraNumbers.getList
switchvox.users.callLogs.search
switchvox.users.callRuleSets.getList
With batched requests you can include them into one call like this:
<batch_requests>
<request method="switchvox.users.profile.extraNumbers.getList" transation="101">
<parameters>
<account_id>1004</account_id>
</parameters>
</request>
<request method="switchvox.users.callLogs.search" transaction="102">
<parameters>
<start_date>2009-7-28 00:00:00</start_date>
<end_date>2009-07-29 23:59:59</end_date>
<account_id>1004</account_id>
</parameters>
</request>
<request method="switchvox.users.callRuleSets.getList" transaction_id="103">
<parameters>
<call_rule_set_type>unanswered</call_rule_set_type>
<account_id>1004</account_id>
</parameters>
</request>
</batch_requests>
Then your response might look something like this:
<extra_number id="277" number="918585551212" icon_type="cell" icon_path="/images/main/number_icons/cell.png" user_order="1" title="Mobile"/> <event start_time="2009-07-28 07:58:29" type="TALKING" display="Talked to Channel Group ( PRI Lines ) for 29 seconds" /> <event start_time="2009-07-28 07:58:59" type="HANGUP" display="Call was hung up by David Podolsky <104>" /> <event start_time="2009-07-29 09:37:31" type="OUTGOING" display="Dialed number (130)" /> <event start_time="2009-07-29 09:37:31" type="INTERNAL" display="Rang Tim Berg <130>" /> <event start_time="2009-07-29 09:37:33" type="TALKING" display="Talked to Tim Berg <130> for 2 minutes, 54 seconds" /> <event start_time="2009-07-29 09:40:28" type="HANGUP" display="Call was hung up by David Podolsky <104>" /> <owner account_id="1004" /> <time_frame id="0" name="Anytime" /> <rule id="473" order="1" type="call_ringall" date_created="2008-07-11 09:10:14" date_modified="2008-07-11 09:10:14" ring_count="0" preserve_callerid="1" to_number1="105" to_number2="104" call_type="direct_call" to_number3="" /> <rule id="47" order="2" type="voicemail" date_created="2006-03-14 10:06:20" date_modified="2006-03-14 10:06:20" ring_count="5" call_type="direct_call" />
There you have it. 3 requests packed into 1.
