4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact get API.
11 * /*this demonstrates the usage of chained api functions. A variety of techniques are used
16 function contact_get_example() {
19 'api.website.getValue' => array(
22 'api.Contribution.getCount' => array(),
23 'api.CustomValue.get' => 1,
27 $result = civicrm_api3('contact', 'get', $params);
29 catch (CiviCRM_API3_Exception
$e) {
31 $errorMessage = $e->getMessage();
32 $errorCode = $e->getErrorCode();
33 $errorData = $e->getExtraParams();
35 'error' => $errorMessage,
36 'error_code' => $errorCode,
37 'error_data' => $errorData,
45 * Function returns array of result expected from previous function.
50 function contact_get_expectedresult() {
52 $expectedResult = array(
60 'contact_type' => 'Individual',
61 'contact_sub_type' => '',
62 'sort_name' => 'xyz3, abc3',
63 'display_name' => 'abc3 xyz3',
70 'legal_identifier' => '',
71 'external_identifier' => '',
75 'preferred_communication_method' => '',
76 'preferred_language' => 'en_US',
77 'preferred_mail_format' => 'Both',
78 'first_name' => 'abc3',
80 'last_name' => 'xyz3',
84 'communication_style_id' => '',
89 'deceased_date' => '',
90 'household_name' => '',
91 'organization_name' => '',
93 'contact_is_deleted' => 0,
94 'current_employer' => '',
96 'street_address' => '1 my road',
97 'supplemental_address_1' => '',
98 'supplemental_address_2' => '',
100 'postal_code_suffix' => '',
104 'state_province_id' => '',
107 'phone_type_id' => '',
110 'email' => 'man3@yahoo.com',
115 'worldregion_id' => '',
116 'world_region' => '',
117 'individual_prefix' => '',
118 'individual_suffix' => '',
119 'communication_style' => '',
121 'state_province_name' => '',
122 'state_province' => '',
125 'api.website.getValue' => 'http://civicrm.org',
126 'api.Contribution.getCount' => 2,
127 'api.CustomValue.get' => array(
134 'latest' => 'value 4',
136 'entity_table' => 'Contact',
139 'entity_table' => 'Contact',
143 'latest' => 'value 3',
146 'entity_table' => 'Contact',
165 'latest' => 'defaultValue',
167 '1' => 'defaultValue',
171 'latest' => 'vegemite',
187 return $expectedResult;
191 * This example has been generated from the API test suite.
192 * The test that created it is called
193 * testGetIndividualWithChainedArraysAndMultipleCustom
194 * and can be found in
195 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
197 * You can see the outcome of the API tests at
198 * https://test.civicrm.org/job/CiviCRM-master-git/
200 * To Learn about the API read
201 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
203 * Browse the api on your own site with the api explorer
204 * http://MYSITE.ORG/path/to/civicrm/api/explorer
206 * Read more about testing here
207 * http://wiki.civicrm.org/confluence/display/CRM/Testing
209 * API Standards documentation:
210 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards