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',
70 'deceased_date' => '',
71 'household_name' => '',
72 'organization_name' => '',
74 'contact_is_deleted' => 0,
75 'current_employer' => '',
77 'street_address' => '1 my road',
78 'supplemental_address_1' => '',
79 'supplemental_address_2' => '',
81 'postal_code_suffix' => '',
85 'state_province_id' => '',
88 'phone_type_id' => '',
91 'email' => 'man3@yahoo.com',
96 'worldregion_id' => '',
98 'individual_prefix' => '',
99 'individual_suffix' => '',
101 'state_province_name' => '',
102 'state_province' => '',
105 'api.website.getValue' => 'http://civicrm.org',
106 'api.Contribution.getCount' => 2,
107 'api.CustomValue.get' => array(
114 'latest' => 'value 4',
116 'entity_table' => 'Contact',
119 'entity_table' => 'Contact',
123 'latest' => 'value 3',
126 'entity_table' => 'Contact',
145 'latest' => 'defaultValue',
147 '1' => 'defaultValue',
151 'latest' => 'vegemite',
167 return $expectedResult;
172 * This example has been generated from the API test suite. The test that created it is called
174 * testGetIndividualWithChainedArraysAndMultipleCustom and can be found in
175 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
177 * You can see the outcome of the API tests at
178 * https://test.civicrm.org/job/CiviCRM-master-git/
180 * To Learn about the API read
181 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
183 * Browse the api on your own site with the api explorer
184 * http://MYSITE.ORG/path/to/civicrm/api/explorer
186 * Read more about testing here
187 * http://wiki.civicrm.org/confluence/display/CRM/Testing
189 * API Standards documentation:
190 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards