CRM-15988 - Update generated examples
[civicrm-core.git] / api / v3 / examples / LocBlock / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the LocBlock.get API.
50fb255d 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{
a828d7b8 17 $result = civicrm_api3('LocBlock', 'get', $params);
50fb255d 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 }
6a488035 30
50fb255d 31 return $result;
6a488035
TO
32}
33
fb32de45 34/**
50fb255d 35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
6a488035 39 */
50fb255d 40function loc_block_get_expectedresult() {
6a488035 41
82adafa2 42 $expectedResult = array(
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 3,
47 'values' => array(
82adafa2 48 '3' => array(
50fb255d 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(
69f028bc 72 'id' => '3',
50fb255d 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',
6a488035 86 ),
50fb255d 87 ),
6a488035 88 ),
50fb255d 89 );
6a488035 90
fb32de45 91 return $expectedResult;
6a488035
TO
92}
93
a828d7b8 94/*
50fb255d 95* This example has been generated from the API test suite.
a828d7b8
CW
96* The test that created it is called "testCreateLocBlockEntities"
97* and can be found at:
89bf81b4 98* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LocBlockTest.php
6a488035
TO
99*
100* You can see the outcome of the API tests at
89bf81b4 101* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
102*
103* To Learn about the API read
89bf81b4 104* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 105*
89bf81b4 106* Browse the api on your own site with the api explorer
41d4d31f 107* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
b259a4ab 114*/