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