updated examples
[civicrm-core.git] / api / v3 / examples / AddressGet.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using address get API
4 * *
6a488035
TO
5 */
6function address_get_example(){
edb0d67a 7$params = array(
6a488035
TO
8 'contact_id' => 9,
9 'street_name' => 'Ambachtstraat',
6a488035
TO
10);
11
fb32de45 12try{
13 $result = civicrm_api3('address', 'get', $params);
14}
15catch (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}
6a488035 22
fb32de45 23return $result;
6a488035
TO
24}
25
fb32de45 26/**
6a488035
TO
27 * Function returns array of result expected from previous function
28 */
29function address_get_expectedresult(){
30
edb0d67a 31 $expectedResult = array(
6a488035
TO
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 1,
35 'id' => 7,
edb0d67a 36 'values' => array(
37 '7' => array(
6a488035
TO
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
fb32de45 54 return $expectedResult;
6a488035
TO
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* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/AddressTest.php
63*
64* You can see the outcome of the API tests at
65* http://tests.dev.civicrm.org/trunk/results-api_v3
66*
67* To Learn about the API read
68* http://book.civicrm.org/developer/current/techniques/api/
69*
70* and review the wiki at
71* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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
b259a4ab 78*/