Merge pull request #13852 from pradpnayak/RecurringMemIssue
[civicrm-core.git] / api / v3 / examples / Contact / GetActions.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Contact.getactions API.
4 *
5 * Getting the available actions for an entity.
6 *
7 * @return array
8 * API result array
9 */
10 function contact_getactions_example() {
11 $params = [];
12
13 try{
14 $result = civicrm_api3('Contact', 'getactions', $params);
15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // Handle error here.
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return [
22 'is_error' => 1,
23 'error_message' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 ];
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
37 */
38 function contact_getactions_expectedresult() {
39
40 $expectedResult = [
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 20,
44 'values' => [
45 '0' => 'create',
46 '1' => 'delete',
47 '2' => 'duplicatecheck',
48 '3' => 'get',
49 '4' => 'getactions',
50 '5' => 'getcount',
51 '6' => 'getfield',
52 '7' => 'getfields',
53 '8' => 'getlist',
54 '9' => 'getoptions',
55 '10' => 'getquick',
56 '11' => 'getrefcount',
57 '12' => 'getsingle',
58 '13' => 'getvalue',
59 '14' => 'merge',
60 '15' => 'proximity',
61 '16' => 'replace',
62 '17' => 'setvalue',
63 '18' => 'update',
64 '19' => 'validate',
65 ],
66 'deprecated' => [
67 'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
68 'setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.',
69 'update' => 'The "update" action is deprecated. Use "create" with an id instead.',
70 ],
71 ];
72
73 return $expectedResult;
74 }
75
76 /*
77 * This example has been generated from the API test suite.
78 * The test that created it is called "testGetActions"
79 * and can be found at:
80 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
81 *
82 * You can see the outcome of the API tests at
83 * https://test.civicrm.org/job/CiviCRM-master-git/
84 *
85 * To Learn about the API read
86 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
87 *
88 * Browse the api on your own site with the api explorer
89 * http://MYSITE.ORG/path/to/civicrm/api
90 *
91 * Read more about testing here
92 * http://wiki.civicrm.org/confluence/display/CRM/Testing
93 *
94 * API Standards documentation:
95 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
96 */