64b6b3ce57cb3622a6b47d183c8616405e4cdcf9
[civicrm-core.git] / api / v3 / examples / Pledge / GetFilterHighDate.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 = array(
12 'pledge_start_date_high' => '20170205024740',
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 array(
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 = array(
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 2,
47 'values' => array(
48 '2' => array(
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' => '2017-02-07 00:00:00',
57 'pledge_start_date' => '2016-03-04 00:00:00',
58 'pledge_status' => 'Overdue',
59 'pledge_total_paid' => '',
60 'pledge_next_pay_date' => '2016-03-04 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-master-git/
86 *
87 * To Learn about the API read
88 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
89 *
90 * Browse the api on your own site with the api explorer
91 * http://MYSITE.ORG/path/to/civicrm/api
92 *
93 * Read more about testing here
94 * http://wiki.civicrm.org/confluence/display/CRM/Testing
95 *
96 * API Standards documentation:
97 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
98 */