Merge branch 'rcsheets-docstring-cleanup'
[civicrm-core.git] / api / v3 / examples / Address / AddressSort.php
1 <?php
2 /**
3 * Test Generated example of using address get API
4 * Demonstrates Use of sort filter *
5 */
6 function address_get_example(){
7 $params = array(
8 'options' => array(
9 'sort' => 'street_address DESC',
10 'limit' => 2,
11 ),
12 'sequential' => 1,
13 );
14
15 try{
16 $result = civicrm_api3('address', 'get', $params);
17 }
18 catch (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 }
25
26 return $result;
27 }
28
29 /**
30 * Function returns array of result expected from previous function
31 */
32 function address_get_expectedresult(){
33
34 $expectedResult = array(
35 'is_error' => 0,
36 'version' => 3,
37 'count' => 2,
38 'values' => array(
39 '0' => array(
40 'id' => '9',
41 'contact_id' => '11',
42 'location_type_id' => '14',
43 'is_primary' => '1',
44 'is_billing' => 0,
45 'street_address' => 'Ambachtstraat 23',
46 'street_number' => '23',
47 'street_name' => 'Ambachtstraat',
48 'city' => 'Brummen',
49 'postal_code' => '6971 BN',
50 'country_id' => '1152',
51 'manual_geo_code' => 0,
52 ),
53 '1' => array(
54 'id' => '1',
55 'contact_id' => '2',
56 'location_type_id' => '1',
57 'is_primary' => '1',
58 'is_billing' => '1',
59 'street_address' => '15 Main St',
60 'street_number' => '15',
61 'street_number_suffix' => 'S',
62 'street_name' => 'Main',
63 'street_type' => 'St',
64 'city' => 'Collinsville',
65 'state_province_id' => '1006',
66 'postal_code' => '6022',
67 'country_id' => '1228',
68 'geo_code_1' => '41.8328',
69 'geo_code_2' => '-72.9253',
70 'manual_geo_code' => 0,
71 ),
72 ),
73 );
74
75 return $expectedResult;
76 }
77
78
79 /*
80 * This example has been generated from the API test suite. The test that created it is called
81 *
82 * testGetAddressSort and can be found in
83 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
84 *
85 * You can see the outcome of the API tests at
86 * https://test.civicrm.org/job/CiviCRM-master-git/
87 *
88 * To Learn about the API read
89 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
90 *
91 * Browse the api on your own site with the api explorer
92 * http://MYSITE.ORG/path/to/civicrm/api/explorer
93 *
94 * Read more about testing here
95 * http://wiki.civicrm.org/confluence/display/CRM/Testing
96 *
97 * API Standards documentation:
98 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
99 */