Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / LocBlock / Get.php
... / ...
CommitLineData
1<?php
2/**
3 * Test Generated example demonstrating the LocBlock.get API.
4 *
5 * Get entities and location block in 1 api call
6 *
7 * @return array
8 * API result array
9 */
10function loc_block_get_example() {
11 $params = array(
12 'id' => 3,
13 'return' => 'all',
14 );
15
16 try{
17 $result = civicrm_api3('LocBlock', 'get', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // Handle error here.
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array(
25 'error' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 );
29 }
30
31 return $result;
32}
33
34/**
35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
39 */
40function loc_block_get_expectedresult() {
41
42 $expectedResult = array(
43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 3,
47 'values' => array(
48 '3' => array(
49 'id' => '3',
50 'address_id' => '3',
51 'email_id' => '4',
52 'phone_id' => '3',
53 'phone_2_id' => '4',
54 'address' => array(
55 'id' => '3',
56 'location_type_id' => '1',
57 'is_primary' => 0,
58 'is_billing' => 0,
59 'street_address' => '987654321',
60 'manual_geo_code' => 0,
61 ),
62 'email' => array(
63 'id' => '4',
64 'location_type_id' => '1',
65 'email' => 'test2@loc.block',
66 'is_primary' => 0,
67 'is_billing' => 0,
68 'on_hold' => 0,
69 'is_bulkmail' => 0,
70 ),
71 'phone' => array(
72 'id' => '3',
73 'location_type_id' => '1',
74 'is_primary' => 0,
75 'is_billing' => 0,
76 'phone' => '987654321',
77 'phone_numeric' => '987654321',
78 ),
79 'phone_2' => array(
80 'id' => '4',
81 'location_type_id' => '1',
82 'is_primary' => 0,
83 'is_billing' => 0,
84 'phone' => '456-7890',
85 'phone_numeric' => '4567890',
86 ),
87 ),
88 ),
89 );
90
91 return $expectedResult;
92}
93
94/*
95* This example has been generated from the API test suite.
96* The test that created it is called "testCreateLocBlockEntities"
97* and can be found at:
98* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LocBlockTest.php
99*
100* You can see the outcome of the API tests at
101* https://test.civicrm.org/job/CiviCRM-master-git/
102*
103* To Learn about the API read
104* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
105*
106* Browse the api on your own site with the api explorer
107* http://MYSITE.ORG/path/to/civicrm/api
108*
109* Read more about testing here
110* http://wiki.civicrm.org/confluence/display/CRM/Testing
111*
112* API Standards documentation:
113* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
114*/