Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / Profile / Submit.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Profile.submit API.
4 *
5 * @return array
6 * API result array
7 */
8 function profile_submit_example() {
9 $params = [
10 'profile_id' => 29,
11 'contact_id' => 3,
12 'first_name' => 'abc2',
13 'last_name' => 'xyz2',
14 'email-primary' => 'abc2.xyz2@gmail.com',
15 'phone-1-1' => '022 321 826',
16 'country-1' => '1013',
17 'state_province-1' => '1000',
18 ];
19
20 try{
21 $result = civicrm_api3('Profile', 'submit', $params);
22 }
23 catch (CiviCRM_API3_Exception $e) {
24 // Handle error here.
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return [
29 'is_error' => 1,
30 'error_message' => $errorMessage,
31 'error_code' => $errorCode,
32 'error_data' => $errorData,
33 ];
34 }
35
36 return $result;
37 }
38
39 /**
40 * Function returns array of result expected from previous function.
41 *
42 * @return array
43 * API result array
44 */
45 function profile_submit_expectedresult() {
46
47 $expectedResult = [
48 'is_error' => 0,
49 'version' => 3,
50 'count' => 1,
51 'id' => 3,
52 'values' => [
53 '3' => [
54 'id' => '3',
55 'contact_type' => 'Individual',
56 'contact_sub_type' => '',
57 'do_not_email' => 0,
58 'do_not_phone' => 0,
59 'do_not_mail' => 0,
60 'do_not_sms' => 0,
61 'do_not_trade' => 0,
62 'is_opt_out' => 0,
63 'legal_identifier' => '',
64 'external_identifier' => '',
65 'sort_name' => 'xyz2, abc2',
66 'display_name' => 'Mr. abc2 xyz2 II',
67 'nick_name' => '',
68 'legal_name' => '',
69 'image_URL' => '',
70 'preferred_communication_method' => '',
71 'preferred_language' => 'en_US',
72 'preferred_mail_format' => 'Both',
73 'hash' => '67eac7789eaee00',
74 'api_key' => '',
75 'first_name' => 'abc2',
76 'middle_name' => 'J.',
77 'last_name' => 'xyz2',
78 'prefix_id' => '3',
79 'suffix_id' => '3',
80 'formal_title' => '',
81 'communication_style_id' => '',
82 'email_greeting_id' => '1',
83 'email_greeting_custom' => '',
84 'email_greeting_display' => 'Dear abc1',
85 'postal_greeting_id' => '1',
86 'postal_greeting_custom' => '',
87 'postal_greeting_display' => 'Dear abc1',
88 'addressee_id' => '1',
89 'addressee_custom' => '',
90 'addressee_display' => 'Mr. abc1 J. xyz1 II',
91 'job_title' => '',
92 'gender_id' => '',
93 'birth_date' => '',
94 'is_deceased' => 0,
95 'deceased_date' => '',
96 'household_name' => '',
97 'primary_contact_id' => '',
98 'organization_name' => '',
99 'sic_code' => '',
100 'user_unique_id' => '',
101 'created_date' => '2013-07-28 08:49:19',
102 'modified_date' => '2012-11-14 16:02:35',
103 ],
104 ],
105 ];
106
107 return $expectedResult;
108 }
109
110 /*
111 * This example has been generated from the API test suite.
112 * The test that created it is called "testProfileSubmit"
113 * and can be found at:
114 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
115 *
116 * You can see the outcome of the API tests at
117 * https://test.civicrm.org/job/CiviCRM-master-git/
118 *
119 * To Learn about the API read
120 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
121 *
122 * Browse the api on your own site with the api explorer
123 * http://MYSITE.ORG/path/to/civicrm/api
124 *
125 * Read more about testing here
126 * http://wiki.civicrm.org/confluence/display/CRM/Testing
127 *
128 * API Standards documentation:
129 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
130 */