Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-03-02-21-30-06
[civicrm-core.git] / api / v3 / examples / Activity / Get.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Activity.get API.
4 *
5 * @return array
6 * API result array
7 */
8 function activity_get_example() {
9 $params = array(
10 'contact_id' => 1,
11 'activity_type_id' => '51',
12 'sequential' => 1,
13 'return.custom_1' => 1,
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(
25 'error' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 );
29 }
30
31 return $result;
32 }
33
34 /**
35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
39 */
40 function activity_get_expectedresult() {
41
42 $expectedResult = array(
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 1,
47 'values' => array(
48 '0' => array(
49 'source_contact_id' => '1',
50 'id' => '1',
51 'activity_type_id' => '51',
52 'subject' => 'test activity type id',
53 'location' => 'Pennsylvania',
54 'activity_date_time' => '2011-06-02 14:36:13',
55 'details' => 'a test activity',
56 'status_id' => '2',
57 'activity_name' => 'Test activity type',
58 'status' => 'Completed',
59 'custom_1' => 'custom string',
60 'custom_1_1' => 'custom string',
61 ),
62 ),
63 );
64
65 return $expectedResult;
66 }
67
68 /*
69 * This example has been generated from the API test suite.
70 * The test that created it is called "testActivityGetContact_idCustom"
71 * and can be found at:
72 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
73 *
74 * You can see the outcome of the API tests at
75 * https://test.civicrm.org/job/CiviCRM-master-git/
76 *
77 * To Learn about the API read
78 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
79 *
80 * Browse the api on your own site with the api explorer
81 * http://MYSITE.ORG/path/to/civicrm/api
82 *
83 * Read more about testing here
84 * http://wiki.civicrm.org/confluence/display/CRM/Testing
85 *
86 * API Standards documentation:
87 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
88 */