Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-09-11-44-07
[civicrm-core.git] / api / v3 / examples / ContributionSoft / Create.php
1 <?php
2 /**
3 * Test Generated example of using contribution_soft create API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9 function contribution_soft_create_example() {
10 $params = array(
11 'contribution_id' => 6,
12 'contact_id' => 19,
13 'amount' => '10',
14 'currency' => 'USD',
15 'soft_credit_type_id' => 5,
16 );
17
18 try{
19 $result = civicrm_api3('contribution_soft', 'create', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'error' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 );
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function contribution_soft_create_expectedresult() {
43
44 $expectedResult = array(
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 5,
49 'values' => array(
50 '5' => array(
51 'id' => '5',
52 'contribution_id' => '6',
53 'contact_id' => '19',
54 'amount' => '10',
55 'currency' => 'USD',
56 'pcp_id' => '',
57 'pcp_display_in_roll' => '',
58 'pcp_roll_nickname' => '',
59 'pcp_personal_note' => '',
60 'soft_credit_type_id' => '5',
61 ),
62 ),
63 );
64
65 return $expectedResult;
66 }
67
68 /**
69 * This example has been generated from the API test suite.
70 * The test that created it is called
71 * testCreateContributionSoft
72 * and can be found in
73 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionSoftTest.php
74 *
75 * You can see the outcome of the API tests at
76 * https://test.civicrm.org/job/CiviCRM-master-git/
77 *
78 * To Learn about the API read
79 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
80 *
81 * Browse the api on your own site with the api explorer
82 * http://MYSITE.ORG/path/to/civicrm/api
83 *
84 * Read more about testing here
85 * http://wiki.civicrm.org/confluence/display/CRM/Testing
86 *
87 * API Standards documentation:
88 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
89 */