test tweaks and updated examples
[civicrm-core.git] / api / v3 / examples / ContactGet.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' => '',
53 'preferred_mail_format' => 'Both',
54 'first_name' => '',
55 'middle_name' => '',
56 'last_name' => '',
57 'job_title' => '',
58 'birth_date' => '',
59 'is_deceased' => 0,
60 'deceased_date' => '',
61 'household_name' => '',
62 'organization_name' => '',
63 'sic_code' => '',
64 'contact_is_deleted' => 0,
6a488035
TO
65 'current_employer' => '',
66 'address_id' => '',
67 'street_address' => '',
68 'supplemental_address_1' => '',
69 'supplemental_address_2' => '',
70 'city' => '',
71 'postal_code_suffix' => '',
72 'postal_code' => '',
73 'geo_code_1' => '',
74 'geo_code_2' => '',
75 'state_province_id' => '',
6a488035 76 'country_id' => '',
6a488035
TO
77 'phone_id' => '',
78 'phone_type_id' => '',
79 'phone' => '',
80 'email_id' => '1',
81 'email' => 'man2@yahoo.com',
82 'on_hold' => 0,
83 'im_id' => '',
84 'provider_id' => '',
85 'im' => '',
86 'worldregion_id' => '',
87 'world_region' => '',
9f1b81e0 88 'state_province_name' => '',
89 'state_province' => '',
90 'country' => '',
6a488035
TO
91 'id' => '1',
92 ),
93 ),
94);
95
fb32de45 96 return $expectedResult;
6a488035
TO
97}
98
99
100/*
101* This example has been generated from the API test suite. The test that created it is called
102*
103* testContactGetEmail and can be found in
104* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
105*
106* You can see the outcome of the API tests at
107* http://tests.dev.civicrm.org/trunk/results-api_v3
108*
109* To Learn about the API read
110* http://book.civicrm.org/developer/current/techniques/api/
111*
112* and review the wiki at
113* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
114*
115* Read more about testing here
116* http://wiki.civicrm.org/confluence/display/CRM/Testing
117*
118* API Standards documentation:
119* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
120*/