Ian province abbreviation patch - issue 724
[civicrm-core.git] / api / v3 / examples / Activity / Create.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Activity.create API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function activity_create_example() {
9 $params = array(
10 'source_contact_id' => 1,
11 'activity_type_id' => '51',
12 'subject' => 'test activity type id',
13 'activity_date_time' => '2011-06-02 14:36:13',
14 'status_id' => 2,
15 'priority_id' => 1,
16 'duration' => 120,
e3aa0dd1 17 'location' => 'Pennsylvania',
50fb255d 18 'details' => 'a test activity',
19 'custom_1' => 'custom string',
20 );
6a488035 21
50fb255d 22 try{
a828d7b8 23 $result = civicrm_api3('Activity', 'create', $params);
50fb255d 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_create_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 'source_record_id' => '',
57 'activity_type_id' => '51',
58 'subject' => 'test activity type id',
59 'activity_date_time' => '20110602143613',
60 'duration' => '120',
e3aa0dd1 61 'location' => 'Pennsylvania',
50fb255d 62 'phone_id' => '',
63 'phone_number' => '',
64 'details' => 'a test activity',
65 'status_id' => '2',
66 'priority_id' => '1',
67 'parent_id' => '',
68 'is_test' => '',
69 'medium_id' => '',
70 'is_auto' => '',
71 'relationship_id' => '',
72 'is_current_revision' => '',
73 'original_id' => '',
74 'result' => '',
75 'is_deleted' => '',
76 'campaign_id' => '',
77 'engagement_level' => '',
78 'weight' => '',
79 ),
6a488035 80 ),
50fb255d 81 );
6a488035 82
fb32de45 83 return $expectedResult;
6a488035
TO
84}
85
a828d7b8 86/*
50fb255d 87* This example has been generated from the API test suite.
a828d7b8
CW
88* The test that created it is called "testActivityCreateCustom"
89* and can be found at:
69d79249 90* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
2f3d72cf 91*
92* You can see the outcome of the API tests at
69d79249 93* https://test.civicrm.org/job/CiviCRM-master-git/
2f3d72cf 94*
95* To Learn about the API read
69d79249 96* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
2f3d72cf 97*
69d79249 98* Browse the api on your own site with the api explorer
41d4d31f 99* http://MYSITE.ORG/path/to/civicrm/api
2f3d72cf 100*
6a488035
TO
101* Read more about testing here
102* http://wiki.civicrm.org/confluence/display/CRM/Testing
2f3d72cf 103*
104* API Standards documentation:
105* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 106*/