Merge pull request #4947 from eileenmcnaughton/examples
[civicrm-core.git] / api / v3 / examples / Profile / Apply.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
6a488035 7
50fb255d 8/**
9 * Test Generated example of using profile apply API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15function profile_apply_example() {
16 $params = array(
17 'profile_id' => 31,
18 'contact_id' => 3,
19 'first_name' => 'abc2',
20 'last_name' => 'xyz2',
21 'email-Primary' => 'abc2.xyz2@gmail.com',
22 'phone-1-1' => '022 321 826',
23 'country-1' => '1013',
24 'state_province-1' => '1000',
25 );
6a488035 26
50fb255d 27 try{
28 $result = civicrm_api3('profile', 'apply', $params);
29 }
30 catch (CiviCRM_API3_Exception $e) {
31 // Handle error here.
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
35 return array(
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
39 );
40 }
41
42 return $result;
6a488035
TO
43}
44
fb32de45 45/**
50fb255d 46 * Function returns array of result expected from previous function.
47 *
48 * @return array
49 * API result array
6a488035 50 */
50fb255d 51function profile_apply_expectedresult() {
6a488035 52
53ca8fd7 53 $expectedResult = array(
50fb255d 54 'is_error' => 0,
55 'version' => 3,
56 'count' => 11,
57 'values' => array(
6a488035
TO
58 'contact_type' => 'Individual',
59 'contact_sub_type' => '',
89bf81b4 60 'contact_id' => 3,
6a488035 61 'version' => 3,
f27f2724 62 'debug' => 1,
c3d3e837 63 'profile_id' => 31,
6a488035
TO
64 'first_name' => 'abc2',
65 'last_name' => 'xyz2',
53ca8fd7 66 'email' => array(
50fb255d 67 '1' => array(
68 'location_type_id' => '1',
69 'is_primary' => 1,
70 'email' => 'abc2.xyz2@gmail.com',
6a488035 71 ),
50fb255d 72 ),
53ca8fd7 73 'phone' => array(
50fb255d 74 '2' => array(
75 'location_type_id' => '1',
76 'is_primary' => 1,
77 'phone_type_id' => '1',
78 'phone' => '022 321 826',
6a488035 79 ),
50fb255d 80 ),
53ca8fd7 81 'address' => array(
50fb255d 82 '1' => array(
83 'location_type_id' => '1',
84 'is_primary' => 1,
85 'country_id' => '1013',
86 'state_province_id' => '1000',
6a488035 87 ),
50fb255d 88 ),
6a488035 89 ),
50fb255d 90 );
6a488035 91
fb32de45 92 return $expectedResult;
6a488035
TO
93}
94
50fb255d 95/**
96* This example has been generated from the API test suite.
97* The test that created it is called
98* testProfileApply
99* and can be found in
69d79249 100* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
6a488035
TO
101*
102* You can see the outcome of the API tests at
69d79249 103* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
104*
105* To Learn about the API read
69d79249 106* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 107*
69d79249
E
108* Browse the api on your own site with the api explorer
109* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
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
b259a4ab 116*/