Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /* | |
4 | /*this demonstrates the usage of chained api functions. A variety of return formats are used. Note that no notes | |
5 | *custom fields or memberships exist | |
6 | */ | |
7 | function contact_get_example(){ | |
edb0d67a | 8 | $params = array( |
6a488035 TO |
9 | 'id' => 1, |
10 | 'version' => 3, | |
edb0d67a | 11 | 'api.website.getValue' => array( |
6a488035 TO |
12 | 'return' => 'url', |
13 | ), | |
14 | 'api.Contribution.getCount' => array(), | |
15 | 'api.CustomValue.get' => 1, | |
16 | 'api.Note.get' => 1, | |
17 | 'api.Membership.getCount' => array(), | |
18 | ); | |
19 | ||
20 | $result = civicrm_api( 'contact','get',$params ); | |
21 | ||
22 | return $result; | |
23 | } | |
24 | ||
25 | /* | |
26 | * Function returns array of result expected from previous function | |
27 | */ | |
28 | function 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' => 'xyz3, abc3', | |
41 | 'display_name' => 'abc3 xyz3', | |
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' => 'abc3', | |
55 | 'middle_name' => '', | |
56 | 'last_name' => 'xyz3', | |
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' => '', | |
76 | 'state_province_name' => '', | |
77 | 'state_province' => '', | |
78 | 'country_id' => '', | |
79 | 'country' => '', | |
80 | 'phone_id' => '', | |
81 | 'phone_type_id' => '', | |
82 | 'phone' => '', | |
83 | 'email_id' => '1', | |
84 | 'email' => 'man3@yahoo.com', | |
85 | 'on_hold' => 0, | |
86 | 'im_id' => '', | |
87 | 'provider_id' => '', | |
88 | 'im' => '', | |
89 | 'worldregion_id' => '', | |
90 | 'world_region' => '', | |
91 | 'id' => '1', | |
92 | 'api.website.getValue' => 'http://civicrm.org', | |
93 | 'api.Contribution.getCount' => 2, | |
edb0d67a | 94 | 'api.CustomValue.get' => array( |
6a488035 TO |
95 | 'is_error' => 0, |
96 | 'version' => 3, | |
97 | 'count' => 0, | |
98 | 'values' => array(), | |
99 | ), | |
edb0d67a | 100 | 'api.Note.get' => array( |
6a488035 TO |
101 | 'is_error' => 0, |
102 | 'version' => 3, | |
103 | 'count' => 0, | |
104 | 'values' => array(), | |
105 | ), | |
106 | 'api.Membership.getCount' => 0, | |
107 | ), | |
108 | ), | |
109 | ); | |
110 | ||
111 | return $expectedResult ; | |
112 | } | |
113 | ||
114 | ||
115 | /* | |
116 | * This example has been generated from the API test suite. The test that created it is called | |
117 | * | |
118 | * testGetIndividualWithChainedArraysFormats and can be found in | |
119 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php | |
120 | * | |
121 | * You can see the outcome of the API tests at | |
122 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
123 | * | |
124 | * To Learn about the API read | |
125 | * http://book.civicrm.org/developer/current/techniques/api/ | |
126 | * | |
127 | * and review the wiki at | |
128 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
129 | * | |
130 | * Read more about testing here | |
131 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
132 | * | |
133 | * API Standards documentation: | |
134 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
135 | */ |