Merge remote branch 'canonical/master' into merge-20140930
[civicrm-core.git] / api / v3 / examples / Contact / Get.php
1 <?php
2 /**
3 * Test Generated example of using contact get API
4 * *
5 */
6 function contact_get_example(){
7 $params = array(
8 'email' => 'man2@yahoo.com',
9 );
10
11 try{
12 $result = civicrm_api3('contact', 'get', $params);
13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20 }
21
22 return $result;
23 }
24
25 /**
26 * Function returns array of result expected from previous function
27 */
28 function contact_get_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 1,
34 'id' => 1,
35 'values' => array(
36 '1' => array(
37 'contact_id' => '1',
38 'contact_type' => 'Individual',
39 'contact_sub_type' => '',
40 'sort_name' => 'man2@yahoo.com',
41 'display_name' => 'man2@yahoo.com',
42 'do_not_email' => 0,
43 'do_not_phone' => 0,
44 'do_not_mail' => 0,
45 'do_not_sms' => 0,
46 'do_not_trade' => 0,
47 'is_opt_out' => 0,
48 'legal_identifier' => '',
49 'external_identifier' => '',
50 'nick_name' => '',
51 'legal_name' => '',
52 'image_URL' => '',
53 'preferred_communication_method' => '',
54 'preferred_language' => 'en_US',
55 'preferred_mail_format' => 'Both',
56 'first_name' => '',
57 'middle_name' => '',
58 'last_name' => '',
59 'prefix_id' => '',
60 'suffix_id' => '',
61 'formal_title' => '',
62 'communication_style_id' => '',
63 'job_title' => '',
64 'gender_id' => '',
65 'birth_date' => '',
66 'is_deceased' => 0,
67 'deceased_date' => '',
68 'household_name' => '',
69 'organization_name' => '',
70 'sic_code' => '',
71 'contact_is_deleted' => 0,
72 'current_employer' => '',
73 'address_id' => '2',
74 'street_address' => '1 my road',
75 'supplemental_address_1' => '',
76 'supplemental_address_2' => '',
77 'city' => '',
78 'postal_code_suffix' => '',
79 'postal_code' => '',
80 'geo_code_1' => '',
81 'geo_code_2' => '',
82 'state_province_id' => '',
83 'country_id' => '',
84 'phone_id' => '',
85 'phone_type_id' => '',
86 'phone' => '',
87 'email_id' => '1',
88 'email' => 'man2@yahoo.com',
89 'on_hold' => 0,
90 'im_id' => '',
91 'provider_id' => '',
92 'im' => '',
93 'worldregion_id' => '',
94 'world_region' => '',
95 'individual_prefix' => '',
96 'individual_suffix' => '',
97 'communication_style' => '',
98 'gender' => '',
99 'state_province_name' => '',
100 'state_province' => '',
101 'country' => '',
102 'id' => '1',
103 ),
104 ),
105 );
106
107 return $expectedResult;
108 }
109
110
111 /*
112 * This example has been generated from the API test suite. The test that created it is called
113 *
114 * testContactGetEmail and can be found in
115 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
116 *
117 * You can see the outcome of the API tests at
118 * https://test.civicrm.org/job/CiviCRM-master-git/
119 *
120 * To Learn about the API read
121 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
122 *
123 * Browse the api on your own site with the api explorer
124 * http://MYSITE.ORG/path/to/civicrm/api/explorer
125 *
126 * Read more about testing here
127 * http://wiki.civicrm.org/confluence/display/CRM/Testing
128 *
129 * API Standards documentation:
130 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
131 */