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