Merge pull request #4737 from eileenmcnaughton/master
[civicrm-core.git] / api / v3 / examples / LocBlock / getEntities.php
1 <?php
2 /**
3 * Test Generated example of using loc_block get API
4 * Get entities and location block in 1 api call *
5 */
6 function loc_block_get_example(){
7 $params = array(
8 'id' => 3,
9 'return' => 'all',
10 );
11
12 try{
13 $result = civicrm_api3('loc_block', '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 loc_block_get_expectedresult(){
30
31 $expectedResult = array(
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 1,
35 'id' => 3,
36 'values' => array(
37 '3' => array(
38 'id' => '3',
39 'address_id' => '3',
40 'email_id' => '33',
41 'phone_id' => '3',
42 'phone_2_id' => '4',
43 'address' => array(
44 'id' => '3',
45 'location_type_id' => '1',
46 'is_primary' => 0,
47 'is_billing' => 0,
48 'street_address' => '987654321',
49 'manual_geo_code' => 0,
50 ),
51 'email' => array(
52 'id' => '33',
53 'location_type_id' => '1',
54 'email' => 'test2@loc.block',
55 'is_primary' => 0,
56 'is_billing' => 0,
57 'on_hold' => 0,
58 'is_bulkmail' => 0,
59 ),
60 'phone' => array(
61 'id' => '3',
62 'location_type_id' => '1',
63 'is_primary' => 0,
64 'is_billing' => 0,
65 'phone' => '987654321',
66 'phone_numeric' => '987654321',
67 ),
68 'phone_2' => array(
69 'id' => '4',
70 'location_type_id' => '1',
71 'is_primary' => 0,
72 'is_billing' => 0,
73 'phone' => '456-7890',
74 'phone_numeric' => '4567890',
75 ),
76 ),
77 ),
78 );
79
80 return $expectedResult;
81 }
82
83
84 /*
85 * This example has been generated from the API test suite. The test that created it is called
86 *
87 * testCreateLocBlockEntities and can be found in
88 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LocBlockTest.php
89 *
90 * You can see the outcome of the API tests at
91 * https://test.civicrm.org/job/CiviCRM-master-git/
92 *
93 * To Learn about the API read
94 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
95 *
96 * Browse the api on your own site with the api explorer
97 * http://MYSITE.ORG/path/to/civicrm/api/explorer
98 *
99 * Read more about testing here
100 * http://wiki.civicrm.org/confluence/display/CRM/Testing
101 *
102 * API Standards documentation:
103 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
104 */