| 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 | 'id' => '3', |
| 33 | 'address_id' => '3', |
| 34 | 'email_id' => '4', |
| 35 | 'phone_id' => '3', |
| 36 | 'phone_2_id' => '4', |
| 37 | 'address' => array( |
| 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 | ), |
| 45 | 'email' => array( |
| 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 | ), |
| 54 | 'phone' => array( |
| 55 | 'id' => '3', |
| 56 | 'location_type_id' => '1', |
| 57 | 'is_primary' => 0, |
| 58 | 'is_billing' => 0, |
| 59 | 'phone' => '987654321', |
| 60 | 'phone_numeric' => '987654321', |
| 61 | ), |
| 62 | 'phone_2' => array( |
| 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 | |
| 72 | return $expectedResult; |
| 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 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/LocBlockTest.php |
| 81 | * |
| 82 | * You can see the outcome of the API tests at |
| 83 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
| 84 | * |
| 85 | * To Learn about the API read |
| 86 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
| 87 | * |
| 88 | * Browse the api on your own site with the api explorer |
| 89 | * http://MYSITE.ORG/path/to/civicrm/api/explorer |
| 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 |
| 96 | */ |