Merge branch 'rcsheets-docstring-cleanup'
[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' => '',
b259a4ab
EM
57 'preferred_communication_method' => '',
58 'preferred_language' => 'en_US',
6a488035
TO
59 'preferred_mail_format' => 'Both',
60 'first_name' => '',
61 'middle_name' => '',
62 'last_name' => '',
6ecbca5b 63 'prefix_id' => '',
64 'suffix_id' => '',
6a488035 65 'job_title' => '',
6ecbca5b 66 'gender_id' => '',
6a488035
TO
67 'birth_date' => '',
68 'is_deceased' => 0,
69 'deceased_date' => '',
70 'household_name' => '',
71 'organization_name' => '',
72 'sic_code' => '',
73 'contact_is_deleted' => 0,
6a488035 74 'current_employer' => '',
69d79249
E
75 'address_id' => '2',
76 'street_address' => '1 my road',
6a488035
TO
77 'supplemental_address_1' => '',
78 'supplemental_address_2' => '',
79 'city' => '',
80 'postal_code_suffix' => '',
81 'postal_code' => '',
82 'geo_code_1' => '',
83 'geo_code_2' => '',
84 'state_province_id' => '',
6a488035 85 'country_id' => '',
6a488035
TO
86 'phone_id' => '',
87 'phone_type_id' => '',
88 'phone' => '',
89 'email_id' => '1',
90 'email' => 'man2@yahoo.com',
91 'on_hold' => 0,
92 'im_id' => '',
93 'provider_id' => '',
94 'im' => '',
95 'worldregion_id' => '',
96 'world_region' => '',
6ecbca5b 97 'individual_prefix' => '',
98 'individual_suffix' => '',
99 'gender' => '',
9f1b81e0 100 'state_province_name' => '',
101 'state_province' => '',
102 'country' => '',
6a488035
TO
103 'id' => '1',
104 ),
105 ),
106);
107
fb32de45 108 return $expectedResult;
6a488035
TO
109}
110
111
112/*
113* This example has been generated from the API test suite. The test that created it is called
114*
115* testGetGroupIDFromContact and can be found in
69d79249 116* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
117*
118* You can see the outcome of the API tests at
69d79249 119* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
120*
121* To Learn about the API read
69d79249 122* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 123*
69d79249
E
124* Browse the api on your own site with the api explorer
125* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
126*
127* Read more about testing here
128* http://wiki.civicrm.org/confluence/display/CRM/Testing
129*
130* API Standards documentation:
131* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 132*/