Merge branch 4.5 into master
[civicrm-core.git] / api / v3 / examples / ContributionPage / Get.php
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 contribution_page get API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15 function contribution_page_get_example() {
16 $params = array(
17 'amount' => '34567',
18 'currency' => 'NZD',
19 'financial_type_id' => 1,
20 );
21
22 try{
23 $result = civicrm_api3('contribution_page', 'get', $params);
24 }
25 catch (CiviCRM_API3_Exception $e) {
26 // Handle error here.
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
30 return array(
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
38 }
39
40 /**
41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
45 */
46 function contribution_page_get_expectedresult() {
47
48 $expectedResult = array(
49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 1,
53 'values' => array(
54 '1' => array(
55 'id' => '1',
56 'title' => 'Test Contribution Page',
57 'financial_type_id' => '1',
58 'is_credit_card_only' => 0,
59 'is_monetary' => '1',
60 'is_recur' => 0,
61 'is_confirm_enabled' => '1',
62 'is_recur_interval' => 0,
63 'is_recur_installments' => 0,
64 'is_pay_later' => '1',
65 'is_partial_payment' => 0,
66 'is_allow_other_amount' => 0,
67 'goal_amount' => '34567.00',
68 'is_for_organization' => 0,
69 'is_email_receipt' => 0,
70 'is_active' => '1',
71 'amount_block_is_active' => '1',
72 'currency' => 'NZD',
73 'is_share' => '1',
74 'is_billing_required' => 0,
75 ),
76 ),
77 );
78
79 return $expectedResult;
80 }
81
82 /**
83 * This example has been generated from the API test suite.
84 * The test that created it is called
85 * testGetContributionPageByAmount
86 * and can be found in
87 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
88 *
89 * You can see the outcome of the API tests at
90 * https://test.civicrm.org/job/CiviCRM-master-git/
91 *
92 * To Learn about the API read
93 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
94 *
95 * Browse the api on your own site with the api explorer
96 * http://MYSITE.ORG/path/to/civicrm/api/explorer
97 *
98 * Read more about testing here
99 * http://wiki.civicrm.org/confluence/display/CRM/Testing
100 *
101 * API Standards documentation:
102 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
103 */