CRM-15988 - Update generated examples
[civicrm-core.git] / api / v3 / examples / Contact / GroupFilterUsingContactAPI.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Contact.get API.
50fb255d 4 *
5c49fee0 5 * Get all from group and display contacts.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function contact_get_example() {
11 $params = array(
12 'filter.group_id' => array(
6a488035
TO
13 '0' => 1,
14 '1' => 26,
15 ),
50fb255d 16 'contact_type' => 'Individual',
17 );
6a488035 18
50fb255d 19 try{
a828d7b8 20 $result = civicrm_api3('Contact', 'get', $params);
50fb255d 21 }
22 catch (CiviCRM_API3_Exception $e) {
23 // Handle error here.
24 $errorMessage = $e->getMessage();
25 $errorCode = $e->getErrorCode();
26 $errorData = $e->getExtraParams();
27 return array(
28 'error' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
6a488035 33
50fb255d 34 return $result;
6a488035
TO
35}
36
fb32de45 37/**
50fb255d 38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
6a488035 42 */
50fb255d 43function contact_get_expectedresult() {
6a488035 44
edb0d67a 45 $expectedResult = array(
50fb255d 46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
49 'id' => 1,
50 'values' => array(
edb0d67a 51 '1' => array(
50fb255d 52 'contact_id' => '1',
53 'contact_type' => 'Individual',
54 'contact_sub_type' => '',
55 'sort_name' => 'man2@yahoo.com',
56 'display_name' => 'man2@yahoo.com',
57 'do_not_email' => 0,
58 'do_not_phone' => 0,
59 'do_not_mail' => 0,
60 'do_not_sms' => 0,
61 'do_not_trade' => 0,
62 'is_opt_out' => 0,
63 'legal_identifier' => '',
64 'external_identifier' => '',
65 'nick_name' => '',
66 'legal_name' => '',
67 'image_URL' => '',
68 'preferred_communication_method' => '',
69 'preferred_language' => 'en_US',
70 'preferred_mail_format' => 'Both',
71 'first_name' => '',
72 'middle_name' => '',
73 'last_name' => '',
74 'prefix_id' => '',
75 'suffix_id' => '',
76 'formal_title' => '',
77 'communication_style_id' => '',
78 'job_title' => '',
79 'gender_id' => '',
80 'birth_date' => '',
81 'is_deceased' => 0,
82 'deceased_date' => '',
83 'household_name' => '',
84 'organization_name' => '',
85 'sic_code' => '',
86 'contact_is_deleted' => 0,
87 'current_employer' => '',
88 'address_id' => '2',
89 'street_address' => '1 my road',
90 'supplemental_address_1' => '',
91 'supplemental_address_2' => '',
92 'city' => '',
93 'postal_code_suffix' => '',
94 'postal_code' => '',
95 'geo_code_1' => '',
96 'geo_code_2' => '',
97 'state_province_id' => '',
98 'country_id' => '',
99 'phone_id' => '',
100 'phone_type_id' => '',
101 'phone' => '',
102 'email_id' => '1',
103 'email' => 'man2@yahoo.com',
104 'on_hold' => 0,
105 'im_id' => '',
106 'provider_id' => '',
107 'im' => '',
108 'worldregion_id' => '',
109 'world_region' => '',
110 'individual_prefix' => '',
111 'individual_suffix' => '',
112 'communication_style' => '',
113 'gender' => '',
114 'state_province_name' => '',
115 'state_province' => '',
116 'country' => '',
117 'id' => '1',
118 ),
6a488035 119 ),
50fb255d 120 );
6a488035 121
fb32de45 122 return $expectedResult;
6a488035
TO
123}
124
a828d7b8 125/*
50fb255d 126* This example has been generated from the API test suite.
a828d7b8
CW
127* The test that created it is called "testGetGroupIDFromContact"
128* and can be found at:
69d79249 129* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
130*
131* You can see the outcome of the API tests at
69d79249 132* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
133*
134* To Learn about the API read
69d79249 135* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 136*
69d79249 137* Browse the api on your own site with the api explorer
41d4d31f 138* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
139*
140* Read more about testing here
141* http://wiki.civicrm.org/confluence/display/CRM/Testing
142*
143* API Standards documentation:
144* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 145*/