$workxpress = new Services_WorkXpress();
$workxpress->setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
$request = $workxpress->loadRequest('LookupData');
/* @var $request Services_WorkXpress_Request_LookupData */
array(
'fieldId' => String,
'format' => String stored|text|html,
'reference' => String (Optional),
'formatFormula' => String (Optional),
);
|
|$reference (Optional)| String|An identifier that will be returned with the
response to identify each Relation Type. If the reference is empty a random one will be created. |
**call()** - Executes the API call
===== Example Using Array =====
Below is an example of a LookupData request using an array as input:
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('LookupData');
/* @var $request Services_WorkXpress_Request_LookupData */
// we'll use a map to find our items
$map_definition = 'a1
';
// build the data set array
$data_set_array = array(
'items' => array (
// we can also define any items that we know
array('itemId' => 'u4'),
array('definition' => $map_definition),
),
'fields' => array (
array(
'fieldId' => 'a14',
'reference' => 'Mailing Address',
'format' => 'Services_WorkXpress::FIELD_FORMAT_TEXT,
'formatFormula' => 'Street – City, State ZipCode';
),
array(
'fieldId' => 'a26',
'reference' => 'PhoneNumber',
'format' => 'stored'
),
),
'relations' => array(
array(
'relationType' => 'a47',
'from' => 'target',
'reference' => 'relation',
'fields' => array(
array(
'fieldId' => 'a56',
'format' => Services_WorkXpress::FIELD_FORMAT_HTML,
)
),
),
)
);
$request->addDataSet('A', $data_set_array);
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_LookupData */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('LookupData');
/* @var $request Services_WorkXpress_Request_LookupData */
// we'll use a map to find our items
$map_definition = 'a1
';
// add the first data set
$request->addDataSet('A');
$request->addItem('u4');
$request->addField('a26', Services_WorkXpress::FIELD_FORMAT_STORED,
null, 'PhoneNumber');
// define fields for the relation
$relation_fields = array(
'fieldId' => 'a56',
'format' => Services_WorkXpress::FIELD_FORMAT_HTML,
) // end $relation_fields
// add a second data set
$request->addDataSet('B');
$request->addMap($map_definition);
$request->addField('a14', Services_WorkXpress::FIELD_FORMAT_TEXT,
'Street – City, State ZipCode', 'MailingAddress');
$request->addField('a26', Services_WorkXpress::FIELD_FORMAT_STORED,
null, 'PhoneNumber');
$request->addRelation('a47', 'target', $relation_fields, 'Relation');
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_LookupData */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
array(
'fieldId' => String,
'value' => String,
);
|
|$reference (Optional) |String |An identifier that will be returned with the response to identify each Relation. If the reference is empty a random one will be created. |
**call()** - Executes the API call
===== Example Using Array =====
Below is an example of an AddItem request using an array as input:
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('AddItem');
/* @var $request Services_WorkXpress_Request_AddItem */
// build the data set array
$data_set_array = array(
'item' => array (
array('itemTypeId' => 'a22'),
),
'fields' => array (
array(
'fieldId' => 'a37',
'value' => 123,
),
array(
'fieldId' => 'a39',
'value' => 'Heres some Text!!',
),
),
'relations' => array(
array(
'relationType' => 'a68',
'startingSide' => 'target',
'reference' => 'relation',
'oppositeItemId' => 'u2',
'fields' => array(
array(
'fieldId' => 'a75',
'value' => 'From an array...',
),
),
),
),
); // end $data_set_array
$request->addDataSet('First Item', $data_set_array);
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_AddItem */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('AddItem');
/* @var $request Services_WorkXpress_Request_AddItem */
// add the data set
$request->addDataSet('First Item');
// add the item
$request->addItem('a22');
$request->addField('a37', 123);
$request->addField('a39', 'Heres some Text!!');
// setup the relation fields
$relation_fields = array(
array(
'fieldId' => 'a75',
'value' => 'From an array...'
),
); // end $relation_fields
// add the relation
$request->addRelatoin('a68', 'target', 'u2', $relation_fields,
'relation');
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_AddItem */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
array(
'fieldId' => String,
'value' => String,
);
|
|$reference (Optional)|String |An identifier that will be returned with the response to identify each Relation. If the reference is empty a random one will be created. |
**call()** - Executes the API call
===== Example Using Array =====
Below is an example of an UpdateItem request using an array as input:
// load the Services_WorkXpress object
$workxpress = new Services_WorkXpress();
$workxpress->setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('UpdateItem');
/* @var $request Services_WorkXpress_Request_UpdateItem */
// we'll use a map to find our items
$map_definition = 'a1
';
// create the first data set array
$data_set_array = array(
'items' => array(
array('itemId' => 'u4'),
),
'fields' => array(
array(
'fieldId' => 'a18',
'value' => 'Test Value',
),
),
'relations' => array(
array(
'action' => 'add',
'relationType' => 'a47',
'startingSide' => 'target',
'oppositeItemId' => 'u8',
),
)
); // end $data_set_array
// add the fist data set
$request->addDataSet(Services_WorkXpress::DATA_SET_ACTION_UPDATE, 'A',
$data_set_array);
// create the second data set array
$data_set_array = array(
'items' => array(
array('definition' => $map_definition),
),
'fields' => array(
array(
'fieldId' => 'a32',
'value' => 'Lots of text...',
),
),
'relations' => array(
// recycle all relations of type a47 on the items in this
// data set
array(
'action' => 'recycle',
'relationType' => 'a47',
'startingSide' => 'target',
'oppositeItemId' => 'u8',
'fields' => array(
'fieldId' => 'a56',
'value' => 'for ALL of them?'
),
'reference' => 'relationAdd',
),
// add a relation between the item and item u8 with no fields
array(
'action' => 'add',
'relationType' => 'a47',
'startingSide' => 'target',
'reference' => 'relationRecycle',
),
// update all relations of type a32 on the items in this
// data set
array(
'action' => 'update',
'relationType' => 'a32',
'startingSide' => 'base',
'fields' => array(
'fieldId' => 'a56',
'value' => 'for ALL of them?'
),
'reference' => 'relationUpdate',
),
// delete all relations of type a32 on the items in this
// data set
array(
'action' => 'delete',
'relationType' => 'a65',
'startingSide' => 'base',
'reference' => 'relationDelete',
),
// restore all relations of type a32 on the items in this
// data set
array(
'action' => 'restore',
'relationType' => 'a15',
'startingSide' => 'base',
'reference' => 'relationRestore',
),
)
); // end $data_set_array
// add the second data set
$request->addDataSet(Services_WorkXpress::DATA_SET_ACTION_UPDATE, 'B',
$data_set_array);
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_UpdateItem */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
// load the Services_WorkXpress object
$workxpress = new Services_WorkXpress();
$workxpress->setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('UpdateItem');
/* @var $request Services_WorkXpress_Request_UpdateItem */
// we'll use a map to find our items
$map_definition = 'a1
';
// add the fist data set
$request->addDataSet(Services_WorkXpress::DATA_SET_ACTION_UPDATE, 'A');
$request->addItem('u4');
$request->addField('a18', 'Test Value');
// add a relation between the item and item u8 with no fields
$request->addRelation('add', 'a47', 'target', 'u8');
// add the second data set
$request->addDataSet(Services_WorkXpress::DATA_SET_ACTION_UPDATE, 'B');
$request->addMap($map_definition);
$request->addField('a32', 'Lots of text...');
// recycle all relations of type a47 on the items in this data set
$request->addRelation('recycle', 'a47', 'target', null, array(),
'relationRecycle');
// setup the relation fields
$relation_fields = array(
array(
'fieldId' => 'a56',
'value' => 'for ALL of them?',
),
); // end $relation_fields
// add a new relation to all of the items in this data set, with data
// on the relationship(s)
$request->addRelation('add', 'a47', 'target', 'u8', $relation_fields,
'relationAdd');
// update all relations of type a32 on the items in this data set
$request->addRelation('update', 'a32', 'base', null, $relation_fields,
'relationUpdate');
// delete all relations of type a65 on the items in this data set.
$request->addRelation('delete', 'a65', 'base', null, array(),
'relationDelete');
// restore all relations of type a15 on the items in this data set.
$request->addRelation('restore', 'a15', 'base', null, array(),
'relationRestore');
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_UpdateItem */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_FULLY_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('ExecuteAction');
/* @var $request Services_WorkXpress_Request_ExecuteAction */
// we'll use a map to find our items
$map_definition = 'a121 ';
// build the data set array
$data_set_array = array(
'items' => array (
array('itemId' => 'u4'),
array('itemId' => 'u7'),
array('definition' => $map_definition),
),
'actions' => array (
array(
'actionId' => 'a286',
),
),
); // end $data_set_array
$request->addDataSet('A', $data_set_array);
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_LookupData */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_NOT_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
setAPIVersion(1);
$workxpress->setAuthKey($auth_key);
$workxpress->setRemoteHost('http://example.workxpress.com');
// load the request object
$request = $workxpress->loadRequest('ExecuteAction');
/* @var $request Services_WorkXpress_Request_ExecuteAction */
// we'll use a map to find our items
$map_definition = 'a121 ';
// add the data set
$request->addDataSet('A');
$request->addItem('u4');
$request->addItem('u7');
$request->addMap($map_definition);
$request->addAction('a286');
/** make the API call **/
try
{
// make the call and get the data array
$response = $request->call();
/* @var $response Services_WorkXpress_Response_LookupData */
$items = $response->getDataArray(
Services_WorkXpress::DATA_ARRAY_FORMAT_NOT_COLLAPSED);
// show the results
echo ''.print_r($items, true).'
';
} // end try
catch (Services_WorkXpress_Exception $e)
{
echo 'Error
'.$e->getMessage().'
';
} // end catch Services_WorkXpress_Exception
◦ array(
0 => array(
'reference' => 'account',
'items' => array(
0 => array(
'itemId' => 'u113',
'fields' => array(
0 => array(
'fieldId => 'e52',
'reference' => 'username',
'value' => 'tuser',
),
),
'relations' => array(
0 => array(
'reference' => 'relation',
'id' => 'u115',
'relationType' => 'a41',
'baseItemTypeId' => 'e8',
'baseItemId' => 'u113',
'targetItemTypeId' => 'a28',
'targetItemId' => 'u114',
'fields' => array(
0 => array(
'fieldId => 'a118',
'reference' => 'position',
'value' => 'Developer',
),
),
),
),
),
),
),
);
◦ 'accounts' => array(
'u113' => array(
'fields' => array(
'e52' => array(
'username' => 'tuser'
),
),
'relations' => array(
'relation' => array(
'u115' => array(
'relationType' => 'a41',
'baseItemTypeId' => 'e8',
'baseItemId' => 'u113',
'targetItemTypeId' => 'a28',
'targetItemId' => 'u114',
'fields' => array(
0 => array(
'fieldId => 'a118',
'reference' => 'position',
'value' => 'Developer',
),
),
),
),
),
),
);
◦ 'accounts' => array(
'u113' => array(
'fields' => array(
'e52' => array(
'username' => array(
'fieldId' =>'e52',
'reference' => 'username',
'value' => 'jarmes',
),
),
),
'relations' => array(
'u115' => array(
'reference' => array(
'reference' => 'relation',
'id' => 'u115',
'relationType' => 'a41',
'baseItemTypeId' => 'e8',
'baseItemId' => 'u113',
'targetItemTypeId' => 'a28',
'targetItemId' => 'u114',
'field' => array(
0 => array(
'fieldId => 'a118',
'reference' => 'position',
'value' => 'Developer',
),
),
),
),
),
),
);