Merge pull request #15124 from mattwire/REF_processMembershipPending
[civicrm-core.git] / api / v3 / examples / Contact / GetUnique.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Contact.getunique API.
4 *
5 * @return array
6 * API result array
7 */
8 function contact_getunique_example() {
9 $params = [];
10
11 try{
12 $result = civicrm_api3('Contact', 'getunique', $params);
13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // Handle error here.
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return [
20 'is_error' => 1,
21 'error_message' => $errorMessage,
22 'error_code' => $errorCode,
23 'error_data' => $errorData,
24 ];
25 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function.
32 *
33 * @return array
34 * API result array
35 */
36 function contact_getunique_expectedresult() {
37
38 $expectedResult = [
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 'UI_external_identifier',
43 'values' => [
44 'UI_external_identifier' => [],
45 ],
46 ];
47
48 return $expectedResult;
49 }
50
51 /*
52 * This example has been generated from the API test suite.
53 * The test that created it is called "testContactGetUnique"
54 * and can be found at:
55 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
56 *
57 * You can see the outcome of the API tests at
58 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
59 *
60 * To Learn about the API read
61 * https://docs.civicrm.org/dev/en/latest/api/
62 *
63 * Browse the API on your own site with the API Explorer. It is in the main
64 * CiviCRM menu, under: Support > Development > API Explorer.
65 *
66 * Read more about testing here
67 * https://docs.civicrm.org/dev/en/latest/testing/
68 *
69 * API Standards documentation:
70 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/
71 */