test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / MailingCreate.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using mailing create API
4 * *
6a488035
TO
5 */
6function mailing_create_example(){
53ca8fd7 7$params = array(
6a488035
TO
8 'subject' => 'maild',
9 'body_text' => 'bdkfhdskfhduew',
6a488035
TO
10 'name' => 'mailing name',
11 'created_id' => 1,
12);
13
fb32de45 14try{
15 $result = civicrm_api3('mailing', 'create', $params);
16}
17catch (CiviCRM_API3_Exception $e) {
18 // handle error here
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
23}
6a488035 24
fb32de45 25return $result;
6a488035
TO
26}
27
fb32de45 28/**
6a488035
TO
29 * Function returns array of result expected from previous function
30 */
31function mailing_create_expectedresult(){
32
53ca8fd7 33 $expectedResult = array(
6a488035
TO
34 'is_error' => 0,
35 'version' => 3,
36 'count' => 1,
37 'id' => 1,
53ca8fd7 38 'values' => array(
39 '1' => array(
6a488035
TO
40 'id' => '1',
41 'domain_id' => '1',
9f1b81e0 42 'header_id' => '',
43 'footer_id' => '',
6a488035
TO
44 'reply_id' => '',
45 'unsubscribe_id' => '',
46 'resubscribe_id' => '',
47 'optout_id' => '',
48 'name' => 'mailing name',
49 'from_name' => 'FIXME',
50 'from_email' => 'info@EXAMPLE.ORG',
51 'replyto_email' => 'info@EXAMPLE.ORG',
52 'subject' => 'maild',
53 'body_text' => 'bdkfhdskfhduew',
54 'body_html' => '',
55 'url_tracking' => '1',
56 'forward_replies' => '',
57 'auto_responder' => 0,
58 'open_tracking' => '1',
59 'is_completed' => '',
60 'msg_template_id' => '',
61 'override_verp' => '1',
62 'created_id' => '1',
f27f2724 63 'created_date' => '2013-07-28 08:49:19',
6a488035 64 'scheduled_id' => '',
fb32de45 65 'scheduled_date' => '20130728085413',
6a488035 66 'approver_id' => '1',
fb32de45 67 'approval_date' => '20130728085413',
6a488035
TO
68 'approval_status_id' => '',
69 'approval_note' => '',
70 'is_archived' => '',
71 'visibility' => 'User and User Admin Only',
72 'campaign_id' => '',
73 'dedupe_email' => '',
74 'sms_provider_id' => '',
53ca8fd7 75 'api.mailing_job.create' => array(
6a488035
TO
76 'is_error' => 0,
77 'version' => 3,
78 'count' => 1,
79 'id' => 1,
53ca8fd7 80 'values' => array(
81 '0' => array(
6a488035
TO
82 'id' => '1',
83 'mailing_id' => '1',
fb32de45 84 'scheduled_date' => '20130728085413',
6a488035
TO
85 'start_date' => '',
86 'end_date' => '',
87 'status' => 'Scheduled',
88 'is_test' => 0,
89 'job_type' => '',
90 'parent_id' => '',
91 'job_offset' => '',
92 'job_limit' => '',
93 ),
94 ),
95 ),
96 ),
97 ),
98);
99
fb32de45 100 return $expectedResult;
6a488035
TO
101}
102
103
104/*
105* This example has been generated from the API test suite. The test that created it is called
106*
107* testMailerCreateSuccess and can be found in
108* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/MailingTest.php
109*
110* You can see the outcome of the API tests at
111* http://tests.dev.civicrm.org/trunk/results-api_v3
112*
113* To Learn about the API read
114* http://book.civicrm.org/developer/current/techniques/api/
115*
116* and review the wiki at
117* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
118*
119* Read more about testing here
120* http://wiki.civicrm.org/confluence/display/CRM/Testing
121*
122* API Standards documentation:
123* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
124*/