CRM-15988 - Mass cleanup of api entity names to CamelCase
[civicrm-core.git] / api / v3 / examples / Profile / GetFields.php
CommitLineData
9dec4e61 1<?php
50fb255d 2/**
3 * Test Generated example of using profile getfields API.
4 *
5 * demonstrates retrieving profile fields passing in an id
6 *
7 * @return array
8 * API result array
9 */
10function profile_getfields_example() {
11 $params = array(
12 'action' => 'submit',
13 'profile_id' => 27,
14 );
9dec4e61 15
50fb255d 16 try{
17 $result = civicrm_api3('profile', 'getfields', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // Handle error here.
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array(
25 'error' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 );
29 }
30
31 return $result;
9dec4e61 32}
33
34/**
50fb255d 35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
9dec4e61 39 */
50fb255d 40function profile_getfields_expectedresult() {
9dec4e61 41
42 $expectedResult = array(
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 9,
46 'values' => array(
b259a4ab 47 'custom_1' => array(
50fb255d 48 'label' => '_addCustomFieldToProfile',
49 'groupTitle' => '_addCustomFie',
50 'data_type' => 'String',
51 'html_type' => 'Text',
52 'default_value' => 'defaultValue',
53 'text_length' => '',
54 'options_per_line' => '',
55 'custom_group_id' => '1',
56 'extends' => 'Contact',
57 'is_search_range' => 0,
58 'extends_entity_column_value' => '',
59 'extends_entity_column_id' => '',
60 'is_view' => 0,
61 'is_multiple' => 0,
62 'option_group_id' => '',
63 'date_format' => '',
64 'time_format' => '',
65 'is_required' => 0,
66 'name' => 'custom_1',
67 'title' => 'first_name',
68 'type' => 2,
69 'api.required' => '1',
70 'help_pre' => '',
71 'help_post' => '',
72 'entity' => 'contact',
73 'weight' => '1',
74 'api.aliases' => array(),
75 ),
b259a4ab 76 'postal_code-1' => array(
50fb255d 77 'name' => 'postal_code',
78 'type' => 2,
79 'title' => 'State Province',
80 'maxlength' => 12,
81 'size' => 12,
82 'import' => TRUE,
83 'where' => 'civicrm_address.postal_code',
84 'headerPattern' => '/postal|zip/i',
85 'dataPattern' => '/\\d?\\d{4}(-\\d{4})?/',
86 'export' => TRUE,
87 'api.required' => 0,
88 'help_pre' => '',
89 'help_post' => '',
90 'entity' => 'address',
91 'weight' => '2',
92 'api.aliases' => array(),
93 ),
b259a4ab 94 'state_province-1' => array(
50fb255d 95 'name' => 'state_province_id',
96 'type' => 1,
97 'title' => 'State Province',
98 'FKClassName' => 'CRM_Core_DAO_StateProvince',
99 'html' => array(
100 'type' => 'Select',
101 ),
102 'pseudoconstant' => array(
103 'table' => 'civicrm_state_province',
104 'keyColumn' => 'id',
105 'labelColumn' => 'name',
b259a4ab 106 ),
50fb255d 107 'FKApiName' => 'StateProvince',
108 'api.required' => '1',
109 'help_pre' => '',
110 'help_post' => '',
111 'entity' => 'address',
112 'weight' => '3',
113 'api.aliases' => array(),
114 ),
b259a4ab 115 'country-1' => array(
50fb255d 116 'name' => 'country_id',
117 'type' => 1,
118 'title' => 'Country',
119 'FKClassName' => 'CRM_Core_DAO_Country',
120 'html' => array(
121 'type' => 'Select',
9dec4e61 122 ),
50fb255d 123 'pseudoconstant' => array(
124 'table' => 'civicrm_country',
125 'keyColumn' => 'id',
126 'labelColumn' => 'name',
127 'nameColumn' => 'iso_code',
9dec4e61 128 ),
50fb255d 129 'FKApiName' => 'Country',
130 'api.required' => '1',
131 'help_pre' => '',
132 'help_post' => '',
133 'entity' => 'address',
134 'weight' => '4',
135 'api.aliases' => array(),
136 ),
137 'phone-1-1' => array(
138 'name' => 'phone',
139 'type' => 2,
140 'title' => 'Phone',
141 'maxlength' => 32,
142 'size' => 20,
143 'import' => TRUE,
144 'where' => 'civicrm_phone.phone',
145 'headerPattern' => '/phone/i',
146 'dataPattern' => '/^[\\d\\(\\)\\-\\.\\s]+$/',
147 'export' => TRUE,
148 'api.required' => '1',
149 'help_pre' => '',
150 'help_post' => '',
151 'entity' => 'phone',
152 'weight' => '5',
153 'api.aliases' => array(),
154 ),
b259a4ab 155 'email-primary' => array(
50fb255d 156 'name' => 'email',
157 'type' => 2,
158 'title' => 'Email',
159 'maxlength' => 254,
160 'size' => 20,
161 'import' => TRUE,
162 'where' => 'civicrm_email.email',
163 'headerPattern' => '/e.?mail/i',
164 'dataPattern' => '/^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$/',
165 'export' => TRUE,
166 'rule' => 'email',
167 'html' => array(
168 'type' => 'Text',
b259a4ab 169 ),
50fb255d 170 'api.required' => '1',
171 'help_pre' => '',
172 'help_post' => '',
173 'entity' => 'email',
174 'weight' => '6',
175 'api.aliases' => array(
176 '0' => 'email-Primary',
177 ),
178 ),
b259a4ab 179 'last_name' => array(
50fb255d 180 'name' => 'last_name',
181 'type' => 2,
182 'title' => 'Last Name',
183 'maxlength' => 64,
184 'size' => 30,
185 'import' => TRUE,
186 'where' => 'civicrm_contact.last_name',
187 'headerPattern' => '/^last|(l(ast\\s)?name)$/i',
188 'dataPattern' => '/^\\w+(\\s\\w+)?+$/',
189 'export' => TRUE,
190 'html' => array(
191 'type' => 'Text',
9dec4e61 192 ),
50fb255d 193 'api.required' => '1',
194 'help_pre' => '',
195 'help_post' => '',
196 'entity' => 'contact',
197 'weight' => '7',
198 'api.aliases' => array(),
199 ),
b259a4ab 200 'first_name' => array(
50fb255d 201 'name' => 'first_name',
202 'type' => 2,
203 'title' => 'First Name',
204 'maxlength' => 64,
205 'size' => 30,
206 'import' => TRUE,
207 'where' => 'civicrm_contact.first_name',
208 'headerPattern' => '/^first|(f(irst\\s)?name)$/i',
209 'dataPattern' => '/^\\w+$/',
210 'export' => TRUE,
211 'html' => array(
212 'type' => 'Text',
9dec4e61 213 ),
50fb255d 214 'api.required' => '1',
215 'help_pre' => '',
216 'help_post' => '',
217 'entity' => 'contact',
218 'weight' => '8',
219 'api.aliases' => array(),
220 ),
9dec4e61 221 'profile_id' => array(
50fb255d 222 'api.required' => TRUE,
223 'title' => 'Profile ID',
5c49fee0 224 'name' => 'profile_id',
50fb255d 225 ),
9dec4e61 226 ),
50fb255d 227 );
9dec4e61 228
229 return $expectedResult;
230}
231
50fb255d 232/**
233* This example has been generated from the API test suite.
234* The test that created it is called
235* testGetFields
236* and can be found in
69d79249 237* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
9dec4e61 238*
239* You can see the outcome of the API tests at
69d79249 240* https://test.civicrm.org/job/CiviCRM-master-git/
9dec4e61 241*
242* To Learn about the API read
69d79249 243* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
9dec4e61 244*
69d79249 245* Browse the api on your own site with the api explorer
41d4d31f 246* http://MYSITE.ORG/path/to/civicrm/api
9dec4e61 247*
248* Read more about testing here
249* http://wiki.civicrm.org/confluence/display/CRM/Testing
250*
251* API Standards documentation:
252* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 253*/