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