Merge pull request #11736 from jitendrapurohit/CRM-21815
[civicrm-core.git] / api / v3 / examples / Address / AddressLike.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Address.get API.
4 *
5 * Demonstrates Use of Like.
6 *
7 * @return array
8 * API result array
9 */
10 function address_get_example() {
11 $params = array(
12 'street_address' => array(
13 'LIKE' => '%mb%',
14 ),
15 'sequential' => 1,
16 );
17
18 try{
19 $result = civicrm_api3('Address', 'get', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'is_error' => 1,
28 'error_message' => $errorMessage,
29 'error_code' => $errorCode,
30 'error_data' => $errorData,
31 );
32 }
33
34 return $result;
35 }
36
37 /**
38 * Function returns array of result expected from previous function.
39 *
40 * @return array
41 * API result array
42 */
43 function address_get_expectedresult() {
44
45 $expectedResult = array(
46 'is_error' => 0,
47 'version' => 3,
48 'count' => 1,
49 'id' => 1,
50 'values' => array(
51 '0' => array(
52 'id' => '1',
53 'contact_id' => '20',
54 'location_type_id' => '18',
55 'is_primary' => '1',
56 'is_billing' => 0,
57 'street_address' => 'Ambachtstraat 23',
58 'street_number' => '23',
59 'street_name' => 'Ambachtstraat',
60 'city' => 'Brummen',
61 'postal_code' => '6971 BN',
62 'country_id' => '1152',
63 'manual_geo_code' => 0,
64 ),
65 ),
66 );
67
68 return $expectedResult;
69 }
70
71 /*
72 * This example has been generated from the API test suite.
73 * The test that created it is called "testGetAddressLikeSuccess"
74 * and can be found at:
75 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
76 *
77 * You can see the outcome of the API tests at
78 * https://test.civicrm.org/job/CiviCRM-master-git/
79 *
80 * To Learn about the API read
81 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
82 *
83 * Browse the api on your own site with the api explorer
84 * http://MYSITE.ORG/path/to/civicrm/api
85 *
86 * Read more about testing here
87 * http://wiki.civicrm.org/confluence/display/CRM/Testing
88 *
89 * API Standards documentation:
90 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
91 */