updated examples
[civicrm-core.git] / api / v3 / examples / Profile / Apply.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using profile apply API
4 * *
6a488035
TO
5 */
6function profile_apply_example(){
53ca8fd7 7$params = array(
c3d3e837
E
8 'profile_id' => 31,
9 'contact_id' => 2,
6a488035
TO
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
fb32de45 18try{
19 $result = civicrm_api3('profile', 'apply', $params);
20}
21catch (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}
6a488035 28
fb32de45 29return $result;
6a488035
TO
30}
31
fb32de45 32/**
6a488035
TO
33 * Function returns array of result expected from previous function
34 */
35function profile_apply_expectedresult(){
36
53ca8fd7 37 $expectedResult = array(
6a488035
TO
38 'is_error' => 0,
39 'version' => 3,
f27f2724 40 'count' => 11,
53ca8fd7 41 'values' => array(
6a488035
TO
42 'contact_type' => 'Individual',
43 'contact_sub_type' => '',
c3d3e837 44 'contact_id' => 2,
6a488035 45 'version' => 3,
f27f2724 46 'debug' => 1,
c3d3e837 47 'profile_id' => 31,
6a488035
TO
48 'first_name' => 'abc2',
49 'last_name' => 'xyz2',
53ca8fd7 50 'email' => array(
51 '1' => array(
6a488035
TO
52 'location_type_id' => '1',
53 'is_primary' => 1,
54 'email' => 'abc2.xyz2@gmail.com',
55 ),
56 ),
53ca8fd7 57 'phone' => array(
58 '2' => array(
6a488035
TO
59 'location_type_id' => '1',
60 'is_primary' => 1,
61 'phone_type_id' => '1',
62 'phone' => '022 321 826',
63 ),
64 ),
53ca8fd7 65 'address' => array(
66 '1' => array(
6a488035
TO
67 'location_type_id' => '1',
68 'is_primary' => 1,
69 'country_id' => '1013',
70 'state_province_id' => '1000',
71 ),
72 ),
73 ),
74);
75
fb32de45 76 return $expectedResult;
6a488035
TO
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
69d79249 84* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
6a488035
TO
85*
86* You can see the outcome of the API tests at
69d79249 87* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
88*
89* To Learn about the API read
69d79249 90* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 91*
69d79249
E
92* Browse the api on your own site with the api explorer
93* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
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
b259a4ab 100*/