Merge pull request #1046 from colemanw/showHide
[civicrm-core.git] / api / v3 / examples / Contact / GetSingleContact.php
1 <?php
2
3 /*
4 This demonstrates use of the 'format.single_entity_array' param.
5 /* This param causes the only contact to be returned as an array without the other levels.
6 /* it will be ignored if there is not exactly 1 result
7 */
8 function contact_getsingle_example(){
9 $params = array(
10 'version' => 3,
11 'id' => 17,
12 );
13
14 $result = civicrm_api( 'contact','getsingle',$params );
15
16 return $result;
17 }
18
19 /*
20 * Function returns array of result expected from previous function
21 */
22 function contact_getsingle_expectedresult(){
23
24 $expectedResult = array(
25 'contact_id' => '17',
26 'contact_type' => 'Individual',
27 'contact_sub_type' => '',
28 'sort_name' => '',
29 'display_name' => 'Test Contact',
30 'do_not_email' => '',
31 'do_not_phone' => '',
32 'do_not_mail' => '',
33 'do_not_sms' => '',
34 'do_not_trade' => '',
35 'is_opt_out' => 0,
36 'legal_identifier' => '',
37 'external_identifier' => '',
38 'nick_name' => '',
39 'legal_name' => '',
40 'image_URL' => '',
41 'preferred_mail_format' => '',
42 'first_name' => 'Test',
43 'middle_name' => '',
44 'last_name' => 'Contact',
45 'job_title' => '',
46 'birth_date' => '',
47 'is_deceased' => 0,
48 'deceased_date' => '',
49 'household_name' => '',
50 'organization_name' => '',
51 'sic_code' => '',
52 'contact_is_deleted' => 0,
53 'current_employer' => '',
54 'address_id' => '',
55 'street_address' => '',
56 'supplemental_address_1' => '',
57 'supplemental_address_2' => '',
58 'city' => '',
59 'postal_code_suffix' => '',
60 'postal_code' => '',
61 'geo_code_1' => '',
62 'geo_code_2' => '',
63 'state_province_id' => '',
64 'state_province_name' => '',
65 'state_province' => '',
66 'country_id' => '',
67 'country' => '',
68 'phone_id' => '',
69 'phone_type_id' => '',
70 'phone' => '',
71 'email_id' => '',
72 'email' => '',
73 'on_hold' => '',
74 'im_id' => '',
75 'provider_id' => '',
76 'im' => '',
77 'worldregion_id' => '',
78 'world_region' => '',
79 'id' => '17',
80 );
81
82 return $expectedResult ;
83 }
84
85
86 /*
87 * This example has been generated from the API test suite. The test that created it is called
88 *
89 * testContactGetSingle_entity_array and can be found in
90 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
91 *
92 * You can see the outcome of the API tests at
93 * http://tests.dev.civicrm.org/trunk/results-api_v3
94 *
95 * To Learn about the API read
96 * http://book.civicrm.org/developer/current/techniques/api/
97 *
98 * and review the wiki at
99 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
100 *
101 * Read more about testing here
102 * http://wiki.civicrm.org/confluence/display/CRM/Testing
103 *
104 * API Standards documentation:
105 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
106 */