99486a32ae16ed4dec4d7172beba31a4860cfcaa
3 * Test Generated example of using 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();
34 'error' => $errorMessage,
35 'error_code' => $errorCode,
36 'error_data' => $errorData,
44 * Function returns array of result expected from previous function.
49 function contact_create_expectedresult() {
51 $expectedResult = array(
59 'contact_type' => 'Individual',
60 'contact_sub_type' => '',
67 'legal_identifier' => '',
68 'external_identifier' => '',
70 'display_name' => 'batman',
74 'preferred_communication_method' => '',
75 'preferred_language' => 'en_US',
76 'preferred_mail_format' => 'Both',
77 'hash' => '67eac7789eaee00',
85 'communication_style_id' => '',
86 'email_greeting_id' => '1',
87 'email_greeting_custom' => '',
88 'email_greeting_display' => '',
89 'postal_greeting_id' => '1',
90 'postal_greeting_custom' => '',
91 'postal_greeting_display' => '',
92 'addressee_id' => '1',
93 'addressee_custom' => '',
94 'addressee_display' => '',
99 'deceased_date' => '',
100 'household_name' => '',
101 'primary_contact_id' => '',
102 'organization_name' => '',
104 'user_unique_id' => '',
105 'created_date' => '2013-07-28 08:49:19',
106 'modified_date' => '2012-11-14 16:02:35',
107 'api.tag.create' => 6,
108 'api.entity_tag.create' => array(
118 return $expectedResult;
122 * This example has been generated from the API test suite.
123 * The test that created it is called
124 * testChainingValuesCreate
125 * and can be found in
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