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