Merge pull request #4087 from robinmitra/master
[civicrm-core.git] / api / v3 / examples / Profile / Apply.php
1 <?php
2 /**
3 * Test Generated example of using profile apply API
4 * *
5 */
6 function profile_apply_example(){
7 $params = array(
8 'profile_id' => 31,
9 'contact_id' => 3,
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', 'apply', $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_apply_expectedresult(){
36
37 $expectedResult = array(
38 'is_error' => 0,
39 'version' => 3,
40 'count' => 11,
41 'values' => array(
42 'contact_type' => 'Individual',
43 'contact_sub_type' => '',
44 'contact_id' => 3,
45 'version' => 3,
46 'debug' => 1,
47 'profile_id' => 31,
48 'first_name' => 'abc2',
49 'last_name' => 'xyz2',
50 'email' => array(
51 '1' => array(
52 'location_type_id' => '1',
53 'is_primary' => 1,
54 'email' => 'abc2.xyz2@gmail.com',
55 ),
56 ),
57 'phone' => array(
58 '2' => array(
59 'location_type_id' => '1',
60 'is_primary' => 1,
61 'phone_type_id' => '1',
62 'phone' => '022 321 826',
63 ),
64 ),
65 'address' => array(
66 '1' => array(
67 'location_type_id' => '1',
68 'is_primary' => 1,
69 'country_id' => '1013',
70 'state_province_id' => '1000',
71 ),
72 ),
73 ),
74 );
75
76 return $expectedResult;
77 }
78
79
80 /*
81 * This example has been generated from the API test suite. The test that created it is called
82 *
83 * testProfileApply and can be found in
84 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
85 *
86 * You can see the outcome of the API tests at
87 * https://test.civicrm.org/job/CiviCRM-master-git/
88 *
89 * To Learn about the API read
90 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
91 *
92 * Browse the api on your own site with the api explorer
93 * http://MYSITE.ORG/path/to/civicrm/api/explorer
94 *
95 * Read more about testing here
96 * http://wiki.civicrm.org/confluence/display/CRM/Testing
97 *
98 * API Standards documentation:
99 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
100 */