Merge pull request #5086 from deepak-srivastava/CRM-15490
[civicrm-core.git] / api / v3 / examples / Activity / ContactRefCustomFieldGet.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
6a488035 7
50fb255d 8/**
9 * Test Generated example of using activity get API.
10 *
11 * Get with Contact Ref Custom Field
12 *
13 * @return array
14 * API result array
15 */
16function activity_get_example() {
17 $params = array(
18 'return.custom_2' => 1,
19 'id' => 1,
20 );
6a488035 21
50fb255d 22 try{
23 $result = civicrm_api3('activity', 'get', $params);
24 }
25 catch (CiviCRM_API3_Exception $e) {
26 // Handle error here.
27 $errorMessage = $e->getMessage();
28 $errorCode = $e->getErrorCode();
29 $errorData = $e->getExtraParams();
30 return array(
31 'error' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
6a488035
TO
38}
39
fb32de45 40/**
50fb255d 41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
6a488035 45 */
50fb255d 46function activity_get_expectedresult() {
6a488035 47
feb2a730 48 $expectedResult = array(
50fb255d 49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 1,
53 'values' => array(
feb2a730 54 '1' => array(
50fb255d 55 'id' => '1',
56 'activity_type_id' => '51',
57 'subject' => 'test activity type id',
58 'activity_date_time' => '2011-06-02 14:36:13',
59 'duration' => '120',
e3aa0dd1 60 'location' => 'Pennsylvania',
50fb255d 61 'details' => 'a test activity',
62 'status_id' => '2',
63 'priority_id' => '1',
64 'is_test' => 0,
65 'is_auto' => 0,
66 'is_current_revision' => '1',
67 'is_deleted' => 0,
68 'source_contact_id' => '1',
69 'custom_1' => 'defaultValue',
70 'custom_1_1' => 'defaultValue',
71 'custom_2' => 'Anderson, Anthony',
72 'custom_2_1' => 'Anderson, Anthony',
73 'custom_2_1_id' => '1',
74 'custom_2_id' => '1',
75 ),
6a488035 76 ),
50fb255d 77 );
6a488035 78
fb32de45 79 return $expectedResult;
6a488035
TO
80}
81
50fb255d 82/**
83* This example has been generated from the API test suite.
84* The test that created it is called
85* testActivityCreateCustomContactRefField
86* and can be found in
69d79249 87* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
6a488035
TO
88*
89* You can see the outcome of the API tests at
69d79249 90* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
91*
92* To Learn about the API read
69d79249 93* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 94*
69d79249
E
95* Browse the api on your own site with the api explorer
96* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
97*
98* Read more about testing here
99* http://wiki.civicrm.org/confluence/display/CRM/Testing
100*
101* API Standards documentation:
102* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 103*/