Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /* | |
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). | |
6 | */ | |
7 | function contact_create_example(){ | |
edb0d67a | 8 | $params = array( |
6a488035 TO |
9 | 'version' => 3, |
10 | 'display_name' => 'batman', | |
11 | 'contact_type' => 'Individual', | |
edb0d67a | 12 | 'api.tag.create' => array( |
6a488035 TO |
13 | 'name' => '$value.id', |
14 | 'description' => '$value.display_name', | |
15 | 'format.only_id' => 1, | |
16 | ), | |
edb0d67a | 17 | 'api.entity_tag.create' => array( |
6a488035 TO |
18 | 'tag_id' => '$value.api.tag.create', |
19 | ), | |
20 | ); | |
21 | ||
22 | $result = civicrm_api( 'contact','create',$params ); | |
23 | ||
24 | return $result; | |
25 | } | |
26 | ||
27 | /* | |
28 | * Function returns array of result expected from previous function | |
29 | */ | |
30 | function contact_create_expectedresult(){ | |
31 | ||
edb0d67a | 32 | $expectedResult = array( |
6a488035 TO |
33 | 'is_error' => 0, |
34 | 'version' => 3, | |
35 | 'count' => 1, | |
36 | 'id' => 1, | |
edb0d67a | 37 | 'values' => array( |
38 | '1' => array( | |
6a488035 TO |
39 | 'id' => '1', |
40 | 'contact_type' => 'Individual', | |
41 | 'contact_sub_type' => '', | |
42 | 'do_not_email' => 0, | |
43 | 'do_not_phone' => 0, | |
44 | 'do_not_mail' => 0, | |
45 | 'do_not_sms' => 0, | |
46 | 'do_not_trade' => 0, | |
47 | 'is_opt_out' => 0, | |
48 | 'legal_identifier' => '', | |
49 | 'external_identifier' => '', | |
50 | 'sort_name' => '', | |
51 | 'display_name' => 'batman', | |
52 | 'nick_name' => '', | |
53 | 'legal_name' => '', | |
54 | 'image_URL' => '', | |
55 | 'preferred_communication_method' => '', | |
56 | 'preferred_language' => 'en_US', | |
57 | 'preferred_mail_format' => 'Both', | |
58 | 'hash' => '67eac7789eaee00', | |
59 | 'api_key' => '', | |
60 | 'first_name' => '', | |
61 | 'middle_name' => '', | |
62 | 'last_name' => '', | |
63 | 'prefix_id' => '', | |
64 | 'suffix_id' => '', | |
65 | 'email_greeting_id' => '1', | |
66 | 'email_greeting_custom' => '', | |
67 | 'email_greeting_display' => '', | |
68 | 'postal_greeting_id' => '1', | |
69 | 'postal_greeting_custom' => '', | |
70 | 'postal_greeting_display' => '', | |
71 | 'addressee_id' => '1', | |
72 | 'addressee_custom' => '', | |
73 | 'addressee_display' => '', | |
74 | 'job_title' => '', | |
75 | 'gender_id' => '', | |
76 | 'birth_date' => '', | |
77 | 'is_deceased' => 0, | |
78 | 'deceased_date' => '', | |
79 | 'household_name' => '', | |
80 | 'primary_contact_id' => '', | |
81 | 'organization_name' => '', | |
82 | 'sic_code' => '', | |
83 | 'user_unique_id' => '', | |
edb0d67a | 84 | 'created_date' => '20120130621222105', |
6a488035 TO |
85 | 'modified_date' => '2012-11-14 16:02:35', |
86 | 'api.tag.create' => 6, | |
edb0d67a | 87 | 'api.entity_tag.create' => array( |
6a488035 TO |
88 | 'is_error' => 0, |
89 | 'not_added' => 1, | |
90 | 'added' => 1, | |
91 | 'total_count' => 2, | |
92 | ), | |
93 | ), | |
94 | ), | |
95 | ); | |
96 | ||
97 | return $expectedResult ; | |
98 | } | |
99 | ||
100 | ||
101 | /* | |
102 | * This example has been generated from the API test suite. The test that created it is called | |
103 | * | |
104 | * testChainingValuesCreate and can be found in | |
105 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php | |
106 | * | |
107 | * You can see the outcome of the API tests at | |
108 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
109 | * | |
110 | * To Learn about the API read | |
111 | * http://book.civicrm.org/developer/current/techniques/api/ | |
112 | * | |
113 | * and review the wiki at | |
114 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
115 | * | |
116 | * Read more about testing here | |
117 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
118 | * | |
119 | * API Standards documentation: | |
120 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
121 | */ |