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