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