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