Merge pull request #5020 from pratikshad/4.6-alpha4
[civicrm-core.git] / api / v3 / examples / PriceFieldValue / Create.php
1 <?php
2 /**
3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8 /**
9 * Test Generated example of using price_field_value create API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15 function price_field_value_create_example() {
16 $params = array(
17 'price_field_id' => 13,
18 'membership_type_id' => 5,
19 'name' => 'memType1',
20 'label' => 'memType1',
21 'amount' => 90,
22 'membership_num_terms' => 2,
23 'is_active' => 1,
24 'financial_type_id' => 2,
25 );
26
27 try{
28 $result = civicrm_api3('price_field_value', 'create', $params);
29 }
30 catch (CiviCRM_API3_Exception $e) {
31 // Handle error here.
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
35 return array(
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
39 );
40 }
41
42 return $result;
43 }
44
45 /**
46 * Function returns array of result expected from previous function.
47 *
48 * @return array
49 * API result array
50 */
51 function price_field_value_create_expectedresult() {
52
53 $expectedResult = array(
54 'is_error' => 0,
55 'version' => 3,
56 'count' => 1,
57 'id' => 10,
58 'values' => array(
59 '10' => array(
60 'id' => '10',
61 'price_field_id' => '13',
62 'name' => 'memType1',
63 'label' => 'memType1',
64 'description' => '',
65 'amount' => '90',
66 'count' => '',
67 'max_value' => '',
68 'weight' => '1',
69 'membership_type_id' => '5',
70 'membership_num_terms' => '2',
71 'is_default' => '',
72 'is_active' => '1',
73 'financial_type_id' => '2',
74 'deductible_amount' => '',
75 'contribution_type_id' => '2',
76 ),
77 ),
78 );
79
80 return $expectedResult;
81 }
82
83 /**
84 * This example has been generated from the API test suite.
85 * The test that created it is called
86 * testCreatePriceFieldValuewithMultipleTerms
87 * and can be found in
88 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PriceFieldValueTest.php
89 *
90 * You can see the outcome of the API tests at
91 * https://test.civicrm.org/job/CiviCRM-master-git/
92 *
93 * To Learn about the API read
94 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
95 *
96 * Browse the api on your own site with the api explorer
97 * http://MYSITE.ORG/path/to/civicrm/api/explorer
98 *
99 * Read more about testing here
100 * http://wiki.civicrm.org/confluence/display/CRM/Testing
101 *
102 * API Standards documentation:
103 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
104 */