Merge pull request #5174 from joannechester/patch-2
[civicrm-core.git] / api / v3 / examples / Activity / DateTimeHigh.php
1 <?php
2 /**
3 * Test Generated example of using activity get API.
4 *
5 * Demonstrates _high filter (at time of writing doesn't work if contact_id is set.
6 *
7 * @return array
8 * API result array
9 */
10 function activity_get_example() {
11 $params = array(
12 'source_contact_id' => 1,
13 'filter.activity_date_time_high' => '20120101000000',
14 'sequential' => 1,
15 );
16
17 try{
18 $result = civicrm_api3('activity', 'get', $params);
19 }
20 catch (CiviCRM_API3_Exception $e) {
21 // Handle error here.
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
25 return array(
26 'error' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
29 );
30 }
31
32 return $result;
33 }
34
35 /**
36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
40 */
41 function activity_get_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 1,
47 'id' => 1,
48 'values' => array(
49 '0' => array(
50 'id' => '1',
51 'activity_type_id' => '51',
52 'subject' => 'Make-it-Happen Meeting',
53 'activity_date_time' => '2011-01-01 00:00:00',
54 'duration' => '120',
55 'location' => 'Pennsylvania',
56 'details' => 'a test activity',
57 'status_id' => '1',
58 'priority_id' => '1',
59 'is_test' => 0,
60 'is_auto' => 0,
61 'is_current_revision' => '1',
62 'is_deleted' => 0,
63 'source_contact_id' => '1',
64 ),
65 ),
66 );
67
68 return $expectedResult;
69 }
70
71 /**
72 * This example has been generated from the API test suite.
73 * The test that created it is called
74 * testGetFilterMaxDate
75 * and can be found in
76 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
77 *
78 * You can see the outcome of the API tests at
79 * https://test.civicrm.org/job/CiviCRM-master-git/
80 *
81 * To Learn about the API read
82 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
83 *
84 * Browse the api on your own site with the api explorer
85 * http://MYSITE.ORG/path/to/civicrm/api
86 *
87 * Read more about testing here
88 * http://wiki.civicrm.org/confluence/display/CRM/Testing
89 *
90 * API Standards documentation:
91 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
92 */