CRM-15905 fix - API: problem sorting contacts on ID
[civicrm-core.git] / api / v3 / examples / Mailing / Submit.php
CommitLineData
50fb255d 1<?php
2/**
3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8/**
9 * Test Generated example of using mailing submit API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15function mailing_submit_example() {
16 $params = array(
17 'scheduled_date' => '2014-12-13 10:00:00',
18 'id' => 9,
19 );
20
21 try{
22 $result = civicrm_api3('mailing', 'submit', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // Handle error here.
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array(
30 'error' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
33 );
34 }
35
36 return $result;
37}
38
39/**
40 * Function returns array of result expected from previous function.
41 *
42 * @return array
43 * API result array
44 */
45function mailing_submit_expectedresult() {
46
47 $expectedResult = array(
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 9,
52 'values' => array(
53 '9' => array(
54 'id' => '9',
55 'domain_id' => '1',
56 'header_id' => '',
57 'footer_id' => '',
58 'reply_id' => '',
59 'unsubscribe_id' => '',
60 'resubscribe_id' => '',
61 'optout_id' => '',
62 'name' => 'mailing name',
63 'from_name' => 'FIXME',
64 'from_email' => 'info@EXAMPLE.ORG',
65 'replyto_email' => 'info@EXAMPLE.ORG',
66 'subject' => 'Hello {contact.display_name}',
67 'body_text' => 'This is {contact.display_name}',
68 'body_html' => '<p>This is {contact.display_name}</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' => '22',
77 'created_date' => '2013-07-28 08:49:19',
78 'scheduled_id' => '22',
79 'scheduled_date' => '20130728085413',
80 'approver_id' => '',
81 'approval_date' => '',
82 'approval_status_id' => '',
83 'approval_note' => '',
84 'is_archived' => 0,
85 'visibility' => 'Public Pages',
86 'campaign_id' => '',
87 'dedupe_email' => 0,
88 'sms_provider_id' => '',
89 'hash' => '67eac7789eaee00',
90 'location_type_id' => '',
91 'email_selection_method' => '',
92 ),
93 ),
94 );
95
96 return $expectedResult;
97}
98
99/**
100* This example has been generated from the API test suite.
101* The test that created it is called
102* testMailerSubmit
103* and can be found in
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/explorer
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*/