Merge pull request #2749 from monishdeb/HR-317
[civicrm-core.git] / api / v3 / examples / LocBlock / getEntities.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
69f028bc
CW
3 * Test Generated example of using loc_block get API
4 * Get entities and location block in 1 api call *
6a488035 5 */
69f028bc 6function loc_block_get_example(){
82adafa2 7$params = array(
69f028bc
CW
8 'id' => 3,
9 'return' => 'all',
6a488035
TO
10);
11
fb32de45 12try{
69f028bc 13 $result = civicrm_api3('loc_block', 'get', $params);
fb32de45 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 */
69f028bc 29function loc_block_get_expectedresult(){
6a488035 30
82adafa2 31 $expectedResult = array(
6a488035
TO
32 'is_error' => 0,
33 'version' => 3,
34 'count' => 1,
35 'id' => 3,
82adafa2 36 'values' => array(
37 '3' => array(
69f028bc
CW
38 'id' => '3',
39 'address_id' => '3',
40 'email_id' => '4',
41 'phone_id' => '3',
42 'phone_2_id' => '4',
82adafa2 43 'address' => array(
6a488035
TO
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 ),
82adafa2 51 'email' => array(
6a488035 52 'id' => '4',
6a488035
TO
53 'location_type_id' => '1',
54 'email' => 'test2@loc.block',
55 'is_primary' => 0,
69f028bc
CW
56 'is_billing' => 0,
57 'on_hold' => 0,
58 'is_bulkmail' => 0,
6a488035 59 ),
82adafa2 60 'phone' => array(
6a488035 61 'id' => '3',
6a488035
TO
62 'location_type_id' => '1',
63 'is_primary' => 0,
69f028bc 64 'is_billing' => 0,
6a488035 65 'phone' => '987654321',
69f028bc 66 'phone_numeric' => '987654321',
6a488035 67 ),
82adafa2 68 'phone_2' => array(
6a488035 69 'id' => '4',
6a488035
TO
70 'location_type_id' => '1',
71 'is_primary' => 0,
69f028bc 72 'is_billing' => 0,
6a488035 73 'phone' => '456-7890',
69f028bc 74 'phone_numeric' => '4567890',
6a488035 75 ),
6a488035
TO
76 ),
77 ),
78);
79
fb32de45 80 return $expectedResult;
6a488035
TO
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* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/LocBlockTest.php
89*
90* You can see the outcome of the API tests at
91* http://tests.dev.civicrm.org/trunk/results-api_v3
92*
93* To Learn about the API read
94* http://book.civicrm.org/developer/current/techniques/api/
95*
96* and review the wiki at
97* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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
b259a4ab 104*/