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