Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Pledge.get API. |
50fb255d | 4 | * |
5 | * demonstrates high date filter | |
6 | * | |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function pledge_get_example() { | |
cf8f0fff | 11 | $params = [ |
8390b11b | 12 | 'pledge_start_date_high' => '20190818192828', |
cf8f0fff | 13 | ]; |
6a488035 | 14 | |
50fb255d | 15 | try{ |
a828d7b8 | 16 | $result = civicrm_api3('Pledge', 'get', $params); |
50fb255d | 17 | } |
18 | catch (CiviCRM_API3_Exception $e) { | |
19 | // Handle error here. | |
20 | $errorMessage = $e->getMessage(); | |
21 | $errorCode = $e->getErrorCode(); | |
22 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 23 | return [ |
1d8ee3d6 | 24 | 'is_error' => 1, |
25 | 'error_message' => $errorMessage, | |
50fb255d | 26 | 'error_code' => $errorCode, |
27 | 'error_data' => $errorData, | |
cf8f0fff | 28 | ]; |
50fb255d | 29 | } |
30 | ||
31 | return $result; | |
6a488035 TO |
32 | } |
33 | ||
fb32de45 | 34 | /** |
50fb255d | 35 | * Function returns array of result expected from previous function. |
36 | * | |
37 | * @return array | |
38 | * API result array | |
6a488035 | 39 | */ |
50fb255d | 40 | function pledge_get_expectedresult() { |
6a488035 | 41 | |
cf8f0fff | 42 | $expectedResult = [ |
50fb255d | 43 | 'is_error' => 0, |
44 | 'version' => 3, | |
45 | 'count' => 1, | |
46 | 'id' => 2, | |
cf8f0fff CW |
47 | 'values' => [ |
48 | '2' => [ | |
50fb255d | 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', | |
8390b11b SL |
56 | 'pledge_create_date' => '2019-08-20 00:00:00', |
57 | 'pledge_start_date' => '2018-03-02 00:00:00', | |
50fb255d | 58 | 'pledge_status' => 'Overdue', |
59 | 'pledge_total_paid' => '', | |
8390b11b | 60 | 'pledge_next_pay_date' => '2018-03-02 00:00:00', |
50fb255d | 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', | |
cf8f0fff CW |
71 | ], |
72 | ], | |
73 | ]; | |
6a488035 | 74 | |
fb32de45 | 75 | return $expectedResult; |
6a488035 TO |
76 | } |
77 | ||
a828d7b8 | 78 | /* |
50fb255d | 79 | * This example has been generated from the API test suite. |
a828d7b8 CW |
80 | * The test that created it is called "testPledgeGetReturnFilters" |
81 | * and can be found at: | |
69d79249 | 82 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php |
6a488035 TO |
83 | * |
84 | * You can see the outcome of the API tests at | |
8390b11b | 85 | * https://test.civicrm.org/job/CiviCRM-Core-Matrix/ |
6a488035 TO |
86 | * |
87 | * To Learn about the API read | |
8390b11b | 88 | * https://docs.civicrm.org/dev/en/latest/api/ |
6a488035 | 89 | * |
8390b11b SL |
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. | |
6a488035 TO |
92 | * |
93 | * Read more about testing here | |
8390b11b | 94 | * https://docs.civicrm.org/dev/en/latest/testing/ |
6a488035 TO |
95 | * |
96 | * API Standards documentation: | |
8390b11b | 97 | * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/ |
b259a4ab | 98 | */ |