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