Merge pull request #5049 from totten/master-mailing-multiling
[civicrm-core.git] / api / v3 / examples / Mailing / Submit.php
1 <?php
2 /**
3 * Test Generated example of using mailing submit API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function mailing_submit_example() {
10 $params = array(
11 'scheduled_date' => '2014-12-13 10:00:00',
12 'id' => 9,
13 );
14
15 try{
16 $result = civicrm_api3('mailing', 'submit', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
24 'error' => $errorMessage,
25 'error_code' => $errorCode,
26 'error_data' => $errorData,
27 );
28 }
29
30 return $result;
31 }
32
33 /**
34 * Function returns array of result expected from previous function.
35 *
36 * @return array
37 * API result array
38 */
39 function mailing_submit_expectedresult() {
40
41 $expectedResult = array(
42 'is_error' => 0,
43 'version' => 3,
44 'count' => 1,
45 'id' => 9,
46 'values' => array(
47 '9' => array(
48 'id' => '9',
49 'domain_id' => '1',
50 'header_id' => '',
51 'footer_id' => '',
52 'reply_id' => '',
53 'unsubscribe_id' => '',
54 'resubscribe_id' => '',
55 'optout_id' => '',
56 'name' => 'mailing name',
57 'from_name' => 'FIXME',
58 'from_email' => 'info@EXAMPLE.ORG',
59 'replyto_email' => 'info@EXAMPLE.ORG',
60 'subject' => 'Hello {contact.display_name}',
61 'body_text' => 'This is {contact.display_name}',
62 'body_html' => '<p>This is {contact.display_name}</p>',
63 'url_tracking' => '1',
64 'forward_replies' => 0,
65 'auto_responder' => 0,
66 'open_tracking' => '1',
67 'is_completed' => '',
68 'msg_template_id' => '',
69 'override_verp' => '1',
70 'created_id' => '22',
71 'created_date' => '2013-07-28 08:49:19',
72 'scheduled_id' => '22',
73 'scheduled_date' => '20130728085413',
74 'approver_id' => '',
75 'approval_date' => '',
76 'approval_status_id' => '',
77 'approval_note' => '',
78 'is_archived' => 0,
79 'visibility' => 'Public Pages',
80 'campaign_id' => '',
81 'dedupe_email' => 0,
82 'sms_provider_id' => '',
83 'hash' => '67eac7789eaee00',
84 'location_type_id' => '',
85 'email_selection_method' => '',
86 ),
87 ),
88 );
89
90 return $expectedResult;
91 }
92
93 /**
94 * This example has been generated from the API test suite.
95 * The test that created it is called
96 * testMailerSubmit
97 * and can be found in
98 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php
99 *
100 * You can see the outcome of the API tests at
101 * https://test.civicrm.org/job/CiviCRM-master-git/
102 *
103 * To Learn about the API read
104 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
105 *
106 * Browse the api on your own site with the api explorer
107 * http://MYSITE.ORG/path/to/civicrm/api
108 *
109 * Read more about testing here
110 * http://wiki.civicrm.org/confluence/display/CRM/Testing
111 *
112 * API Standards documentation:
113 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
114 */