4 * Test Generated API Example.
5 * See bottom of this file for more detail.
9 * Test Generated example of using contact create API.
11 * /*this demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
12 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
17 function contact_create_example() {
19 'display_name' => 'batman',
20 'contact_type' => 'Individual',
21 'api.tag.create' => array(
22 'name' => '$value.id',
23 'description' => '$value.display_name',
24 'format.only_id' => 1,
26 'api.entity_tag.create' => array(
27 'tag_id' => '$value.api.tag.create',
32 $result = civicrm_api3('contact', 'create', $params);
34 catch (CiviCRM_API3_Exception
$e) {
36 $errorMessage = $e->getMessage();
37 $errorCode = $e->getErrorCode();
38 $errorData = $e->getExtraParams();
40 'error' => $errorMessage,
41 'error_code' => $errorCode,
42 'error_data' => $errorData,
50 * Function returns array of result expected from previous function.
55 function contact_create_expectedresult() {
57 $expectedResult = array(
65 'contact_type' => 'Individual',
66 'contact_sub_type' => '',
73 'legal_identifier' => '',
74 'external_identifier' => '',
76 'display_name' => 'batman',
80 'preferred_communication_method' => '',
81 'preferred_language' => 'en_US',
82 'preferred_mail_format' => 'Both',
83 'hash' => '67eac7789eaee00',
91 'communication_style_id' => '',
92 'email_greeting_id' => '1',
93 'email_greeting_custom' => '',
94 'email_greeting_display' => '',
95 'postal_greeting_id' => '1',
96 'postal_greeting_custom' => '',
97 'postal_greeting_display' => '',
98 'addressee_id' => '1',
99 'addressee_custom' => '',
100 'addressee_display' => '',
105 'deceased_date' => '',
106 'household_name' => '',
107 'primary_contact_id' => '',
108 'organization_name' => '',
110 'user_unique_id' => '',
111 'created_date' => '2013-07-28 08:49:19',
112 'modified_date' => '2012-11-14 16:02:35',
113 'api.tag.create' => 6,
114 'api.entity_tag.create' => array(
124 return $expectedResult;
128 * This example has been generated from the API test suite.
129 * The test that created it is called
130 * testChainingValuesCreate
131 * and can be found in
132 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
134 * You can see the outcome of the API tests at
135 * https://test.civicrm.org/job/CiviCRM-master-git/
137 * To Learn about the API read
138 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
140 * Browse the api on your own site with the api explorer
141 * http://MYSITE.ORG/path/to/civicrm/api/explorer
143 * Read more about testing here
144 * http://wiki.civicrm.org/confluence/display/CRM/Testing
146 * API Standards documentation:
147 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards