3 * Test Generated example of using contact getsingle API
4 * This demonstrates use of the 'format.single_entity_array' param.
5 /* This param causes the only contact to be returned as an array without the other levels.
6 /* it will be ignored if there is not exactly 1 result *
8 function contact_getsingle_example(){
14 $result = civicrm_api3('contact', 'getsingle', $params);
16 catch (CiviCRM_API3_Exception
$e) {
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
28 * Function returns array of result expected from previous function
30 function contact_getsingle_expectedresult(){
32 $expectedResult = array(
34 'contact_type' => 'Individual',
35 'contact_sub_type' => '',
37 'display_name' => 'Test Contact',
44 'legal_identifier' => '',
45 'external_identifier' => '',
49 'preferred_mail_format' => '',
50 'first_name' => 'Test',
52 'last_name' => 'Contact',
59 'deceased_date' => '',
60 'household_name' => '',
61 'organization_name' => '',
63 'contact_is_deleted' => 0,
64 'current_employer' => '',
66 'street_address' => '',
67 'supplemental_address_1' => '',
68 'supplemental_address_2' => '',
70 'postal_code_suffix' => '',
74 'state_province_id' => '',
77 'phone_type_id' => '',
85 'worldregion_id' => '',
87 'individual_prefix' => '',
88 'individual_suffix' => '',
90 'state_province_name' => '',
91 'state_province' => '',
96 return $expectedResult;
101 * This example has been generated from the API test suite. The test that created it is called
103 * testContactGetSingle_entity_array and can be found in
104 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
106 * You can see the outcome of the API tests at
107 * http://tests.dev.civicrm.org/trunk/results-api_v3
109 * To Learn about the API read
110 * http://book.civicrm.org/developer/current/techniques/api/
112 * and review the wiki at
113 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
115 * Read more about testing here
116 * http://wiki.civicrm.org/confluence/display/CRM/Testing
118 * API Standards documentation:
119 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards