Merge pull request #22966 from eileenmcnaughton/retrieve
[civicrm-core.git] / api / v3 / examples / StatusPreference / Get.ex.php
1 <?php
2
3 /**
4 * @file
5 */
6
7 /**
8 * Test Generated example demonstrating the StatusPreference.get API.
9 *
10 * @return array
11 * API result array
12 */
13 function status_preference_get_example() {
14 $params = [
15 'id' => 5,
16 ];
17
18 try {
19 $result = civicrm_api3('StatusPreference', 'get', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return [
27 'is_error' => 1,
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 ];
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
42 */
43 function status_preference_get_expectedresult() {
44
45 $expectedResult = [
46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
49 'id' => 5,
50 'values' => [
51 '5' => [
52 'id' => '5',
53 'domain_id' => '1',
54 'name' => 'test_check',
55 'hush_until' => '2015-12-12',
56 'ignore_severity' => '4',
57 'is_active' => '1',
58 ],
59 ],
60 ];
61
62 return $expectedResult;
63 }
64
65 /*
66 * This example has been generated from the API test suite.
67 * The test that created it is called "testStatusPreferenceGet"
68 * and can be found at:
69 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StatusPreferenceTest.php
70 *
71 * You can see the outcome of the API tests at
72 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
73 *
74 * To Learn about the API read
75 * https://docs.civicrm.org/dev/en/latest/api/
76 *
77 * Browse the API on your own site with the API Explorer. It is in the main
78 * CiviCRM menu, under: Support > Development > API Explorer.
79 *
80 * Read more about testing here
81 * https://docs.civicrm.org/dev/en/latest/testing/
82 *
83 * API Standards documentation:
84 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
85 */