3 * Test Generated example of using contact get API.
5 * /*this demonstrates the usage of chained api functions. A variety of techniques are used
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();
29 'error' => $errorMessage,
30 'error_code' => $errorCode,
31 'error_data' => $errorData,
39 * Function returns array of result expected from previous function.
44 function contact_get_expectedresult() {
46 $expectedResult = array(
54 'contact_type' => 'Individual',
55 'contact_sub_type' => '',
56 'sort_name' => 'xyz3, abc3',
57 'display_name' => 'abc3 xyz3',
64 'legal_identifier' => '',
65 'external_identifier' => '',
69 'preferred_communication_method' => '',
70 'preferred_language' => 'en_US',
71 'preferred_mail_format' => 'Both',
72 'first_name' => 'abc3',
74 'last_name' => 'xyz3',
78 'communication_style_id' => '',
83 'deceased_date' => '',
84 'household_name' => '',
85 'organization_name' => '',
87 'contact_is_deleted' => 0,
88 'current_employer' => '',
90 'street_address' => '1 my road',
91 'supplemental_address_1' => '',
92 'supplemental_address_2' => '',
94 'postal_code_suffix' => '',
98 'state_province_id' => '',
101 'phone_type_id' => '',
104 'email' => 'man3@yahoo.com',
109 'worldregion_id' => '',
110 'world_region' => '',
111 'individual_prefix' => '',
112 'individual_suffix' => '',
113 'communication_style' => '',
115 'state_province_name' => '',
116 'state_province' => '',
119 'api.website.getValue' => 'http://civicrm.org',
120 'api.Contribution.getCount' => 2,
121 'api.CustomValue.get' => array(
128 'latest' => 'value 4',
130 'entity_table' => 'Contact',
133 'entity_table' => 'Contact',
137 'latest' => 'value 3',
140 'entity_table' => 'Contact',
159 'latest' => 'defaultValue',
161 '1' => 'defaultValue',
165 'latest' => 'vegemite',
181 return $expectedResult;
185 * This example has been generated from the API test suite.
186 * The test that created it is called
187 * testGetIndividualWithChainedArraysAndMultipleCustom
188 * and can be found in
189 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
191 * You can see the outcome of the API tests at
192 * https://test.civicrm.org/job/CiviCRM-master-git/
194 * To Learn about the API read
195 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
197 * Browse the api on your own site with the api explorer
198 * http://MYSITE.ORG/path/to/civicrm/api
200 * Read more about testing here
201 * http://wiki.civicrm.org/confluence/display/CRM/Testing
203 * API Standards documentation:
204 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards