Merge pull request #2342 from totten/4.4-cache-codegen
[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 'job_title' => '',
62 'gender_id' => '',
63 'birth_date' => '',
64 'is_deceased' => 0,
65 'deceased_date' => '',
66 'household_name' => '',
67 'organization_name' => '',
68 'sic_code' => '',
69 'contact_is_deleted' => 0,
70 'current_employer' => '',
71 'address_id' => '2',
72 'street_address' => '1 my road',
73 'supplemental_address_1' => '',
74 'supplemental_address_2' => '',
75 'city' => '',
76 'postal_code_suffix' => '',
77 'postal_code' => '',
78 'geo_code_1' => '',
79 'geo_code_2' => '',
80 'state_province_id' => '',
81 'country_id' => '',
82 'phone_id' => '',
83 'phone_type_id' => '',
84 'phone' => '',
85 'email_id' => '1',
86 'email' => 'man2@yahoo.com',
87 'on_hold' => 0,
88 'im_id' => '',
89 'provider_id' => '',
90 'im' => '',
91 'worldregion_id' => '',
92 'world_region' => '',
93 'individual_prefix' => '',
94 'individual_suffix' => '',
95 'gender' => '',
96 'state_province_name' => '',
97 'state_province' => '',
98 'country' => '',
99 'id' => '1',
100 ),
101 ),
102 );
103
104 return $expectedResult;
105 }
106
107
108 /*
109 * This example has been generated from the API test suite. The test that created it is called
110 *
111 * testContactGetEmail and can be found in
112 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
113 *
114 * You can see the outcome of the API tests at
115 * https://test.civicrm.org/job/CiviCRM-master-git/
116 *
117 * To Learn about the API read
118 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
119 *
120 * Browse the api on your own site with the api explorer
121 * http://MYSITE.ORG/path/to/civicrm/api/explorer
122 *
123 * Read more about testing here
124 * http://wiki.civicrm.org/confluence/display/CRM/Testing
125 *
126 * API Standards documentation:
127 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
128 */