Ian province abbreviation patch - issue 724
[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() {
9 $params = array(
10 'scheduled_date' => '2014-12-13 10:00:00',
a828d7b8
CW
11 'approval_date' => '2014-12-13 00:00:00',
12 'id' => 16,
50fb255d 13 );
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();
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 */
39function mailing_submit_expectedresult() {
40
41 $expectedResult = array(
42 'is_error' => 0,
43 'version' => 3,
44 'count' => 1,
a828d7b8 45 'id' => 16,
50fb255d 46 'values' => array(
a828d7b8
CW
47 '16' => array(
48 'id' => '16',
50fb255d 49 'domain_id' => '1',
50 'header_id' => '',
a828d7b8 51 'footer_id' => '24',
5c49fee0
CW
52 'reply_id' => '8',
53 'unsubscribe_id' => '5',
54 'resubscribe_id' => '6',
55 'optout_id' => '7',
50fb255d 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}',
5c49fee0
CW
61 'body_text' => 'This is {contact.display_name}.
62{domain.address}{action.optOutUrl}',
a828d7b8 63 'body_html' => '<p>Look ma, magic tokens in the markup!</p>',
50fb255d 64 'url_tracking' => '1',
65 'forward_replies' => 0,
66 'auto_responder' => 0,
67 'open_tracking' => '1',
68 'is_completed' => '',
69 'msg_template_id' => '',
70 'override_verp' => '1',
a828d7b8 71 'created_id' => '35',
50fb255d 72 'created_date' => '2013-07-28 08:49:19',
a828d7b8 73 'scheduled_id' => '36',
50fb255d 74 'scheduled_date' => '20130728085413',
a828d7b8
CW
75 'approver_id' => '36',
76 'approval_date' => '20130728085413',
77 'approval_status_id' => '1',
50fb255d 78 'approval_note' => '',
79 'is_archived' => 0,
80 'visibility' => 'Public Pages',
81 'campaign_id' => '',
5c49fee0 82 'dedupe_email' => '1',
50fb255d 83 'sms_provider_id' => '',
84 'hash' => '67eac7789eaee00',
5c49fee0
CW
85 'location_type_id' => 0,
86 'email_selection_method' => 'automatic',
50fb255d 87 ),
88 ),
89 );
90
91 return $expectedResult;
92}
93
a828d7b8 94/*
50fb255d 95* This example has been generated from the API test suite.
a828d7b8
CW
96* The test that created it is called "testMailerSubmit"
97* and can be found at:
50fb255d 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
41d4d31f 107* http://MYSITE.ORG/path/to/civicrm/api
50fb255d 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*/