remove print icon
[civicrm-core.git] / api / v3 / examples / Pledge / GetFilterHighDate.ex.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Pledge.get API.
4 *
5 * demonstrates high date filter
6 *
7 * @return array
8 * API result array
9 */
10 function pledge_get_example() {
11 $params = [
12 'pledge_start_date_high' => '20190818192828',
13 ];
14
15 try{
16 $result = civicrm_api3('Pledge', 'get', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return [
24 'is_error' => 1,
25 'error_message' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 ];
29 }
30
31 return $result;
32 }
33
34 /**
35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
39 */
40 function pledge_get_expectedresult() {
41
42 $expectedResult = [
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 2,
47 'values' => [
48 '2' => [
49 'contact_id' => '8',
50 'contact_type' => 'Individual',
51 'contact_sub_type' => '',
52 'sort_name' => 'Anderson, Anthony',
53 'display_name' => 'Mr. Anthony Anderson II',
54 'pledge_id' => '2',
55 'pledge_amount' => '100.00',
56 'pledge_create_date' => '2019-08-20 00:00:00',
57 'pledge_start_date' => '2018-03-02 00:00:00',
58 'pledge_status' => 'Overdue',
59 'pledge_total_paid' => '',
60 'pledge_next_pay_date' => '2018-03-02 00:00:00',
61 'pledge_next_pay_amount' => '20.00',
62 'pledge_outstanding_amount' => '20.00',
63 'pledge_financial_type' => 'Donation',
64 'pledge_contribution_page_id' => '',
65 'pledge_frequency_interval' => '5',
66 'pledge_frequency_unit' => 'year',
67 'pledge_is_test' => 0,
68 'pledge_campaign_id' => '',
69 'pledge_currency' => 'USD',
70 'id' => '2',
71 ],
72 ],
73 ];
74
75 return $expectedResult;
76 }
77
78 /*
79 * This example has been generated from the API test suite.
80 * The test that created it is called "testPledgeGetReturnFilters"
81 * and can be found at:
82 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php
83 *
84 * You can see the outcome of the API tests at
85 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
86 *
87 * To Learn about the API read
88 * https://docs.civicrm.org/dev/en/latest/api/
89 *
90 * Browse the API on your own site with the API Explorer. It is in the main
91 * CiviCRM menu, under: Support > Development > API Explorer.
92 *
93 * Read more about testing here
94 * https://docs.civicrm.org/dev/en/latest/testing/
95 *
96 * API Standards documentation:
97 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
98 */