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