4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact getsingle API.
11 * This demonstrates use of the 'format.single_entity_array' param.
12 /* This param causes the only contact to be returned as an array without the other levels.
13 /* it will be ignored if there is not exactly 1 result
18 function contact_getsingle_example() {
24 $result = civicrm_api3('contact', 'getsingle', $params);
26 catch (CiviCRM_API3_Exception
$e) {
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
32 'error' => $errorMessage,
33 'error_code' => $errorCode,
34 'error_data' => $errorData,
42 * Function returns array of result expected from previous function.
47 function contact_getsingle_expectedresult() {
49 $expectedResult = array(
51 'contact_type' => 'Individual',
52 'contact_sub_type' => '',
54 'display_name' => 'Test Contact',
61 'legal_identifier' => '',
62 'external_identifier' => '',
66 'preferred_communication_method' => '',
67 'preferred_language' => '',
68 'preferred_mail_format' => '',
69 'first_name' => 'Test',
71 'last_name' => 'Contact',
75 'communication_style_id' => '',
80 'deceased_date' => '',
81 'household_name' => '',
82 'organization_name' => '',
84 'contact_is_deleted' => 0,
85 'current_employer' => '',
87 'street_address' => '',
88 'supplemental_address_1' => '',
89 'supplemental_address_2' => '',
91 'postal_code_suffix' => '',
95 'state_province_id' => '',
98 'phone_type_id' => '',
106 'worldregion_id' => '',
107 'world_region' => '',
108 'individual_prefix' => '',
109 'individual_suffix' => '',
110 'communication_style' => '',
112 'state_province_name' => '',
113 'state_province' => '',
118 return $expectedResult;
122 * This example has been generated from the API test suite.
123 * The test that created it is called
124 * testContactGetSingle_entity_array
125 * and can be found in
126 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
128 * You can see the outcome of the API tests at
129 * https://test.civicrm.org/job/CiviCRM-master-git/
131 * To Learn about the API read
132 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
134 * Browse the api on your own site with the api explorer
135 * http://MYSITE.ORG/path/to/civicrm/api/explorer
137 * Read more about testing here
138 * http://wiki.civicrm.org/confluence/display/CRM/Testing
140 * API Standards documentation:
141 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards