Merge pull request #12185 from eileenmcnaughton/entity_form_url_defaults
[civicrm-core.git] / api / v3 / examples / Address / AddressLike.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Address.get API.
50fb255d 4 *
5c49fee0 5 * Demonstrates Use of Like.
50fb255d 6 *
7 * @return array
8 * API result array
9 */
10function address_get_example() {
11 $params = array(
12 'street_address' => array(
6a488035
TO
13 'LIKE' => '%mb%',
14 ),
50fb255d 15 'sequential' => 1,
16 );
6a488035 17
50fb255d 18 try{
a828d7b8 19 $result = civicrm_api3('Address', 'get', $params);
50fb255d 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(
5be22f39 27 'is_error' => 1,
28 'error_message' => $errorMessage,
50fb255d 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 address_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 '0' => array(
50fb255d 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 ),
6a488035 65 ),
50fb255d 66 );
6a488035 67
fb32de45 68 return $expectedResult;
6a488035
TO
69}
70
a828d7b8 71/*
50fb255d 72* This example has been generated from the API test suite.
a828d7b8
CW
73* The test that created it is called "testGetAddressLikeSuccess"
74* and can be found at:
69d79249 75* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/AddressTest.php
6a488035
TO
76*
77* You can see the outcome of the API tests at
69d79249 78* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
79*
80* To Learn about the API read
69d79249 81* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 82*
69d79249 83* Browse the api on your own site with the api explorer
41d4d31f 84* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
b259a4ab 91*/