Import from SVN (r45945, r596)
[civicrm-core.git] / api / v3 / examples / ContactCreate.php
CommitLineData
6a488035
TO
1<?php
2// $Id$
3
4
5
6/*
7
8 */
9function contact_create_example() {
10 $params = array(
11 'first_name' => 'abc3',
12 'last_name' => 'xyz3',
13 'contact_type' => 'Individual',
14 'email' => 'man3@yahoo.com',
15 'version' => 3,
16 'api.contribution.create' => array(
17 'receive_date' => '2010-01-01',
18 'total_amount' => '100',
19 'financial_type_id' => 1,
20 'payment_instrument_id' => 1,
21 'non_deductible_amount' => '10',
22 'fee_amount' => '50',
23 'net_amount' => '90',
24 'trxn_id' => 12345,
25 'invoice_id' => 67890,
26 'source' => 'SSF',
27 'contribution_status_id' => 1,
28 ),
29 'api.website.create' => array(
30 '0' => array(
31 'url' => 'http://civicrm.org',
32 ),
33 '1' => array(
34 'url' => 'http://chained.org',
35 'website_type_id' => 2,
36 ),
37 ),
38 );
39
40 require_once 'api/api.php';
41 $result = civicrm_api('contact', 'create', $params);
42
43 return $result;
44}
45
46/*
47 * Function returns array of result expected from previous function
48 */
49function contact_create_expectedresult() {
50
51 $expectedResult = array(
52 'is_error' => 0,
53 'version' => 3,
54 'count' => 1,
55 'id' => 1,
56 'values' => array(
57 '1' => array(
58 'id' => 1,
59 'contact_type' => 'Individual',
60 'contact_sub_type' => 'null',
61 'do_not_email' => '',
62 'do_not_phone' => '',
63 'do_not_mail' => '',
64 'do_not_sms' => '',
65 'do_not_trade' => '',
66 'is_opt_out' => '',
67 'legal_identifier' => '',
68 'external_identifier' => '',
69 'sort_name' => 'xyz3, abc3',
70 'display_name' => 'abc3 xyz3',
71 'nick_name' => '',
72 'legal_name' => '',
73 'image_URL' => '',
74 'preferred_communication_method' => '',
75 'preferred_language' => 'en_US',
76 'preferred_mail_format' => '',
77 'api_key' => '',
78 'first_name' => 'abc3',
79 'middle_name' => '',
80 'last_name' => 'xyz3',
81 'prefix_id' => '',
82 'suffix_id' => '',
83 'email_greeting_id' => '',
84 'email_greeting_custom' => '',
85 'email_greeting_display' => '',
86 'postal_greeting_id' => '',
87 'postal_greeting_custom' => '',
88 'postal_greeting_display' => '',
89 'addressee_id' => '',
90 'addressee_custom' => '',
91 'addressee_display' => '',
92 'job_title' => '',
93 'gender_id' => '',
94 'birth_date' => '',
95 'is_deceased' => '',
96 'deceased_date' => '',
97 'household_name' => '',
98 'primary_contact_id' => '',
99 'organization_name' => '',
100 'sic_code' => '',
101 'user_unique_id' => '',
102 'api.contribution.create' => array(
103 'is_error' => 0,
104 'version' => 3,
105 'count' => 1,
106 'id' => 2,
107 'values' => array(
108 '0' => array(
109 'id' => 2,
110 'contact_id' => 1,
111 'financial_type_id' => 1,
112 'contribution_page_id' => '',
113 'payment_instrument_id' => 1,
114 'receive_date' => '20100101000000',
115 'non_deductible_amount' => '10',
116 'total_amount' => '100',
117 'fee_amount' => '50',
118 'net_amount' => '90',
119 'trxn_id' => 12345,
120 'invoice_id' => 67890,
121 'currency' => 'USD',
122 'cancel_date' => '',
123 'cancel_reason' => '',
124 'receipt_date' => '',
125 'thankyou_date' => '',
126 'source' => 'SSF',
127 'amount_level' => '',
128 'contribution_recur_id' => '',
129 'honor_contact_id' => '',
130 'is_test' => '',
131 'is_pay_later' => '',
132 'contribution_status_id' => 1,
133 'honor_type_id' => '',
134 'address_id' => '',
135 'check_number' => 'null',
136 'campaign_id' => '',
137 ),
138 ),
139 ),
140 'api.website.create' => array(
141 '0' => array(
142 'is_error' => 0,
143 'version' => 3,
144 'count' => 1,
145 'id' => 3,
146 'values' => array(
147 '0' => array(
148 'id' => 3,
149 'contact_id' => 1,
150 'url' => 'http://civicrm.org',
151 'website_type_id' => '',
152 ),
153 ),
154 ),
155 '1' => array(
156 'is_error' => 0,
157 'version' => 3,
158 'count' => 1,
159 'id' => 4,
160 'values' => array(
161 '0' => array(
162 'id' => 4,
163 'contact_id' => 1,
164 'url' => 'http://chained.org',
165 'website_type_id' => 2,
166 ),
167 ),
168 ),
169 ),
170 ),
171 ),
172 );
173
174 return $expectedResult;
175}
176
177
178
179
180/*
181* This example has been generated from the API test suite. The test that created it is called
182*
183* testCreateIndividualWithContributionChainedArrays and can be found in
184* http://svn.civicrm.org/civicrm/branches/v3.4/tests/phpunit/CiviTest/api/v3/ContactTest.php
185*
186* You can see the outcome of the API tests at
187* http://tests.dev.civicrm.org/trunk/results-api_v3
188* and review the wiki at
189* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
190* Read more about testing here
191* http://wiki.civicrm.org/confluence/display/CRM/Testing
192*/
193