3 * Test Generated example demonstrating the Contact.create API.
5 * This demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
6 * 2 child functions - one receives values from the parent (Contact) and the other child (Tag).
11 function contact_create_example() {
13 'display_name' => 'batman',
14 'contact_type' => 'Individual',
15 'api.tag.create' => array(
16 'name' => '$value.id',
17 'description' => '$value.display_name',
18 'format.only_id' => 1,
20 'api.entity_tag.create' => array(
21 'tag_id' => '$value.api.tag.create',
26 $result = civicrm_api3('Contact', 'create', $params);
28 catch (CiviCRM_API3_Exception
$e) {
30 $errorMessage = $e->getMessage();
31 $errorCode = $e->getErrorCode();
32 $errorData = $e->getExtraParams();
35 'error_message' => $errorMessage,
36 'error_code' => $errorCode,
37 'error_data' => $errorData,
45 * Function returns array of result expected from previous function.
50 function contact_create_expectedresult() {
52 $expectedResult = array(
60 'contact_type' => 'Individual',
61 'contact_sub_type' => '',
68 'legal_identifier' => '',
69 'external_identifier' => '',
70 'sort_name' => 'batman',
71 'display_name' => 'batman',
75 'preferred_communication_method' => '',
76 'preferred_language' => 'en_US',
77 'preferred_mail_format' => 'Both',
78 'hash' => '67eac7789eaee00',
86 'communication_style_id' => '',
87 'email_greeting_id' => '1',
88 'email_greeting_custom' => '',
89 'email_greeting_display' => '',
90 'postal_greeting_id' => '1',
91 'postal_greeting_custom' => '',
92 'postal_greeting_display' => '',
93 'addressee_id' => '1',
94 'addressee_custom' => '',
95 'addressee_display' => '',
100 'deceased_date' => '',
101 'household_name' => '',
102 'primary_contact_id' => '',
103 'organization_name' => '',
105 'user_unique_id' => '',
106 'created_date' => '2013-07-28 08:49:19',
107 'modified_date' => '2012-11-14 16:02:35',
108 'api.tag.create' => 6,
109 'api.entity_tag.create' => array(
119 return $expectedResult;
123 * This example has been generated from the API test suite.
124 * The test that created it is called "testChainingValuesCreate"
125 * and can be found at:
126 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
128 * You can see the outcome of the API tests at
129 * https://test.civicrm.org/job/CiviCRM-master-git/
131 * To Learn about the API read
132 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
134 * Browse the api on your own site with the api explorer
135 * http://MYSITE.ORG/path/to/civicrm/api
137 * Read more about testing here
138 * http://wiki.civicrm.org/confluence/display/CRM/Testing
140 * API Standards documentation:
141 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards