Merge pull request #10155 from totten/master-pdf-save2
[civicrm-core.git] / api / v3 / examples / MailSettings / ChainedGetDelete.php
1 <?php
2 /**
3 * Test Generated example demonstrating the MailSettings.get API.
4 *
5 * Demonstrates get + delete in the same call.
6 *
7 * @return array
8 * API result array
9 */
10 function mail_settings_get_example() {
11 $params = array(
12 'title' => 'MailSettings title',
13 'api.MailSettings.delete' => 1,
14 );
15
16 try{
17 $result = civicrm_api3('MailSettings', '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 'is_error' => 1,
26 'error_message' => $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 mail_settings_get_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 2,
47 'values' => array(
48 '1' => array(
49 'id' => '1',
50 'domain_id' => '1',
51 'name' => 'default',
52 'is_default' => 0,
53 'domain' => 'EXAMPLE.ORG',
54 'api.MailSettings.delete' => array(
55 'is_error' => 0,
56 'version' => 3,
57 'count' => 1,
58 'values' => 1,
59 ),
60 ),
61 '6' => array(
62 'id' => '6',
63 'domain_id' => '1',
64 'name' => 'my mail setting',
65 'is_default' => '1',
66 'domain' => 'setting.com',
67 'server' => 'localhost',
68 'username' => 'sue',
69 'password' => 'pass',
70 'is_ssl' => 0,
71 'api.MailSettings.delete' => array(
72 'is_error' => 0,
73 'version' => 3,
74 'count' => 1,
75 'values' => 1,
76 ),
77 ),
78 ),
79 );
80
81 return $expectedResult;
82 }
83
84 /*
85 * This example has been generated from the API test suite.
86 * The test that created it is called "testGetMailSettingsChainDelete"
87 * and can be found at:
88 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.php
89 *
90 * You can see the outcome of the API tests at
91 * https://test.civicrm.org/job/CiviCRM-master-git/
92 *
93 * To Learn about the API read
94 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
95 *
96 * Browse the api on your own site with the api explorer
97 * http://MYSITE.ORG/path/to/civicrm/api
98 *
99 * Read more about testing here
100 * http://wiki.civicrm.org/confluence/display/CRM/Testing
101 *
102 * API Standards documentation:
103 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
104 */