Merge pull request #2342 from totten/4.4-cache-codegen
[civicrm-core.git] / api / v3 / examples / Contact / Get.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using contact get API
4 * *
6a488035
TO
5 */
6function contact_get_example(){
edb0d67a 7$params = array(
6a488035 8 'email' => 'man2@yahoo.com',
6a488035
TO
9);
10
fb32de45 11try{
12 $result = civicrm_api3('contact', 'get', $params);
13}
14catch (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}
6a488035 21
fb32de45 22return $result;
6a488035
TO
23}
24
fb32de45 25/**
6a488035
TO
26 * Function returns array of result expected from previous function
27 */
28function contact_get_expectedresult(){
29
edb0d67a 30 $expectedResult = array(
6a488035
TO
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 1,
34 'id' => 1,
edb0d67a 35 'values' => array(
36 '1' => array(
6a488035
TO
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' => '',
b259a4ab
EM
53 'preferred_communication_method' => '',
54 'preferred_language' => 'en_US',
6a488035
TO
55 'preferred_mail_format' => 'Both',
56 'first_name' => '',
57 'middle_name' => '',
58 'last_name' => '',
6ecbca5b 59 'prefix_id' => '',
60 'suffix_id' => '',
6a488035 61 'job_title' => '',
6ecbca5b 62 'gender_id' => '',
6a488035
TO
63 'birth_date' => '',
64 'is_deceased' => 0,
65 'deceased_date' => '',
66 'household_name' => '',
67 'organization_name' => '',
68 'sic_code' => '',
69 'contact_is_deleted' => 0,
6a488035 70 'current_employer' => '',
69d79249
E
71 'address_id' => '2',
72 'street_address' => '1 my road',
6a488035
TO
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' => '',
6a488035 81 'country_id' => '',
6a488035
TO
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' => '',
6ecbca5b 93 'individual_prefix' => '',
94 'individual_suffix' => '',
95 'gender' => '',
9f1b81e0 96 'state_province_name' => '',
97 'state_province' => '',
98 'country' => '',
6a488035
TO
99 'id' => '1',
100 ),
101 ),
102);
103
fb32de45 104 return $expectedResult;
6a488035
TO
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
69d79249 112* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
113*
114* You can see the outcome of the API tests at
69d79249 115* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
116*
117* To Learn about the API read
69d79249 118* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 119*
69d79249
E
120* Browse the api on your own site with the api explorer
121* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
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
b259a4ab 128*/