Merge pull request #1046 from colemanw/showHide
[civicrm-core.git] / api / v3 / examples / LocBlockCreateEntities.php
1 <?php
2
3 /*
4 Create entities and location block in 1 api call
5 */
6 function loc_block_createentities_example(){
7 $params = array(
8 'email' => array(
9 'location_type_id' => 1,
10 'email' => 'test2@loc.block',
11 ),
12 'phone' => array(
13 'location_type_id' => 1,
14 'phone' => '987654321',
15 ),
16 'phone_2' => array(
17 'location_type_id' => 1,
18 'phone' => '456-7890',
19 ),
20 'address' => array(
21 'location_type_id' => 1,
22 'street_address' => '987654321',
23 ),
24 'version' => 3,
25 'debug' => 0,
26 );
27
28 $result = civicrm_api( 'loc_block','createEntities',$params );
29
30 return $result;
31 }
32
33 /*
34 * Function returns array of result expected from previous function
35 */
36 function loc_block_createentities_expectedresult(){
37
38 $expectedResult = array(
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 3,
43 'values' => array(
44 '3' => array(
45 'address' => array(
46 'id' => '3',
47 'location_type_id' => '1',
48 'is_primary' => 0,
49 'is_billing' => 0,
50 'street_address' => '987654321',
51 'manual_geo_code' => 0,
52 ),
53 'email' => array(
54 'id' => '4',
55 'contact_id' => 'null',
56 'location_type_id' => '1',
57 'email' => 'test2@loc.block',
58 'is_primary' => 0,
59 'is_billing' => '',
60 'on_hold' => '',
61 'is_bulkmail' => '',
62 'hold_date' => '',
63 'reset_date' => '',
64 'signature_text' => '',
65 'signature_html' => '',
66 ),
67 'phone' => array(
68 'id' => '3',
69 'contact_id' => 'null',
70 'location_type_id' => '1',
71 'is_primary' => 0,
72 'is_billing' => '',
73 'mobile_provider_id' => '',
74 'phone' => '987654321',
75 'phone_ext' => '',
76 'phone_numeric' => '',
77 'phone_type_id' => '',
78 ),
79 'phone_2' => array(
80 'id' => '4',
81 'contact_id' => 'null',
82 'location_type_id' => '1',
83 'is_primary' => 0,
84 'is_billing' => '',
85 'mobile_provider_id' => '',
86 'phone' => '456-7890',
87 'phone_ext' => '',
88 'phone_numeric' => '',
89 'phone_type_id' => '',
90 ),
91 'id' => '3',
92 'address_id' => '3',
93 'email_id' => '4',
94 'phone_id' => '3',
95 'im_id' => '',
96 'address_2_id' => '',
97 'email_2_id' => '',
98 'phone_2_id' => '4',
99 'im_2_id' => '',
100 ),
101 ),
102 );
103
104 return $expectedResult ;
105 }
106
107
108 /*
109 * This example has been generated from the API test suite. The test that created it is called
110 *
111 * testCreateLocBlockEntities and can be found in
112 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/LocBlockTest.php
113 *
114 * You can see the outcome of the API tests at
115 * http://tests.dev.civicrm.org/trunk/results-api_v3
116 *
117 * To Learn about the API read
118 * http://book.civicrm.org/developer/current/techniques/api/
119 *
120 * and review the wiki at
121 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
122 *
123 * Read more about testing here
124 * http://wiki.civicrm.org/confluence/display/CRM/Testing
125 *
126 * API Standards documentation:
127 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
128 */