Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / MembershipType / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the MembershipType.create API.
4 *
5 * @return array
6 * API result array
7 */
8 function membership_type_create_example() {
9 $params = array(
10 'name' => '40+ Membership',
11 'description' => 'people above 40 are given health instructions',
12 'member_of_contact_id' => 13,
13 'financial_type_id' => 1,
14 'domain_id' => '1',
15 'minimum_fee' => '200',
16 'duration_unit' => 'month',
17 'duration_interval' => '10',
18 'period_type' => 'rolling',
19 'visibility' => 'public',
20 );
21
22 try{
23 $result = civicrm_api3('MembershipType', 'create', $params);
24 }
25 catch (CiviCRM_API3_Exception $e) {
26 // Handle error here.
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
30 return array(
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
38 }
39
40 /**
41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
45 */
46 function membership_type_create_expectedresult() {
47
48 $expectedResult = array(
49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 2,
53 'values' => array(
54 '2' => array(
55 'id' => '2',
56 'domain_id' => '1',
57 'name' => '40+ Membership',
58 'description' => 'people above 40 are given health instructions',
59 'member_of_contact_id' => '13',
60 'financial_type_id' => '1',
61 'minimum_fee' => '200',
62 'duration_unit' => 'month',
63 'duration_interval' => '10',
64 'period_type' => 'rolling',
65 'fixed_period_start_day' => '',
66 'fixed_period_rollover_day' => '',
67 'relationship_type_id' => '',
68 'relationship_direction' => '',
69 'max_related' => '',
70 'visibility' => 'Public',
71 'weight' => '',
72 'receipt_text_signup' => '',
73 'receipt_text_renewal' => '',
74 'auto_renew' => '',
75 'is_active' => '',
76 'contribution_type_id' => '1',
77 ),
78 ),
79 );
80
81 return $expectedResult;
82 }
83
84 /*
85 * This example has been generated from the API test suite.
86 * The test that created it is called "testCreate"
87 * and can be found at:
88 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTypeTest.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
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 */