Merge pull request #9973 from lcdservices/CRM-19469
[civicrm-core.git] / api / v3 / examples / Mailing / Clone.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Mailing.clone API.
4 *
5 * @return array
6 * API result array
7 */
8 function mailing_clone_example() {
9 $params = array(
10 'id' => 21,
11 );
12
13 try{
14 $result = civicrm_api3('Mailing', 'clone', $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 array(
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 mailing_clone_expectedresult() {
39
40 $expectedResult = array(
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 22,
45 'values' => array(
46 '22' => array(
47 'id' => '22',
48 'domain_id' => '1',
49 'header_id' => '1',
50 'footer_id' => '2',
51 'reply_id' => '8',
52 'unsubscribe_id' => '5',
53 'resubscribe_id' => '6',
54 'optout_id' => '7',
55 'name' => 'mailing name',
56 'mailing_type' => 'standalone',
57 'from_name' => 'FIXME',
58 'from_email' => 'info@EXAMPLE.ORG',
59 'replyto_email' => 'info@EXAMPLE.ORG',
60 'template_type' => 'traditional',
61 'template_options' => '',
62 'subject' => 'Hello {contact.display_name}',
63 'body_text' => 'This is {contact.display_name}.
64 https://civicrm.org
65 {domain.address}{action.optOutUrl}',
66 'body_html' => '<p>This is {contact.display_name}.</p><p><a href=\'https://civicrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
67 'url_tracking' => '1',
68 'forward_replies' => 0,
69 'auto_responder' => 0,
70 'open_tracking' => '1',
71 'is_completed' => '',
72 'msg_template_id' => '',
73 'override_verp' => '1',
74 'created_id' => '147',
75 'created_date' => '2013-07-28 08:49:19',
76 'scheduled_id' => '',
77 'scheduled_date' => '',
78 'approver_id' => '',
79 'approval_date' => '',
80 'approval_status_id' => '',
81 'approval_note' => '',
82 'is_archived' => '',
83 'visibility' => 'Public Pages',
84 'campaign_id' => '',
85 'dedupe_email' => '1',
86 'sms_provider_id' => '',
87 'hash' => '',
88 'location_type_id' => '',
89 'email_selection_method' => 'automatic',
90 'language' => '',
91 ),
92 ),
93 );
94
95 return $expectedResult;
96 }
97
98 /*
99 * This example has been generated from the API test suite.
100 * The test that created it is called "testClone"
101 * and can be found at:
102 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php
103 *
104 * You can see the outcome of the API tests at
105 * https://test.civicrm.org/job/CiviCRM-master-git/
106 *
107 * To Learn about the API read
108 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
109 *
110 * Browse the api on your own site with the api explorer
111 * http://MYSITE.ORG/path/to/civicrm/api
112 *
113 * Read more about testing here
114 * http://wiki.civicrm.org/confluence/display/CRM/Testing
115 *
116 * API Standards documentation:
117 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
118 */