Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
3 | * Test Generated example of using contact get API. | |
4 | * | |
5 | * | |
6 | * @return array | |
7 | * API result array | |
8 | */ | |
9 | function contact_get_example() { | |
10 | $params = array( | |
11 | 'email' => 'man2@yahoo.com', | |
12 | ); | |
6a488035 | 13 | |
50fb255d | 14 | try{ |
15 | $result = civicrm_api3('contact', 'get', $params); | |
16 | } | |
17 | catch (CiviCRM_API3_Exception $e) { | |
18 | // Handle error here. | |
19 | $errorMessage = $e->getMessage(); | |
20 | $errorCode = $e->getErrorCode(); | |
21 | $errorData = $e->getExtraParams(); | |
22 | return array( | |
23 | 'error' => $errorMessage, | |
24 | 'error_code' => $errorCode, | |
25 | 'error_data' => $errorData, | |
26 | ); | |
27 | } | |
28 | ||
29 | return $result; | |
6a488035 TO |
30 | } |
31 | ||
fb32de45 | 32 | /** |
50fb255d | 33 | * Function returns array of result expected from previous function. |
34 | * | |
35 | * @return array | |
36 | * API result array | |
6a488035 | 37 | */ |
50fb255d | 38 | function contact_get_expectedresult() { |
6a488035 | 39 | |
edb0d67a | 40 | $expectedResult = array( |
50fb255d | 41 | 'is_error' => 0, |
42 | 'version' => 3, | |
43 | 'count' => 1, | |
44 | 'id' => 1, | |
45 | 'values' => array( | |
edb0d67a | 46 | '1' => array( |
50fb255d | 47 | 'contact_id' => '1', |
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' => '2', | |
84 | 'street_address' => '1 my road', | |
85 | 'supplemental_address_1' => '', | |
86 | 'supplemental_address_2' => '', | |
87 | 'city' => '', | |
88 | 'postal_code_suffix' => '', | |
89 | 'postal_code' => '', | |
90 | 'geo_code_1' => '', | |
91 | 'geo_code_2' => '', | |
92 | 'state_province_id' => '', | |
93 | 'country_id' => '', | |
94 | 'phone_id' => '', | |
95 | 'phone_type_id' => '', | |
96 | 'phone' => '', | |
97 | 'email_id' => '1', | |
98 | 'email' => 'man2@yahoo.com', | |
99 | 'on_hold' => 0, | |
100 | 'im_id' => '', | |
101 | 'provider_id' => '', | |
102 | 'im' => '', | |
103 | 'worldregion_id' => '', | |
104 | 'world_region' => '', | |
105 | 'individual_prefix' => '', | |
106 | 'individual_suffix' => '', | |
107 | 'communication_style' => '', | |
108 | 'gender' => '', | |
109 | 'state_province_name' => '', | |
110 | 'state_province' => '', | |
111 | 'country' => '', | |
112 | 'id' => '1', | |
113 | ), | |
6a488035 | 114 | ), |
50fb255d | 115 | ); |
6a488035 | 116 | |
fb32de45 | 117 | return $expectedResult; |
6a488035 TO |
118 | } |
119 | ||
50fb255d | 120 | /** |
121 | * This example has been generated from the API test suite. | |
122 | * The test that created it is called | |
123 | * testContactGetEmail | |
124 | * and can be found in | |
69d79249 | 125 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php |
6a488035 TO |
126 | * |
127 | * You can see the outcome of the API tests at | |
69d79249 | 128 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
129 | * |
130 | * To Learn about the API read | |
69d79249 | 131 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 132 | * |
69d79249 | 133 | * Browse the api on your own site with the api explorer |
41d4d31f | 134 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
135 | * |
136 | * Read more about testing here | |
137 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
138 | * | |
139 | * API Standards documentation: | |
140 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 141 | */ |