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