infra updated incorrectly set public functions to private on payment classes
[civicrm-core.git] / api / v3 / examples / Campaign / Create.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
6a488035 7
50fb255d 8/**
9 * Test Generated example of using campaign create API.
10 *
11 * Create a campaign - Note use of relative dates here http://www.php.net/manual/en/datetime.formats.relative.php
12 *
13 * @return array
14 * API result array
15 */
16function campaign_create_example() {
17 $params = array(
18 'title' => 'campaign title',
19 'description' => 'Call people, ask for money',
20 'created_date' => 'first sat of July 2008',
21 );
6a488035 22
50fb255d 23 try{
24 $result = civicrm_api3('campaign', 'create', $params);
25 }
26 catch (CiviCRM_API3_Exception $e) {
27 // Handle error here.
28 $errorMessage = $e->getMessage();
29 $errorCode = $e->getErrorCode();
30 $errorData = $e->getExtraParams();
31 return array(
32 'error' => $errorMessage,
33 'error_code' => $errorCode,
34 'error_data' => $errorData,
35 );
36 }
37
38 return $result;
6a488035
TO
39}
40
fb32de45 41/**
50fb255d 42 * Function returns array of result expected from previous function.
43 *
44 * @return array
45 * API result array
6a488035 46 */
50fb255d 47function campaign_create_expectedresult() {
6a488035 48
edb0d67a 49 $expectedResult = array(
50fb255d 50 'is_error' => 0,
51 'version' => 3,
52 'count' => 1,
53 'id' => 1,
54 'values' => array(
edb0d67a 55 '1' => array(
50fb255d 56 'id' => '1',
57 'name' => 'campaign_title',
58 'title' => 'campaign title',
59 'description' => 'Call people, ask for money',
60 'start_date' => '',
61 'end_date' => '',
62 'campaign_type_id' => '',
63 'status_id' => '',
64 'external_identifier' => '',
65 'parent_id' => '',
66 'is_active' => '',
67 'created_id' => '',
68 'created_date' => '2013-07-28 08:49:19',
69 'last_modified_id' => '',
70 'last_modified_date' => '',
71 'goal_general' => '',
72 'goal_revenue' => '',
73 ),
6a488035 74 ),
50fb255d 75 );
6a488035 76
fb32de45 77 return $expectedResult;
6a488035
TO
78}
79
50fb255d 80/**
81* This example has been generated from the API test suite.
82* The test that created it is called
83* testCreateCampaign
84* and can be found in
69d79249 85* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CampaignTest.php
6a488035
TO
86*
87* You can see the outcome of the API tests at
69d79249 88* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
89*
90* To Learn about the API read
69d79249 91* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 92*
69d79249
E
93* Browse the api on your own site with the api explorer
94* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
95*
96* Read more about testing here
97* http://wiki.civicrm.org/confluence/display/CRM/Testing
98*
99* API Standards documentation:
100* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 101*/