Merge pull request #9779 from WeMoveEU/CRM-19963
[civicrm-core.git] / api / v3 / examples / Activity / ReturnAssigneeContact.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Activity.get API.
4 *
5 * Demonstrates getting assignee_contact_id & using it to get the contact.
6 *
7 * @return array
8 * API result array
9 */
10 function activity_get_example() {
11 $params = array(
12 'activity_id' => 1,
13 'sequential' => 1,
14 'return.assignee_contact_id' => 1,
15 'api.contact.get' => array(
16 'id' => '$value.source_contact_id',
17 ),
18 );
19
20 try{
21 $result = civicrm_api3('Activity', 'get', $params);
22 }
23 catch (CiviCRM_API3_Exception $e) {
24 // Handle error here.
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array(
29 'is_error' => 1,
30 'error_message' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
33 );
34 }
35
36 return $result;
37 }
38
39 /**
40 * Function returns array of result expected from previous function.
41 *
42 * @return array
43 * API result array
44 */
45 function activity_get_expectedresult() {
46
47 $expectedResult = array(
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 1,
52 'values' => array(
53 '0' => array(
54 'id' => '1',
55 'activity_type_id' => '9999',
56 'subject' => 'test activity type id',
57 'activity_date_time' => '2011-06-02 14:36:13',
58 'duration' => '120',
59 'location' => 'Pennsylvania',
60 'details' => 'a test activity',
61 'status_id' => '2',
62 'priority_id' => '1',
63 'is_test' => 0,
64 'is_auto' => 0,
65 'is_current_revision' => '1',
66 'is_deleted' => 0,
67 'is_star' => 0,
68 'assignee_contact_id' => array(
69 '0' => '3',
70 ),
71 'source_contact_id' => '1',
72 'api.contact.get' => array(
73 'is_error' => 0,
74 'version' => 3,
75 'count' => 1,
76 'id' => 1,
77 'values' => array(
78 '0' => array(
79 'contact_id' => '1',
80 'contact_type' => 'Individual',
81 'contact_sub_type' => '',
82 'sort_name' => 'Anderson, Anthony',
83 'display_name' => 'Mr. Anthony Anderson II',
84 'do_not_email' => 0,
85 'do_not_phone' => 0,
86 'do_not_mail' => 0,
87 'do_not_sms' => 0,
88 'do_not_trade' => 0,
89 'is_opt_out' => 0,
90 'legal_identifier' => '',
91 'external_identifier' => '',
92 'nick_name' => '',
93 'legal_name' => '',
94 'image_URL' => '',
95 'preferred_communication_method' => '',
96 'preferred_language' => 'en_US',
97 'preferred_mail_format' => 'Both',
98 'first_name' => 'Anthony',
99 'middle_name' => 'J.',
100 'last_name' => 'Anderson',
101 'prefix_id' => '3',
102 'suffix_id' => '3',
103 'formal_title' => '',
104 'communication_style_id' => '',
105 'job_title' => '',
106 'gender_id' => '',
107 'birth_date' => '',
108 'is_deceased' => 0,
109 'deceased_date' => '',
110 'household_name' => '',
111 'organization_name' => '',
112 'sic_code' => '',
113 'contact_is_deleted' => 0,
114 'current_employer' => '',
115 'address_id' => '',
116 'street_address' => '',
117 'supplemental_address_1' => '',
118 'supplemental_address_2' => '',
119 'supplemental_address_3' => '',
120 'city' => '',
121 'postal_code_suffix' => '',
122 'postal_code' => '',
123 'geo_code_1' => '',
124 'geo_code_2' => '',
125 'state_province_id' => '',
126 'country_id' => '',
127 'phone_id' => '',
128 'phone_type_id' => '',
129 'phone' => '',
130 'email_id' => '1',
131 'email' => 'anthony_anderson@civicrm.org',
132 'on_hold' => 0,
133 'im_id' => '',
134 'provider_id' => '',
135 'im' => '',
136 'worldregion_id' => '',
137 'world_region' => '',
138 'languages' => 'English (United States)',
139 'individual_prefix' => 'Mr.',
140 'individual_suffix' => 'II',
141 'communication_style' => '',
142 'gender' => '',
143 'state_province_name' => '',
144 'state_province' => '',
145 'country' => '',
146 'id' => '1',
147 ),
148 ),
149 ),
150 ),
151 ),
152 );
153
154 return $expectedResult;
155 }
156
157 /*
158 * This example has been generated from the API test suite.
159 * The test that created it is called "testActivityGetGoodID1"
160 * and can be found at:
161 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
162 *
163 * You can see the outcome of the API tests at
164 * https://test.civicrm.org/job/CiviCRM-master-git/
165 *
166 * To Learn about the API read
167 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
168 *
169 * Browse the api on your own site with the api explorer
170 * http://MYSITE.ORG/path/to/civicrm/api
171 *
172 * Read more about testing here
173 * http://wiki.civicrm.org/confluence/display/CRM/Testing
174 *
175 * API Standards documentation:
176 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
177 */