| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example demonstrating the Activity.get API. |
| 4 | * |
| 5 | * Get with Contact Ref Custom Field |
| 6 | * |
| 7 | * @return array |
| 8 | * API result array |
| 9 | */ |
| 10 | function activity_get_example() { |
| 11 | $params = array( |
| 12 | 'return.custom_2' => 1, |
| 13 | 'id' => 1, |
| 14 | ); |
| 15 | |
| 16 | try{ |
| 17 | $result = civicrm_api3('Activity', '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 | */ |
| 40 | function activity_get_expectedresult() { |
| 41 | |
| 42 | $expectedResult = array( |
| 43 | 'is_error' => 0, |
| 44 | 'version' => 3, |
| 45 | 'count' => 1, |
| 46 | 'id' => 1, |
| 47 | 'values' => array( |
| 48 | '1' => array( |
| 49 | 'id' => '1', |
| 50 | 'activity_type_id' => '51', |
| 51 | 'subject' => 'test activity type id', |
| 52 | 'activity_date_time' => '2011-06-02 14:36:13', |
| 53 | 'duration' => '120', |
| 54 | 'location' => 'Pennsylvania', |
| 55 | 'details' => 'a test activity', |
| 56 | 'status_id' => '2', |
| 57 | 'priority_id' => '1', |
| 58 | 'is_test' => 0, |
| 59 | 'is_auto' => 0, |
| 60 | 'is_current_revision' => '1', |
| 61 | 'is_deleted' => 0, |
| 62 | 'source_contact_id' => '1', |
| 63 | 'custom_1' => 'defaultValue', |
| 64 | 'custom_1_1' => 'defaultValue', |
| 65 | 'custom_2' => 'Anderson, Anthony', |
| 66 | 'custom_2_1' => 'Anderson, Anthony', |
| 67 | 'custom_2_1_id' => '1', |
| 68 | 'custom_2_id' => '1', |
| 69 | ), |
| 70 | ), |
| 71 | ); |
| 72 | |
| 73 | return $expectedResult; |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * This example has been generated from the API test suite. |
| 78 | * The test that created it is called "testActivityCreateCustomContactRefField" |
| 79 | * and can be found at: |
| 80 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.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 |
| 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 | */ |