Merge pull request #13910 from seamuslee001/note_no_contact_id
[civicrm-core.git] / api / v3 / examples / Mailing / Submit.php
CommitLineData
50fb255d 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Mailing.submit API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function mailing_submit_example() {
cf8f0fff 9 $params = [
50fb255d 10 'scheduled_date' => '2014-12-13 10:00:00',
a828d7b8 11 'approval_date' => '2014-12-13 00:00:00',
1d8ee3d6 12 'id' => 18,
cf8f0fff 13 ];
50fb255d 14
15 try{
a828d7b8 16 $result = civicrm_api3('Mailing', 'submit', $params);
50fb255d 17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
cf8f0fff 23 return [
5be22f39 24 'is_error' => 1,
25 'error_message' => $errorMessage,
50fb255d 26 'error_code' => $errorCode,
27 'error_data' => $errorData,
cf8f0fff 28 ];
50fb255d 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 */
40function mailing_submit_expectedresult() {
41
cf8f0fff 42 $expectedResult = [
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
1d8ee3d6 46 'id' => 18,
cf8f0fff
CW
47 'values' => [
48 '18' => [
1d8ee3d6 49 'id' => '18',
50fb255d 50 'domain_id' => '1',
51 'header_id' => '',
1d8ee3d6 52 'footer_id' => '27',
5c49fee0
CW
53 'reply_id' => '8',
54 'unsubscribe_id' => '5',
55 'resubscribe_id' => '6',
56 'optout_id' => '7',
50fb255d 57 'name' => 'mailing name',
1d8ee3d6 58 'mailing_type' => 'standalone',
50fb255d 59 'from_name' => 'FIXME',
60 'from_email' => 'info@EXAMPLE.ORG',
61 'replyto_email' => 'info@EXAMPLE.ORG',
1d8ee3d6 62 'template_type' => 'traditional',
63 'template_options' => '',
50fb255d 64 'subject' => 'Hello {contact.display_name}',
5c49fee0 65 'body_text' => 'This is {contact.display_name}.
1d8ee3d6 66https://civicrm.org
5c49fee0 67{domain.address}{action.optOutUrl}',
a828d7b8 68 'body_html' => '<p>Look ma, magic tokens in the markup!</p>',
50fb255d 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',
1d8ee3d6 76 'created_id' => '40',
50fb255d 77 'created_date' => '2013-07-28 08:49:19',
1d8ee3d6 78 'scheduled_id' => '41',
50fb255d 79 'scheduled_date' => '20130728085413',
1d8ee3d6 80 'approver_id' => '41',
a828d7b8
CW
81 'approval_date' => '20130728085413',
82 'approval_status_id' => '1',
50fb255d 83 'approval_note' => '',
84 'is_archived' => 0,
85 'visibility' => 'Public Pages',
86 'campaign_id' => '',
5c49fee0 87 'dedupe_email' => '1',
50fb255d 88 'sms_provider_id' => '',
89 'hash' => '67eac7789eaee00',
1d8ee3d6 90 'location_type_id' => '',
5c49fee0 91 'email_selection_method' => 'automatic',
1d8ee3d6 92 'language' => '',
cf8f0fff
CW
93 ],
94 ],
95 ];
50fb255d 96
97 return $expectedResult;
98}
99
a828d7b8 100/*
50fb255d 101* This example has been generated from the API test suite.
a828d7b8
CW
102* The test that created it is called "testMailerSubmit"
103* and can be found at:
50fb255d 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
41d4d31f 113* http://MYSITE.ORG/path/to/civicrm/api
50fb255d 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*/