Merge pull request #1782 from deepak-srivastava/upgrade
[civicrm-core.git] / api / v3 / examples / TagGetfields.php
1 <?php
2 /**
3 * Test Generated example of using tag getfields API
4 * demonstrate use of getfields to interogate api *
5 */
6 function tag_getfields_example(){
7 $params = array(
8 'action' => 'create',
9 );
10
11 try{
12 $result = civicrm_api3('tag', 'getfields', $params);
13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20 }
21
22 return $result;
23 }
24
25 /**
26 * Function returns array of result expected from previous function
27 */
28 function tag_getfields_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 10,
34 'values' => array(
35 'id' => array(
36 'name' => 'id',
37 'type' => 1,
38 'required' => true,
39 'api.aliases' => array(
40 '0' => 'tag',
41 ),
42 ),
43 'name' => array(
44 'name' => 'name',
45 'type' => 2,
46 'title' => 'Name',
47 'required' => true,
48 'maxlength' => 64,
49 'size' => 30,
50 'api.required' => 1,
51 ),
52 'description' => array(
53 'name' => 'description',
54 'type' => 2,
55 'title' => 'Description',
56 'maxlength' => 255,
57 'size' => 45,
58 ),
59 'parent_id' => array(
60 'name' => 'parent_id',
61 'type' => 1,
62 'default' => 'UL',
63 'FKClassName' => 'CRM_Core_DAO_Tag',
64 ),
65 'is_selectable' => array(
66 'name' => 'is_selectable',
67 'type' => 16,
68 ),
69 'is_reserved' => array(
70 'name' => 'is_reserved',
71 'type' => 16,
72 ),
73 'is_tagset' => array(
74 'name' => 'is_tagset',
75 'type' => 16,
76 ),
77 'used_for' => array(
78 'name' => 'used_for',
79 'type' => 2,
80 'title' => 'Used For',
81 'maxlength' => 64,
82 'size' => 30,
83 'default' => 'UL',
84 'api.default' => 'civicrm_contact',
85 ),
86 'created_id' => array(
87 'name' => 'created_id',
88 'type' => 1,
89 'FKClassName' => 'CRM_Contact_DAO_Contact',
90 ),
91 'created_date' => array(
92 'name' => 'created_date',
93 'type' => 12,
94 'title' => 'Tag Created Date',
95 ),
96 ),
97 );
98
99 return $expectedResult;
100 }
101
102
103 /*
104 * This example has been generated from the API test suite. The test that created it is called
105 *
106 * testTagGetfields and can be found in
107 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/TagTest.php
108 *
109 * You can see the outcome of the API tests at
110 * http://tests.dev.civicrm.org/trunk/results-api_v3
111 *
112 * To Learn about the API read
113 * http://book.civicrm.org/developer/current/techniques/api/
114 *
115 * and review the wiki at
116 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
117 *
118 * Read more about testing here
119 * http://wiki.civicrm.org/confluence/display/CRM/Testing
120 *
121 * API Standards documentation:
122 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
123 */