3 * Test Generated example demonstrating the Contact.get API.
5 * This demonstrates the usage of chained api functions with multiple custom fields.
10 function contact_get_example() {
13 'api.website.getValue' => array(
16 'api.Contribution.getCount' => array(),
17 'api.CustomValue.get' => 1,
21 $result = civicrm_api3('Contact', 'get', $params);
23 catch (CiviCRM_API3_Exception
$e) {
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
30 'error_message' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
40 * Function returns array of result expected from previous function.
45 function contact_get_expectedresult() {
47 $expectedResult = array(
55 'contact_type' => 'Individual',
56 'contact_sub_type' => '',
57 'sort_name' => 'xyz3, abc3',
58 'display_name' => 'abc3 xyz3',
65 'legal_identifier' => '',
66 'external_identifier' => '',
70 'preferred_communication_method' => '',
71 'preferred_language' => 'en_US',
72 'preferred_mail_format' => 'Both',
73 'first_name' => 'abc3',
75 'last_name' => 'xyz3',
79 'communication_style_id' => '',
84 'deceased_date' => '',
85 'household_name' => '',
86 'organization_name' => '',
88 'contact_is_deleted' => 0,
89 'current_employer' => '',
91 'street_address' => '',
92 'supplemental_address_1' => '',
93 'supplemental_address_2' => '',
95 'postal_code_suffix' => '',
99 'state_province_id' => '',
102 'phone_type_id' => '',
105 'email' => 'man3@yahoo.com',
110 'worldregion_id' => '',
111 'world_region' => '',
112 'languages' => 'English (United States)',
113 'individual_prefix' => '',
114 'individual_suffix' => '',
115 'communication_style' => '',
117 'state_province_name' => '',
118 'state_province' => '',
121 'api.website.getValue' => 'http://civicrm.org',
122 'api.Contribution.getCount' => 2,
123 'api.CustomValue.get' => array(
130 'entity_table' => 'Contact',
131 'latest' => 'value 4',
136 'entity_table' => 'Contact',
137 'latest' => 'value 3',
144 'entity_table' => 'Contact',
152 'entity_table' => 'Contact',
160 'entity_table' => 'Contact',
161 'latest' => 'defaultValue',
163 '1' => 'defaultValue',
167 'entity_table' => 'Contact',
168 'latest' => 'vegemite',
174 'entity_table' => 'Contact',
185 return $expectedResult;
189 * This example has been generated from the API test suite.
190 * The test that created it is called "testGetIndividualWithChainedArraysAndMultipleCustom"
191 * and can be found at:
192 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
194 * You can see the outcome of the API tests at
195 * https://test.civicrm.org/job/CiviCRM-master-git/
197 * To Learn about the API read
198 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
200 * Browse the api on your own site with the api explorer
201 * http://MYSITE.ORG/path/to/civicrm/api
203 * Read more about testing here
204 * http://wiki.civicrm.org/confluence/display/CRM/Testing
206 * API Standards documentation:
207 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards