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 return formats are used. Note that no notes
12 *custom fields or memberships exist
17 function contact_get_example() {
20 'api.website.getValue' => array(
23 'api.Contribution.getCount' => array(),
24 'api.CustomValue.get' => 1,
26 'api.Membership.getCount' => array(),
30 $result = civicrm_api3('contact', 'get', $params);
32 catch (CiviCRM_API3_Exception
$e) {
34 $errorMessage = $e->getMessage();
35 $errorCode = $e->getErrorCode();
36 $errorData = $e->getExtraParams();
38 'error' => $errorMessage,
39 'error_code' => $errorCode,
40 'error_data' => $errorData,
48 * Function returns array of result expected from previous function.
53 function contact_get_expectedresult() {
55 $expectedResult = array(
63 'contact_type' => 'Individual',
64 'contact_sub_type' => '',
65 'sort_name' => 'xyz3, abc3',
66 'display_name' => 'abc3 xyz3',
73 'legal_identifier' => '',
74 'external_identifier' => '',
78 'preferred_communication_method' => '',
79 'preferred_language' => 'en_US',
80 'preferred_mail_format' => 'Both',
81 'first_name' => 'abc3',
83 'last_name' => 'xyz3',
87 'communication_style_id' => '',
92 'deceased_date' => '',
93 'household_name' => '',
94 'organization_name' => '',
96 'contact_is_deleted' => 0,
97 'current_employer' => '',
99 'street_address' => '1 my road',
100 'supplemental_address_1' => '',
101 'supplemental_address_2' => '',
103 'postal_code_suffix' => '',
107 'state_province_id' => '',
110 'phone_type_id' => '',
113 'email' => 'man3@yahoo.com',
118 'worldregion_id' => '',
119 'world_region' => '',
120 'individual_prefix' => '',
121 'individual_suffix' => '',
122 'communication_style' => '',
124 'state_province_name' => '',
125 'state_province' => '',
128 'api.website.getValue' => 'http://civicrm.org',
129 'api.Contribution.getCount' => 2,
130 'api.CustomValue.get' => array(
136 'api.Note.get' => array(
142 'api.Membership.getCount' => 0,
147 return $expectedResult;
151 * This example has been generated from the API test suite.
152 * The test that created it is called
153 * testGetIndividualWithChainedArraysFormats
154 * and can be found in
155 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
157 * You can see the outcome of the API tests at
158 * https://test.civicrm.org/job/CiviCRM-master-git/
160 * To Learn about the API read
161 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
163 * Browse the api on your own site with the api explorer
164 * http://MYSITE.ORG/path/to/civicrm/api/explorer
166 * Read more about testing here
167 * http://wiki.civicrm.org/confluence/display/CRM/Testing
169 * API Standards documentation:
170 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards