3 * Test Generated example of using contact create API
4 * /*this demonstrates the usage of chained api functions. Specifically it has one 'parent function' &
5 2 child functions - one receives values from the parent (Contact) and the other child (Tag). *
7 function contact_create_example(){
9 'display_name' => 'batman',
10 'contact_type' => 'Individual',
11 'api.tag.create' => array(
12 'name' => '$value.id',
13 'description' => '$value.display_name',
14 'format.only_id' => 1,
16 'api.entity_tag.create' => array(
17 'tag_id' => '$value.api.tag.create',
22 $result = civicrm_api3('contact', 'create', $params);
24 catch (CiviCRM_API3_Exception
$e) {
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
36 * Function returns array of result expected from previous function
38 function contact_create_expectedresult(){
40 $expectedResult = array(
48 'contact_type' => 'Individual',
49 'contact_sub_type' => '',
56 'legal_identifier' => '',
57 'external_identifier' => '',
59 'display_name' => 'batman',
63 'preferred_communication_method' => '',
64 'preferred_language' => 'en_US',
65 'preferred_mail_format' => 'Both',
66 'hash' => '67eac7789eaee00',
73 'email_greeting_id' => '1',
74 'email_greeting_custom' => '',
75 'email_greeting_display' => '',
76 'postal_greeting_id' => '1',
77 'postal_greeting_custom' => '',
78 'postal_greeting_display' => '',
79 'addressee_id' => '1',
80 'addressee_custom' => '',
81 'addressee_display' => '',
86 'deceased_date' => '',
87 'household_name' => '',
88 'primary_contact_id' => '',
89 'organization_name' => '',
91 'user_unique_id' => '',
92 'created_date' => '2013-07-28 08:49:19',
93 'modified_date' => '2012-11-14 16:02:35',
94 'api.tag.create' => 6,
95 'api.entity_tag.create' => array(
105 return $expectedResult;
110 * This example has been generated from the API test suite. The test that created it is called
112 * testChainingValuesCreate and can be found in
113 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
115 * You can see the outcome of the API tests at
116 * http://tests.dev.civicrm.org/trunk/results-api_v3
118 * To Learn about the API read
119 * http://book.civicrm.org/developer/current/techniques/api/
121 * and review the wiki at
122 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
124 * Read more about testing here
125 * http://wiki.civicrm.org/confluence/display/CRM/Testing
127 * API Standards documentation:
128 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards