updated examples
[civicrm-core.git] / api / v3 / examples / Profile / Get.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using profile get API
4 * *
6a488035
TO
5 */
6function profile_get_example(){
53ca8fd7 7$params = array(
f01ce56b 8 'profile_id' => array(
c3d3e837 9 '0' => 14,
f01ce56b 10 '1' => 1,
11 '2' => 'Billing',
12 ),
c3d3e837 13 'contact_id' => 2,
6a488035
TO
14);
15
fb32de45 16try{
17 $result = civicrm_api3('profile', 'get', $params);
18}
19catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25}
6a488035 26
fb32de45 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function profile_get_expectedresult(){
34
53ca8fd7 35 $expectedResult = array(
6a488035
TO
36 'is_error' => 0,
37 'version' => 3,
f01ce56b 38 'count' => 3,
53ca8fd7 39 'values' => array(
c3d3e837 40 '14' => array(
e0efd2d0 41 'postal_code-1' => '90210',
c3d3e837
E
42 'state_province-1' => '1021',
43 'country-1' => '1228',
44 'phone-1-1' => '021 512 755',
45 'email-Primary' => 'abc1.xyz1@yahoo.com',
46 'last_name' => 'xyz1',
47 'first_name' => 'abc1',
48 'email-primary' => 'abc1.xyz1@yahoo.com',
f01ce56b 49 ),
50 '1' => array(
51 'first_name' => 'abc1',
52 'last_name' => 'xyz1',
b29f74b6 53 'street_address-1' => '5 Saint Helier St',
54 'city-1' => 'Gotham City',
e0efd2d0 55 'postal_code-1' => '90210',
f01ce56b 56 'country-1' => '1228',
57 'state_province-1' => '1021',
58 ),
59 'Billing' => array(
60 'billing_first_name' => 'abc1',
e0efd2d0 61 'billing_middle_name' => 'J.',
f01ce56b 62 'billing_last_name' => 'xyz1',
b29f74b6 63 'billing_street_address-5' => '5 Saint Helier St',
64 'billing_city-5' => 'Gotham City',
e0efd2d0 65 'billing_state_province_id-5' => '1021',
45c30250 66 'billing_country_id-5' => '1228',
e0efd2d0 67 'billing_postal_code-5' => '90210',
f01ce56b 68 'billing-email-5' => 'abc1.xyz1@yahoo.com',
e0efd2d0 69 'email-5' => 'abc1.xyz1@yahoo.com',
f01ce56b 70 ),
6a488035
TO
71 ),
72);
73
fb32de45 74 return $expectedResult;
6a488035
TO
75}
76
77
78/*
79* This example has been generated from the API test suite. The test that created it is called
80*
f01ce56b 81* testProfileGetMultiple and can be found in
69d79249 82* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ProfileTest.php
6a488035
TO
83*
84* You can see the outcome of the API tests at
69d79249 85* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
86*
87* To Learn about the API read
69d79249 88* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 89*
69d79249
E
90* Browse the api on your own site with the api explorer
91* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
92*
93* Read more about testing here
94* http://wiki.civicrm.org/confluence/display/CRM/Testing
95*
96* API Standards documentation:
97* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 98*/