From 0013d84fa8cac7a62bac78f9eef3df236c6e2512 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 11 Jun 2021 20:41:10 +0000 Subject: [PATCH] Added more variables for add_did/update_did Non-Agent API functions git-svn-id: svn://192.168.202.10@3453 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/docs/NON-AGENT_API.txt | 27 ++- agc_2-X/trunk/www/vicidial/non_agent_api.php | 200 ++++++++++++++++++- 2 files changed, 219 insertions(+), 8 deletions(-) diff --git a/agc_2-X/trunk/docs/NON-AGENT_API.txt b/agc_2-X/trunk/docs/NON-AGENT_API.txt index 70aa56c7..0ebf7454 100644 --- a/agc_2-X/trunk/docs/NON-AGENT_API.txt +++ b/agc_2-X/trunk/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-05-17 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-06-11 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -187,6 +187,7 @@ Changes: 210402-1102 - Added 'custom_fields_delete' option for update_list function 210406-1047 - Added 'dialable_count' option to list_info function 210517-1850 - Added phone_code as modifiable field in update_lead function +210611-1610 - Added more variables for add_did/update_did functions API Functions use the 'function' variable @@ -2178,6 +2179,12 @@ server_ip - must be all numbers and dots, max 15 characters group - a valid in-group group_id menu_id - a valid call menu menu_id filter_clean_cid_number - 1-20 characters +call_handle_method - If the route is IN_GROUP, this is the call handle method(CID, CIDLOOKUP, CLOSER, etc...), default 'CID' +agent_search_method - If the route is IN_GROUP, this is the agent search method(LO = Load-Balanced-Overflow, LB = Load-Balanced, SO = Server-Only), default 'LB' +list_id - If the route is IN_GROUP, this is the list ID(3-12 digits), default '999' +entry_list_id - If the route is IN_GROUP, this is the entry list ID(1-12 digits), default '0' +campaign_id - If the route is IN_GROUP, this is the campaign ID, default '' +phone_code - If the route is IN_GROUP, this is the phone code, default '1' Example URL strings for API calls: http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=add_did&did_pattern=%2B1727555112&did_description=Updated+test+API+DID&active=Y @@ -2200,6 +2207,12 @@ ERROR: add_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPTION ERROR: add_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test ERROR: add_did MENU ID MUST BE A VALID CALL MENU IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test_menu ERROR: add_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: add_did CALL HANDLE METHOD MUST BE FROM 3 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: add_did AGENT SEARCH METHOD MUST BE 2 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: add_did LIST ID MUST BE FROM 3 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: add_did ENTRY LIST ID MUST BE FROM 1 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|999999999999999 +ERROR: add_did CAMPAIGN MUST BE FROM 1 TO 8 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|TESTCAMPS +ERROR: add_did PHONE CODE MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|99999999999 SUCCESS: add_did DID HAS BEEN ADDED - 6666|1101 @@ -2229,6 +2242,12 @@ server_ip - must be all numbers and dots, max 15 characters group - a valid in-group group_id menu_id - a valid call menu menu_id filter_clean_cid_number - 1-20 characters +call_handle_method - If the route is IN_GROUP, this is the call handle method(CID, CIDLOOKUP, CLOSER, etc...), default 'CID' +agent_search_method - If the route is IN_GROUP, this is the agent search method(LO = Load-Balanced-Overflow, LB = Load-Balanced, SO = Server-Only), default 'LB' +list_id - If the route is IN_GROUP, this is the list ID(3-12 digits), default '999' +entry_list_id - If the route is IN_GROUP, this is the entry list ID(1-12 digits), default '0' +campaign_id - If the route is IN_GROUP, this is the campaign ID, default '' +phone_code - If the route is IN_GROUP, this is the phone code, default '1' delete_did - Can be one of these: 'Y','N' (default is 'N') Example URL strings for API calls: @@ -2253,6 +2272,12 @@ ERROR: update_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPT ERROR: update_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test ERROR: update_did MENU ID MUST BE A VALID CALL MENU IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test_menu ERROR: update_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666| +ERROR: update_did CALL HANDLE METHOD MUST BE FROM 3 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: update_did AGENT SEARCH METHOD MUST BE 2 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: update_did LIST ID MUST BE FROM 3 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|1 +ERROR: update_did ENTRY LIST ID MUST BE FROM 1 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|999999999999999 +ERROR: update_did CAMPAIGN MUST BE FROM 1 TO 8 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|TESTCAMPS +ERROR: update_did PHONE CODE MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|99999999999 NOTICE: update_did NO UPDATES DEFINED - 6666| SUCCESS: update_did DID HAS BEEN DELETED - 6666|23|1101 SUCCESS: update_did DID HAS BEEN UPDATED - 6666|1101 diff --git a/agc_2-X/trunk/www/vicidial/non_agent_api.php b/agc_2-X/trunk/www/vicidial/non_agent_api.php index 78854514..18bae39d 100644 --- a/agc_2-X/trunk/www/vicidial/non_agent_api.php +++ b/agc_2-X/trunk/www/vicidial/non_agent_api.php @@ -177,10 +177,11 @@ # 210402-1102 - Added 'custom_fields_delete' option for update_list function # 210406-1047 - Added 'dialable_count' option to list_info function # 210517-1850 - Added phone_code as modifiable field in update_lead function +# 210611-1610 - Added more variables for add_did/update_did functions # -$version = '2.14-154'; -$build = '210517-1850'; +$version = '2.14-155'; +$build = '210611-1610'; $api_url_log = 0; $startMS = microtime(); @@ -641,6 +642,11 @@ if (isset($_GET["custom_fields_delete"])) {$custom_fields_delete=$_GET["custom elseif (isset($_POST["custom_fields_delete"])) {$custom_fields_delete=$_POST["custom_fields_delete"];} if (isset($_GET["dialable_count"])) {$dialable_count=$_GET["dialable_count"];} elseif (isset($_POST["dialable_count"])) {$dialable_count=$_POST["dialable_count"];} +if (isset($_GET["call_handle_method"])) {$call_handle_method=$_GET["call_handle_method"];} + elseif (isset($_POST["call_handle_method"])) {$call_handle_method=$_POST["call_handle_method"];} +if (isset($_GET["agent_search_method"])) {$agent_search_method=$_GET["agent_search_method"];} + elseif (isset($_POST["agent_search_method"])) {$agent_search_method=$_POST["agent_search_method"];} + header ("Content-type: text/html; charset=utf-8"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 @@ -919,6 +925,8 @@ $custom_fields_add = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_add); $custom_fields_update = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_update); $custom_fields_delete = preg_replace('/[^_0-9a-zA-Z]/','',$custom_fields_delete); $dialable_count = preg_replace('/[^_0-9a-zA-Z]/','',$dialable_count); +$call_handle_method = preg_replace('/[^_0-9a-zA-Z]/','',$call_handle_method); +$agent_search_method = preg_replace('/[^_0-9a-zA-Z]/','',$agent_search_method); $USarea = substr($phone_number, 0, 3); $USprefix = substr($phone_number, 3, 3); @@ -7675,7 +7683,13 @@ if ($function == 'add_did') $groupSQL=''; $menu_idSQL=''; $filter_clean_cid_numberSQL=''; - + $call_handle_methodSQL=''; + $agent_search_methodSQL=''; + $list_idSQL=''; + $entry_list_idSQL=''; + $campaign_idSQL=''; + $phone_codeSQL=''; + if (strlen($did_description) > 0) { if ( (strlen($did_description) > 50) or (strlen($did_description) < 6) ) @@ -7856,8 +7870,92 @@ if ($function == 'add_did') else {$filter_clean_cid_numberSQL = " ,filter_clean_cid_number='$filter_clean_cid_number'";} } + if (strlen($call_handle_method) > 0) + { + if ( (strlen($call_handle_method) > 20) or (strlen($call_handle_method) < 3) ) + { + $result = 'ERROR'; + $result_reason = "add_did CALL HANDLE METHOD MUST BE FROM 3 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$call_handle_method"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$call_handle_methodSQL = " ,call_handle_method='$call_handle_method'";} + } + if (strlen($agent_search_method) > 0) + { + if ( (strlen($agent_search_method) > 2) or (strlen($agent_search_method) < 2) ) + { + $result = 'ERROR'; + $result_reason = "add_did AGENT SEARCH METHOD MUST BE 2 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$agent_search_method"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$agent_search_methodSQL = " ,agent_search_method='$agent_search_method'";} + } + if (strlen($list_id) > 0) + { + if ( (strlen($list_id) > 14) or (strlen($list_id) < 3) ) + { + $result = 'ERROR'; + $result_reason = "add_did LIST ID MUST BE FROM 3 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD"; + $data = "$list_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$list_idSQL = " ,list_id='$list_id'";} + } + if (strlen($entry_list_id) > 0) + { + if ( (strlen($entry_list_id) > 14) or (strlen($entry_list_id) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did ENTRY LIST ID MUST BE FROM 1 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD"; + $data = "$entry_list_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$entry_list_idSQL = " ,entry_list_id='$entry_list_id'";} + } + if (strlen($campaign_id) > 0) + { + if ( (strlen($campaign_id) > 8) or (strlen($campaign_id) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did CAMPAIGN MUST BE FROM 1 TO 8 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$campaign_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$campaign_idSQL = " ,campaign_id='$campaign_id'";} + } + if (strlen($phone_code) > 0) + { + if ( (strlen($phone_code) > 10) or (strlen($phone_code) < 1) ) + { + $result = 'ERROR'; + $result_reason = "add_did PHONE CODE MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$phone_code"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$phone_codeSQL = " ,phone_code='$phone_code'";} + } - $addSQL = "$did_patternSQL$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$menu_idSQL$filter_clean_cid_numberSQL"; + $addSQL = "$did_patternSQL$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$menu_idSQL$filter_clean_cid_numberSQL$call_handle_methodSQL$agent_search_methodSQL$list_idSQL$entry_list_idSQL$campaign_idSQL$phone_codeSQL"; $addSQL = preg_replace("/^ ,/",'',$addSQL); $stmt="INSERT INTO vicidial_inbound_dids SET $addSQL;"; @@ -7994,6 +8092,12 @@ if ($function == 'update_did') $groupSQL=''; $menu_idSQL=''; $filter_clean_cid_numberSQL=''; + $call_handle_methodSQL=''; + $agent_search_methodSQL=''; + $list_idSQL=''; + $entry_list_idSQL=''; + $campaign_idSQL=''; + $phone_codeSQL=''; if ($delete_did == 'Y') { @@ -8210,10 +8314,92 @@ if ($function == 'update_did') else {$filter_clean_cid_numberSQL = " ,filter_clean_cid_number='$filter_clean_cid_number'";} } + if (strlen($call_handle_method) > 0) + { + if ( (strlen($call_handle_method) > 20) or (strlen($call_handle_method) < 3) ) + { + $result = 'ERROR'; + $result_reason = "update_did CALL HANDLE METHOD MUST BE FROM 3 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$call_handle_method"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$call_handle_methodSQL = " ,call_handle_method='$call_handle_method'";} + } + if (strlen($agent_search_method) > 0) + { + if ( (strlen($agent_search_method) > 2) or (strlen($agent_search_method) < 2) ) + { + $result = 'ERROR'; + $result_reason = "update_did AGENT SEARCH METHOD MUST BE 2 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$agent_search_method"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$agent_search_methodSQL = " ,agent_search_method='$agent_search_method'";} + } + if (strlen($list_id) > 0) + { + if ( (strlen($list_id) > 14) or (strlen($list_id) < 3) ) + { + $result = 'ERROR'; + $result_reason = "update_did LIST ID MUST BE FROM 3 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD"; + $data = "$list_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$list_idSQL = " ,list_id='$list_id'";} + } + if (strlen($entry_list_id) > 0) + { + if ( (strlen($entry_list_id) > 14) or (strlen($entry_list_id) < 1) ) + { + $result = 'ERROR'; + $result_reason = "update_did ENTRY LIST ID MUST BE FROM 1 TO 14 DIGITS, THIS IS AN OPTIONAL FIELD"; + $data = "$entry_list_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$entry_list_idSQL = " ,entry_list_id='$entry_list_id'";} + } + if (strlen($campaign_id) > 0) + { + if ( (strlen($campaign_id) > 8) or (strlen($campaign_id) < 1) ) + { + $result = 'ERROR'; + $result_reason = "update_did CAMPAIGN MUST BE FROM 1 TO 8 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$campaign_id"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$campaign_idSQL = " ,campaign_id='$campaign_id'";} + } + if (strlen($phone_code) > 0) + { + if ( (strlen($phone_code) > 10) or (strlen($phone_code) < 1) ) + { + $result = 'ERROR'; + $result_reason = "update_did PHONE CODE MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD"; + $data = "$phone_code"; + echo "$result: $result_reason: |$user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + else + {$phone_codeSQL = " ,phone_code='$phone_code'";} + } - - $updateSQL = "$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$menu_idSQL$filter_clean_cid_numberSQL"; - + $updateSQL = "$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$menu_idSQL$filter_clean_cid_numberSQL$call_handle_methodSQL$agent_search_methodSQL$list_idSQL$entry_list_idSQL$campaign_idSQL$phone_codeSQL"; if (strlen($updateSQL)< 3) {