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