updated examples
[civicrm-core.git] / api / v3 / examples / LocBlockGet.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using loc_block get API
4 * Get entities and location block in 1 api call *
6a488035
TO
5 */
6function loc_block_get_example(){
82adafa2 7$params = array(
6a488035
TO
8 'id' => 3,
9 'return' => 'all',
10);
11
fb32de45 12try{
13 $result = civicrm_api3('loc_block', '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 loc_block_get_expectedresult(){
30
82adafa2 31 $expectedResult = array(
6a488035
TO
32 'id' => '3',
33 'address_id' => '3',
34 'email_id' => '4',
35 'phone_id' => '3',
36 'phone_2_id' => '4',
82adafa2 37 'address' => array(
6a488035
TO
38 'id' => '3',
39 'location_type_id' => '1',
40 'is_primary' => 0,
41 'is_billing' => 0,
42 'street_address' => '987654321',
43 'manual_geo_code' => 0,
44 ),
82adafa2 45 'email' => array(
6a488035
TO
46 'id' => '4',
47 'location_type_id' => '1',
48 'email' => 'test2@loc.block',
49 'is_primary' => 0,
50 'is_billing' => 0,
51 'on_hold' => 0,
52 'is_bulkmail' => 0,
53 ),
82adafa2 54 'phone' => array(
6a488035
TO
55 'id' => '3',
56 'location_type_id' => '1',
57 'is_primary' => 0,
58 'is_billing' => 0,
59 'phone' => '987654321',
60 'phone_numeric' => '987654321',
61 ),
82adafa2 62 'phone_2' => array(
6a488035
TO
63 'id' => '4',
64 'location_type_id' => '1',
65 'is_primary' => 0,
66 'is_billing' => 0,
67 'phone' => '456-7890',
68 'phone_numeric' => '4567890',
69 ),
70);
71
fb32de45 72 return $expectedResult;
6a488035
TO
73}
74
75
76/*
77* This example has been generated from the API test suite. The test that created it is called
78*
79* testCreateLocBlockEntities and can be found in
80* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/LocBlockTest.php
81*
82* You can see the outcome of the API tests at
83* http://tests.dev.civicrm.org/trunk/results-api_v3
84*
85* To Learn about the API read
86* http://book.civicrm.org/developer/current/techniques/api/
87*
88* and review the wiki at
89* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
90*
91* Read more about testing here
92* http://wiki.civicrm.org/confluence/display/CRM/Testing
93*
94* API Standards documentation:
95* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 96*/