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