94d4885b2ba99b51d40e473e74b1dd5a5652073b
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();
27 'error_message' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
37 * Function returns array of result expected from previous function.
42 function contact_getsingle_expectedresult() {
44 $expectedResult = array(
46 'contact_type' => 'Individual',
47 'contact_sub_type' => '',
49 'display_name' => 'Test Contact',
56 'legal_identifier' => '',
57 'external_identifier' => '',
61 'preferred_communication_method' => '',
62 'preferred_language' => '',
63 'preferred_mail_format' => '',
64 'first_name' => 'Test',
66 'last_name' => 'Contact',
70 'communication_style_id' => '',
75 'deceased_date' => '',
76 'household_name' => '',
77 'organization_name' => '',
79 'contact_is_deleted' => 0,
80 'current_employer' => '',
82 'street_address' => '',
83 'supplemental_address_1' => '',
84 'supplemental_address_2' => '',
86 'postal_code_suffix' => '',
90 'state_province_id' => '',
93 'phone_type_id' => '',
101 'worldregion_id' => '',
102 'world_region' => '',
104 'individual_prefix' => '',
105 'individual_suffix' => '',
106 'communication_style' => '',
108 'state_province_name' => '',
109 'state_province' => '',
114 return $expectedResult;
118 * This example has been generated from the API test suite.
119 * The test that created it is called "testContactGetSingleEntityArray"
120 * and can be found at:
121 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
123 * You can see the outcome of the API tests at
124 * https://test.civicrm.org/job/CiviCRM-master-git/
126 * To Learn about the API read
127 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
129 * Browse the api on your own site with the api explorer
130 * http://MYSITE.ORG/path/to/civicrm/api
132 * Read more about testing here
133 * http://wiki.civicrm.org/confluence/display/CRM/Testing
135 * API Standards documentation:
136 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards