Merge pull request #4423 from PalanteJon/aclReportFix-4.5
[civicrm-core.git] / api / v3 / examples / Pledge / Create.php
1 <?php
2 /**
3 * Test Generated example of using pledge create API
4 * *
5 */
6 function pledge_create_example(){
7 $params = array(
8 'contact_id' => 11,
9 'pledge_create_date' => '20140928',
10 'start_date' => '20140928',
11 'scheduled_date' => '20140930',
12 'amount' => '100',
13 'pledge_status_id' => '2',
14 'pledge_financial_type_id' => '1',
15 'pledge_original_installment_amount' => 20,
16 'frequency_interval' => 5,
17 'frequency_unit' => 'year',
18 'frequency_day' => 15,
19 'installments' => 5,
20 'sequential' => 1,
21 );
22
23 try{
24 $result = civicrm_api3('pledge', '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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function
39 */
40 function pledge_create_expectedresult(){
41
42 $expectedResult = array(
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 1,
47 'values' => array(
48 '0' => array(
49 'id' => '1',
50 'contact_id' => '11',
51 'financial_type_id' => '1',
52 'contribution_page_id' => '',
53 'amount' => '100',
54 'original_installment_amount' => '20',
55 'currency' => 'USD',
56 'frequency_unit' => 'year',
57 'frequency_interval' => '5',
58 'frequency_day' => '15',
59 'installments' => '5',
60 'start_date' => '2013-07-29 00:00:00',
61 'create_date' => '20120130621222105',
62 'acknowledge_date' => '',
63 'modified_date' => '',
64 'cancel_date' => '',
65 'end_date' => '',
66 'max_reminders' => '',
67 'initial_reminder_day' => '',
68 'additional_reminder_day' => '',
69 'status_id' => '2',
70 'is_test' => '',
71 'campaign_id' => '',
72 ),
73 ),
74 );
75
76 return $expectedResult;
77 }
78
79
80 /*
81 * This example has been generated from the API test suite. The test that created it is called
82 *
83 * testCreatePledge and can be found in
84 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php
85 *
86 * You can see the outcome of the API tests at
87 * https://test.civicrm.org/job/CiviCRM-master-git/
88 *
89 * To Learn about the API read
90 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
91 *
92 * Browse the api on your own site with the api explorer
93 * http://MYSITE.ORG/path/to/civicrm/api/explorer
94 *
95 * Read more about testing here
96 * http://wiki.civicrm.org/confluence/display/CRM/Testing
97 *
98 * API Standards documentation:
99 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
100 */