38792cba7c4582dc316097645ce43d2479351580
3 * Test Generated example demonstrating the Contact.get API.
5 * This demonstrates the usage of chained api functions.
6 * In this case no notes or custom fields have been created.
11 function contact_get_example() {
14 'api.website.getValue' => array(
17 'api.Contribution.getCount' => array(),
18 'api.CustomValue.get' => 1,
20 'api.Membership.getCount' => array(),
24 $result = civicrm_api3('Contact', 'get', $params);
26 catch (CiviCRM_API3_Exception
$e) {
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
32 'error' => $errorMessage,
33 'error_code' => $errorCode,
34 'error_data' => $errorData,
42 * Function returns array of result expected from previous function.
47 function contact_get_expectedresult() {
49 $expectedResult = array(
57 'contact_type' => 'Individual',
58 'contact_sub_type' => '',
59 'sort_name' => 'xyz3, abc3',
60 'display_name' => 'abc3 xyz3',
67 'legal_identifier' => '',
68 'external_identifier' => '',
72 'preferred_communication_method' => '',
73 'preferred_language' => 'en_US',
74 'preferred_mail_format' => 'Both',
75 'first_name' => 'abc3',
77 'last_name' => 'xyz3',
81 'communication_style_id' => '',
86 'deceased_date' => '',
87 'household_name' => '',
88 'organization_name' => '',
90 'contact_is_deleted' => 0,
91 'current_employer' => '',
93 'street_address' => '1 my road',
94 'supplemental_address_1' => '',
95 'supplemental_address_2' => '',
97 'postal_code_suffix' => '',
101 'state_province_id' => '',
104 'phone_type_id' => '',
107 'email' => 'man3@yahoo.com',
112 'worldregion_id' => '',
113 'world_region' => '',
114 'individual_prefix' => '',
115 'individual_suffix' => '',
116 'communication_style' => '',
118 'state_province_name' => '',
119 'state_province' => '',
122 'api.website.getValue' => 'http://civicrm.org',
123 'api.Contribution.getCount' => 2,
124 'api.CustomValue.get' => array(
130 'api.Note.get' => array(
136 'api.Membership.getCount' => 0,
141 return $expectedResult;
145 * This example has been generated from the API test suite.
146 * The test that created it is called "testGetIndividualWithChainedArraysFormats"
147 * and can be found at:
148 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
150 * You can see the outcome of the API tests at
151 * https://test.civicrm.org/job/CiviCRM-master-git/
153 * To Learn about the API read
154 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
156 * Browse the api on your own site with the api explorer
157 * http://MYSITE.ORG/path/to/civicrm/api
159 * Read more about testing here
160 * http://wiki.civicrm.org/confluence/display/CRM/Testing
162 * API Standards documentation:
163 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards