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