Skip to content

Commit

Permalink
examples of coreBOSCP REST enhancements: issues #160, #159, #161, #15…
Browse files Browse the repository at this point in the history
…6, #155, #151, #150
  • Loading branch information
joebordes committed May 18, 2014
1 parent 6b6f75e commit 2d37da0
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 0 deletions.
23 changes: 23 additions & 0 deletions testcode/304_getWebserviceEntityID.php
@@ -0,0 +1,23 @@
<?php
//name of the module for which to retrieve the entity ID
$moduleName = 'Contacts';

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'vtyiicpng_getWSEntityId',
"entityName"=>$moduleName);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Update",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response, true);
$dmsg.= debugmsg("Webservice response Update",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('failed:'.$jsonResponse['error']['message']);
echo 'failed!';
} else {
$savedObject = $jsonResponse['result'];
var_dump($savedObject);
}
?>
24 changes: 24 additions & 0 deletions testcode/308_getReferenceName.php
@@ -0,0 +1,24 @@
<?php
// list of IDS for which to retrieve the reference
$ids = array('12x22','12x23','10x32','10x33');
$pids = serialize($ids); // to convert into a flat object string

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'getReferenceValue',
"id"=>$pids);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Update",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response, true);
$dmsg.= debugmsg("Webservice response Update",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('failed:'.$jsonResponse['error']['message']);
echo 'failed!';
} else {
$refs = unserialize($jsonResponse['result']);
var_dump($refs);
}
?>
23 changes: 23 additions & 0 deletions testcode/312_getPicklistValues.php
@@ -0,0 +1,23 @@
<?php
//name of the module for which to retrieve the entity ID
$moduleName = 'Accounts';

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'getPicklistValues',
"module"=>$moduleName);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Update",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response, true);
$dmsg.= debugmsg("Webservice response Update",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('failed:'.$jsonResponse['error']['message']);
echo 'failed!';
} else {
$vals = unserialize($jsonResponse['result']);
var_dump($vals);
}
?>
23 changes: 23 additions & 0 deletions testcode/316_getUITypes.php
@@ -0,0 +1,23 @@
<?php
//name of the module for which to retrieve the entity ID
$moduleName = 'Accounts';

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'getUItypes',
"module"=>$moduleName);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Update",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response, true);
$dmsg.= debugmsg("Webservice response Update",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('failed:'.$jsonResponse['error']['message']);
echo 'failed!';
} else {
$vals = unserialize($jsonResponse['result']);
var_dump($vals);
}
?>
23 changes: 23 additions & 0 deletions testcode/320_GetFilterFields.php
@@ -0,0 +1,23 @@
<?php
//name of the module for which to retrieve the entity ID
$moduleName = 'Accounts';

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'getfilterfields',
"module"=>$moduleName);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Update",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response, true);
$dmsg.= debugmsg("Webservice response Update",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('failed:'.$jsonResponse['error']['message']);
echo 'failed!';
} else {
$vals = $jsonResponse['result'];
var_dump($vals);
}
?>
28 changes: 28 additions & 0 deletions testcode/324_getTranslate.php
@@ -0,0 +1,28 @@
<?php
$translate = array(
'Accounts'=>'Accounts',
'LBL_LIST_ACCOUNT_NAME'=>'LBL_LIST_ACCOUNT_NAME',
'Portal User'=>'Client Portal User',
);
//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'gettranslation',
"totranslate"=> json_encode($translate),
'language'=>'es_es',
'module'=>'Contacts'
);

//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) GetTranslation",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response,true);
$dmsg.= debugmsg("Webservice response GetTranslation",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('GetTranslation failed: '.$jsonResponse['error']['message']);
echo 'GetTranslation failed!';
} else {
var_dump($jsonResponse['result']);
}
?>
30 changes: 30 additions & 0 deletions testcode/328_addTicketFaqComment.php
@@ -0,0 +1,30 @@
<?php
//fill in the details of the contacts.userId is obtained from loginResult.
$contactData = array('comments'=>'Valiantwstut2', 'from_portal'=>0,'parent_id'=>'4x22');
//encode the object in JSON format to communicate with the server.
$objectJson = json_encode($contactData);
$dmsg.= debugmsg("Create, sending in",$objectJson);

//name of the module for which the entry has to be created.
$moduleName = 'ModComments';

//sessionId is obtained from loginResult.
$params = array("sessionName"=>$cbSessionID, "operation"=>'addTicketFaqComment',
"id"=>'10x64', "values"=>$objectJson);
//Create must be POST Request.
$response = $httpc->send_post_data($cbURL, $params, true);
$dmsg.= debugmsg("Raw response (json) Create",$response);

//decode the json encode response from the server.
$jsonResponse = json_decode($response,true);
$dmsg.= debugmsg("Webservice response Create",$jsonResponse);

if($jsonResponse['success']==false) {
$dmsg.= debugmsg('create failed:'.$jsonResponse['error']['message']);
echo 'create failed!';
} else {
$savedObject = $jsonResponse['result'];
$id = $savedObject['id'];
var_dump($savedObject);
}
?>

0 comments on commit 2d37da0

Please sign in to comment.