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_communication_method' => '',
59 'preferred_language' => 'en_US',
60 'preferred_mail_format' => 'Both',
61 'first_name' => 'abc3',
63 'last_name' => 'xyz3',
67 'communication_style_id' => '',
72 'deceased_date' => '',
73 'household_name' => '',
74 'organization_name' => '',
76 'contact_is_deleted' => 0,
77 'current_employer' => '',
79 'street_address' => '1 my road',
80 'supplemental_address_1' => '',
81 'supplemental_address_2' => '',
83 'postal_code_suffix' => '',
87 'state_province_id' => '',
90 'phone_type_id' => '',
93 'email' => 'man3@yahoo.com',
98 'worldregion_id' => '',
100 'individual_prefix' => '',
101 'individual_suffix' => '',
102 'communication_style' => '',
104 'state_province_name' => '',
105 'state_province' => '',
108 'api.website.getValue' => 'http://civicrm.org',
109 'api.Contribution.getCount' => 2,
110 'api.CustomValue.get' => array(
117 'latest' => 'value 4',
119 'entity_table' => 'Contact',
122 'entity_table' => 'Contact',
126 'latest' => 'value 3',
129 'entity_table' => 'Contact',
148 'latest' => 'defaultValue',
150 '1' => 'defaultValue',
154 'latest' => 'vegemite',
170 return $expectedResult;
175 * This example has been generated from the API test suite. The test that created it is called
177 * testGetIndividualWithChainedArraysAndMultipleCustom and can be found in
178 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
180 * You can see the outcome of the API tests at
181 * https://test.civicrm.org/job/CiviCRM-master-git/
183 * To Learn about the API read
184 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
186 * Browse the api on your own site with the api explorer
187 * http://MYSITE.ORG/path/to/civicrm/api/explorer
189 * Read more about testing here
190 * http://wiki.civicrm.org/confluence/display/CRM/Testing
192 * API Standards documentation:
193 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards