3 * Test Generated example of using contact get API
4 * /*this demonstrates the usage of chained api functions. A variety of techniques are used *
6 function contact_get_example(){
9 'api.website.getValue' => array(
12 'api.Contribution.getCount' => array(),
13 'api.CustomValue.get' => 1,
17 $result = civicrm_api3('contact', 'get', $params);
19 catch (CiviCRM_API3_Exception
$e) {
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
31 * Function returns array of result expected from previous function
33 function contact_get_expectedresult(){
35 $expectedResult = array(
43 'contact_type' => 'Individual',
44 'contact_sub_type' => '',
45 'sort_name' => 'xyz3, abc3',
46 'display_name' => 'abc3 xyz3',
53 'legal_identifier' => '',
54 'external_identifier' => '',
58 'preferred_mail_format' => 'Both',
59 'first_name' => 'abc3',
61 'last_name' => 'xyz3',
68 'deceased_date' => '',
69 'household_name' => '',
70 'organization_name' => '',
72 'contact_is_deleted' => 0,
73 'current_employer' => '',
75 'street_address' => '',
76 'supplemental_address_1' => '',
77 'supplemental_address_2' => '',
79 'postal_code_suffix' => '',
83 'state_province_id' => '',
86 'phone_type_id' => '',
89 'email' => 'man3@yahoo.com',
94 'worldregion_id' => '',
96 'individual_prefix' => '',
97 'individual_suffix' => '',
99 'state_province_name' => '',
100 'state_province' => '',
103 'api.website.getValue' => 'http://civicrm.org',
104 'api.Contribution.getCount' => 2,
105 'api.CustomValue.get' => array(
112 'latest' => 'value 4',
114 'entity_table' => 'Contact',
117 'entity_table' => 'Contact',
121 'latest' => 'value 3',
124 'entity_table' => 'Contact',
129 'latest' => 'defaultValue',
132 '2' => 'defaultValue',
136 'latest' => 'defaultValue',
138 '1' => 'defaultValue',
139 '2' => 'defaultValue',
143 'latest' => 'defaultValue',
145 '1' => 'defaultValue',
149 'latest' => 'vegemite',
155 'latest' => 'defaultValue',
157 '1' => 'defaultValue',
165 return $expectedResult;
170 * This example has been generated from the API test suite. The test that created it is called
172 * testGetIndividualWithChainedArraysAndMultipleCustom and can be found in
173 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
175 * You can see the outcome of the API tests at
176 * http://tests.dev.civicrm.org/trunk/results-api_v3
178 * To Learn about the API read
179 * http://book.civicrm.org/developer/current/techniques/api/
181 * and review the wiki at
182 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
184 * Read more about testing here
185 * http://wiki.civicrm.org/confluence/display/CRM/Testing
187 * API Standards documentation:
188 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards