updated examples
[civicrm-core.git] / api / v3 / examples / ActivityTypeCreate.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using activity_type create API
4 * *
6a488035
TO
5 */
6function activity_type_create_example(){
edb0d67a 7$params = array(
6a488035
TO
8 'weight' => '2',
9 'label' => 'send out letters',
6a488035
TO
10 'filter' => 0,
11 'is_active' => 1,
12 'is_optgroup' => 1,
13 'is_default' => 0,
14);
15
fb32de45 16try{
17 $result = civicrm_api3('activity_type', 'create', $params);
18}
19catch (CiviCRM_API3_Exception $e) {
20 // handle error here
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
25}
6a488035 26
fb32de45 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function activity_type_create_expectedresult(){
34
edb0d67a 35 $expectedResult = array(
6a488035
TO
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
b259a4ab 39 'id' => 727,
edb0d67a 40 'values' => array(
b259a4ab
EM
41 '727' => array(
42 'id' => '727',
6a488035
TO
43 'option_group_id' => '2',
44 'label' => 'send out letters',
edb0d67a 45 'value' => '46',
6a488035
TO
46 'name' => 'send out letters',
47 'grouping' => '',
48 'filter' => 0,
49 'is_default' => 0,
50 'weight' => '2',
51 'description' => '',
52 'is_optgroup' => '1',
53 'is_reserved' => '',
54 'is_active' => '1',
55 'component_id' => '',
56 'domain_id' => '',
57 'visibility_id' => '',
58 ),
59 ),
60);
61
fb32de45 62 return $expectedResult;
6a488035
TO
63}
64
65
66/*
67* This example has been generated from the API test suite. The test that created it is called
68*
69* testActivityTypeCreate and can be found in
70* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTypeTest.php
71*
72* You can see the outcome of the API tests at
73* http://tests.dev.civicrm.org/trunk/results-api_v3
74*
75* To Learn about the API read
76* http://book.civicrm.org/developer/current/techniques/api/
77*
78* and review the wiki at
79* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
80*
81* Read more about testing here
82* http://wiki.civicrm.org/confluence/display/CRM/Testing
83*
84* API Standards documentation:
85* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 86*/