1c202ab54ecb332e1c04b71a82e9e4d460714efa
3 * Test Generated example demonstrating the Contact.getsingle API.
5 * This demonstrates use of the 'format.single_entity_array' param.
6 * This param causes the only contact to be returned as an array without the other levels.
7 * It will be ignored if there is not exactly 1 result
12 function contact_getsingle_example() {
18 $result = civicrm_api3('Contact', 'getsingle', $params);
20 catch (CiviCRM_API3_Exception
$e) {
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
26 'error' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
36 * Function returns array of result expected from previous function.
41 function contact_getsingle_expectedresult() {
43 $expectedResult = array(
45 'contact_type' => 'Individual',
46 'contact_sub_type' => '',
48 'display_name' => 'Test Contact',
55 'legal_identifier' => '',
56 'external_identifier' => '',
60 'preferred_communication_method' => '',
61 'preferred_language' => '',
62 'preferred_mail_format' => '',
63 'first_name' => 'Test',
65 'last_name' => 'Contact',
69 'communication_style_id' => '',
74 'deceased_date' => '',
75 'household_name' => '',
76 'organization_name' => '',
78 'contact_is_deleted' => 0,
79 'current_employer' => '',
81 'street_address' => '',
82 'supplemental_address_1' => '',
83 'supplemental_address_2' => '',
85 'postal_code_suffix' => '',
89 'state_province_id' => '',
92 'phone_type_id' => '',
100 'worldregion_id' => '',
101 'world_region' => '',
102 'individual_prefix' => '',
103 'individual_suffix' => '',
104 'communication_style' => '',
106 'state_province_name' => '',
107 'state_province' => '',
112 return $expectedResult;
116 * This example has been generated from the API test suite.
117 * The test that created it is called "testContactGetSingleEntityArray"
118 * and can be found at:
119 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
121 * You can see the outcome of the API tests at
122 * https://test.civicrm.org/job/CiviCRM-master-git/
124 * To Learn about the API read
125 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
127 * Browse the api on your own site with the api explorer
128 * http://MYSITE.ORG/path/to/civicrm/api
130 * Read more about testing here
131 * http://wiki.civicrm.org/confluence/display/CRM/Testing
133 * API Standards documentation:
134 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards