CRM-13122 fixed default return properties
[civicrm-core.git] / api / v3 / examples / Contact / GroupFilterUsingContactAPI.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using contact get API
4 * Get all from group and display contacts *
6a488035
TO
5 */
6function contact_get_example(){
edb0d67a 7$params = array(
8 'filter.group_id' => array(
6a488035
TO
9 '0' => 1,
10 '1' => 26,
11 ),
6a488035
TO
12 'contact_type' => 'Individual',
13);
14
fb32de45 15try{
16 $result = civicrm_api3('contact', 'get', $params);
17}
18catch (CiviCRM_API3_Exception $e) {
19 // handle error here
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
24}
6a488035 25
fb32de45 26return $result;
6a488035
TO
27}
28
fb32de45 29/**
6a488035
TO
30 * Function returns array of result expected from previous function
31 */
32function contact_get_expectedresult(){
33
edb0d67a 34 $expectedResult = array(
6a488035
TO
35 'is_error' => 0,
36 'version' => 3,
37 'count' => 1,
38 'id' => 1,
edb0d67a 39 'values' => array(
40 '1' => array(
6a488035
TO
41 'contact_id' => '1',
42 'contact_type' => 'Individual',
43 'contact_sub_type' => '',
44 'sort_name' => 'man2@yahoo.com',
45 'display_name' => 'man2@yahoo.com',
46 'do_not_email' => 0,
47 'do_not_phone' => 0,
48 'do_not_mail' => 0,
49 'do_not_sms' => 0,
50 'do_not_trade' => 0,
51 'is_opt_out' => 0,
52 'legal_identifier' => '',
53 'external_identifier' => '',
54 'nick_name' => '',
55 'legal_name' => '',
56 'image_URL' => '',
57 'preferred_mail_format' => 'Both',
58 'first_name' => '',
59 'middle_name' => '',
60 'last_name' => '',
61 'job_title' => '',
62 'birth_date' => '',
63 'is_deceased' => 0,
64 'deceased_date' => '',
65 'household_name' => '',
66 'organization_name' => '',
67 'sic_code' => '',
68 'contact_is_deleted' => 0,
6a488035
TO
69 'current_employer' => '',
70 'address_id' => '',
71 'street_address' => '',
72 'supplemental_address_1' => '',
73 'supplemental_address_2' => '',
74 'city' => '',
75 'postal_code_suffix' => '',
76 'postal_code' => '',
77 'geo_code_1' => '',
78 'geo_code_2' => '',
79 'state_province_id' => '',
6a488035 80 'country_id' => '',
6a488035
TO
81 'phone_id' => '',
82 'phone_type_id' => '',
83 'phone' => '',
84 'email_id' => '1',
85 'email' => 'man2@yahoo.com',
86 'on_hold' => 0,
87 'im_id' => '',
88 'provider_id' => '',
89 'im' => '',
90 'worldregion_id' => '',
91 'world_region' => '',
9f1b81e0 92 'state_province_name' => '',
93 'state_province' => '',
94 'country' => '',
6a488035
TO
95 'id' => '1',
96 ),
97 ),
98);
99
fb32de45 100 return $expectedResult;
6a488035
TO
101}
102
103
104/*
105* This example has been generated from the API test suite. The test that created it is called
106*
107* testGetGroupIDFromContact and can be found in
108* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php
109*
110* You can see the outcome of the API tests at
111* http://tests.dev.civicrm.org/trunk/results-api_v3
112*
113* To Learn about the API read
114* http://book.civicrm.org/developer/current/techniques/api/
115*
116* and review the wiki at
117* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
118*
119* Read more about testing here
120* http://wiki.civicrm.org/confluence/display/CRM/Testing
121*
122* API Standards documentation:
123* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
124*/