Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | ||
3 | /* | |
4 | /*this demonstrates setting a custom field through the API | |
5 | */ | |
6 | function contact_create_example(){ | |
edb0d67a | 7 | $params = array( |
6a488035 TO |
8 | 'first_name' => 'abc1', |
9 | 'contact_type' => 'Individual', | |
10 | 'last_name' => 'xyz1', | |
11 | 'version' => 3, | |
12 | 'custom_1' => 'custom string', | |
13 | ); | |
14 | ||
15 | $result = civicrm_api( 'contact','create',$params ); | |
16 | ||
17 | return $result; | |
18 | } | |
19 | ||
20 | /* | |
21 | * Function returns array of result expected from previous function | |
22 | */ | |
23 | function contact_create_expectedresult(){ | |
24 | ||
edb0d67a | 25 | $expectedResult = array( |
6a488035 TO |
26 | 'is_error' => 0, |
27 | 'version' => 3, | |
28 | 'count' => 1, | |
29 | 'id' => 1, | |
edb0d67a | 30 | 'values' => array( |
31 | '1' => array( | |
6a488035 TO |
32 | 'id' => '1', |
33 | 'contact_type' => 'Individual', | |
34 | 'contact_sub_type' => '', | |
35 | 'do_not_email' => 0, | |
36 | 'do_not_phone' => 0, | |
37 | 'do_not_mail' => 0, | |
38 | 'do_not_sms' => 0, | |
39 | 'do_not_trade' => 0, | |
40 | 'is_opt_out' => 0, | |
41 | 'legal_identifier' => '', | |
42 | 'external_identifier' => '', | |
43 | 'sort_name' => 'xyz1, abc1', | |
44 | 'display_name' => 'abc1 xyz1', | |
45 | 'nick_name' => '', | |
46 | 'legal_name' => '', | |
47 | 'image_URL' => '', | |
48 | 'preferred_communication_method' => '', | |
49 | 'preferred_language' => 'en_US', | |
50 | 'preferred_mail_format' => 'Both', | |
51 | 'hash' => '67eac7789eaee00', | |
52 | 'api_key' => '', | |
53 | 'first_name' => 'abc1', | |
54 | 'middle_name' => '', | |
55 | 'last_name' => 'xyz1', | |
56 | 'prefix_id' => '', | |
57 | 'suffix_id' => '', | |
58 | 'email_greeting_id' => '1', | |
59 | 'email_greeting_custom' => '', | |
60 | 'email_greeting_display' => '', | |
61 | 'postal_greeting_id' => '1', | |
62 | 'postal_greeting_custom' => '', | |
63 | 'postal_greeting_display' => '', | |
64 | 'addressee_id' => '1', | |
65 | 'addressee_custom' => '', | |
66 | 'addressee_display' => '', | |
67 | 'job_title' => '', | |
68 | 'gender_id' => '', | |
69 | 'birth_date' => '', | |
70 | 'is_deceased' => 0, | |
71 | 'deceased_date' => '', | |
72 | 'household_name' => '', | |
73 | 'primary_contact_id' => '', | |
74 | 'organization_name' => '', | |
75 | 'sic_code' => '', | |
76 | 'user_unique_id' => '', | |
edb0d67a | 77 | 'created_date' => '20120130621222105', |
6a488035 TO |
78 | 'modified_date' => '2012-11-14 16:02:35', |
79 | ), | |
80 | ), | |
81 | ); | |
82 | ||
83 | return $expectedResult ; | |
84 | } | |
85 | ||
86 | ||
87 | /* | |
88 | * This example has been generated from the API test suite. The test that created it is called | |
89 | * | |
90 | * testCreateWithCustom and can be found in | |
91 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ContactTest.php | |
92 | * | |
93 | * You can see the outcome of the API tests at | |
94 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
95 | * | |
96 | * To Learn about the API read | |
97 | * http://book.civicrm.org/developer/current/techniques/api/ | |
98 | * | |
99 | * and review the wiki at | |
100 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
101 | * | |
102 | * Read more about testing here | |
103 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
104 | * | |
105 | * API Standards documentation: | |
106 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
107 | */ |