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