Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-16-17-51-20
[civicrm-core.git] / api / v3 / examples / Pledge / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
3 * Test Generated example of using pledge get API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9function pledge_get_example() {
10 $params = array(
11 'pledge_id' => 1,
12 );
6a488035 13
50fb255d 14 try{
15 $result = civicrm_api3('pledge', 'get', $params);
16 }
17 catch (CiviCRM_API3_Exception $e) {
18 // Handle error here.
19 $errorMessage = $e->getMessage();
20 $errorCode = $e->getErrorCode();
21 $errorData = $e->getExtraParams();
22 return array(
23 'error' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 );
27 }
28
29 return $result;
6a488035
TO
30}
31
fb32de45 32/**
50fb255d 33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
6a488035 37 */
50fb255d 38function pledge_get_expectedresult() {
6a488035 39
53ca8fd7 40 $expectedResult = array(
50fb255d 41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 1,
45 'values' => array(
53ca8fd7 46 '1' => array(
50fb255d 47 'contact_id' => '5',
48 'contact_type' => 'Individual',
49 'contact_sub_type' => '',
50 'sort_name' => 'Anderson, Anthony',
51 'display_name' => 'Mr. Anthony Anderson II',
52 'pledge_id' => '1',
53 'pledge_amount' => '100.00',
54 'pledge_create_date' => '2015-01-15 00:00:00',
55 'pledge_status' => 'Pending',
56 'pledge_total_paid' => '',
57 'pledge_next_pay_date' => '2015-01-17 00:00:00',
58 'pledge_next_pay_amount' => '20.00',
59 'pledge_outstanding_amount' => '',
60 'pledge_financial_type' => 'Donation',
61 'pledge_contribution_page_id' => '',
62 'pledge_frequency_interval' => '5',
63 'pledge_frequency_unit' => 'year',
64 'pledge_is_test' => 0,
65 'pledge_campaign_id' => '',
66 'pledge_currency' => 'USD',
67 'id' => '1',
68 ),
6a488035 69 ),
50fb255d 70 );
6a488035 71
fb32de45 72 return $expectedResult;
6a488035
TO
73}
74
50fb255d 75/**
76* This example has been generated from the API test suite.
77* The test that created it is called
78* testGetPledge
79* and can be found in
69d79249 80* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php
6a488035
TO
81*
82* You can see the outcome of the API tests at
69d79249 83* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
84*
85* To Learn about the API read
69d79249 86* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 87*
69d79249 88* Browse the api on your own site with the api explorer
41d4d31f 89* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
90*
91* Read more about testing here
92* http://wiki.civicrm.org/confluence/display/CRM/Testing
93*
94* API Standards documentation:
95* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 96*/