Merge pull request #17522 from seamuslee001/remove_deprecated_methods
[civicrm-core.git] / api / v3 / MailingEventConfirm.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * APIv3 functions for registering/processing mailing group events.
15 *
16 * @package CiviCRM_APIv3
17 */
18
19 /**
20 * Handle a confirm event.
21 *
22 * @param array $params
23 * name/value pairs to insert in new 'survey'
24 *
25 * @throws Exception
26 * @return array
27 * api result array
28 */
29 function civicrm_api3_mailing_event_confirm_create($params) {
30
31 $contact_id = $params['contact_id'];
32 $subscribe_id = $params['subscribe_id'];
33 $hash = $params['hash'];
34
35 $confirm = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash) !== FALSE;
36
37 if (!$confirm) {
38 throw new Exception('Confirmation failed');
39 }
40 return civicrm_api3_create_success($params);
41 }
42
43 /**
44 * Adjust Metadata for Create action.
45 *
46 * The metadata is used for setting defaults, documentation & validation.
47 *
48 * @param array $params
49 * Array of parameters determined by getfields.
50 */
51 function _civicrm_api3_mailing_event_confirm_create_spec(&$params) {
52 $params['contact_id'] = [
53 'api.required' => 1,
54 'title' => 'Contact ID',
55 'type' => CRM_Utils_Type::T_INT,
56 ];
57 $params['subscribe_id'] = [
58 'api.required' => 1,
59 'title' => 'Subscribe Event ID',
60 'type' => CRM_Utils_Type::T_INT,
61 ];
62 $params['hash'] = [
63 'api.required' => 1,
64 'title' => 'Hash',
65 'type' => CRM_Utils_Type::T_STRING,
66 ];
67 }