Remove boilerplate from the top of api example files
[civicrm-core.git] / api / v3 / examples / Participant / Create.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
3 * Test Generated example of using participant create API.
4 *
5 *
6 * @return array
7 * API result array
8 */
9function participant_create_example() {
10 $params = array(
11 'contact_id' => 4,
12 'event_id' => 1,
13 'status_id' => 1,
14 'role_id' => 1,
15 'register_date' => '2007-07-21 00:00:00',
16 'source' => 'Online Event Registration: API Testing',
17 'custom_1' => 'custom string',
18 );
6a488035 19
50fb255d 20 try{
21 $result = civicrm_api3('participant', 'create', $params);
22 }
23 catch (CiviCRM_API3_Exception $e) {
24 // Handle error here.
25 $errorMessage = $e->getMessage();
26 $errorCode = $e->getErrorCode();
27 $errorData = $e->getExtraParams();
28 return array(
29 'error' => $errorMessage,
30 'error_code' => $errorCode,
31 'error_data' => $errorData,
32 );
33 }
34
35 return $result;
6a488035
TO
36}
37
fb32de45 38/**
50fb255d 39 * Function returns array of result expected from previous function.
40 *
41 * @return array
42 * API result array
6a488035 43 */
50fb255d 44function participant_create_expectedresult() {
6a488035 45
53ca8fd7 46 $expectedResult = array(
50fb255d 47 'is_error' => 0,
48 'version' => 3,
49 'count' => 1,
50 'id' => 4,
51 'values' => array(
53ca8fd7 52 '4' => array(
50fb255d 53 'id' => '4',
54 'contact_id' => '4',
55 'event_id' => '1',
56 'status_id' => '1',
57 'role_id' => '1',
58 'register_date' => '20070721000000',
59 'source' => 'Online Event Registration: API Testing',
60 'fee_level' => '',
61 'is_test' => '',
62 'is_pay_later' => '',
63 'fee_amount' => '',
64 'registered_by_id' => '',
65 'discount_id' => '',
66 'fee_currency' => '',
67 'campaign_id' => '',
68 'discount_amount' => '',
69 'cart_id' => '',
70 'must_wait' => '',
71 ),
6a488035 72 ),
50fb255d 73 );
6a488035 74
fb32de45 75 return $expectedResult;
6a488035
TO
76}
77
50fb255d 78/**
79* This example has been generated from the API test suite.
80* The test that created it is called
81* testCreateWithCustom
82* and can be found in
69d79249 83* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php
6a488035
TO
84*
85* You can see the outcome of the API tests at
69d79249 86* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
87*
88* To Learn about the API read
69d79249 89* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 90*
69d79249
E
91* Browse the api on your own site with the api explorer
92* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
93*
94* Read more about testing here
95* http://wiki.civicrm.org/confluence/display/CRM/Testing
96*
97* API Standards documentation:
98* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 99*/