Minor tidyup of api3 completetransaction; plus comments
[civicrm-core.git] / api / v3 / MailingEventResubscribe.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
a30c801b
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * APIv3 functions for registering/processing mailing group events.
15 *
16 * @package CiviCRM_APIv3
6a488035
TO
17 */
18
19/**
0965e988 20 * Subscribe from mailing group.
6a488035 21 *
cf470720 22 * @param array $params
6a488035 23 *
a6c01b45 24 * @return array
72b3a70c 25 * api result array
6a488035
TO
26 */
27function civicrm_api3_mailing_event_resubscribe_create($params) {
28
29 $groups = CRM_Mailing_Event_BAO_Resubscribe::resub_to_mailing(
30 $params['job_id'],
31 $params['event_queue_id'],
32 $params['hash']
33 );
34
35 if (count($groups)) {
36 CRM_Mailing_Event_BAO_Resubscribe::send_resub_response(
37 $params['event_queue_id'],
5c2d1ad1 38 $groups,
6a488035
TO
39 $params['job_id']
40 );
41 return civicrm_api3_create_success($params);
42 }
43 return civicrm_api3_create_error('Queue event could not be found');
44}
11e09c59
TO
45
46/**
0965e988
EM
47 * Adjust Metadata for Create action.
48 *
49 * The metadata is used for setting defaults, documentation & validation.
1c88e578 50 *
cf470720 51 * @param array $params
b081365f 52 * Array of parameters determined by getfields.
6a488035
TO
53 */
54function _civicrm_api3_mailing_event_resubscribe_create_spec(&$params) {
cf8f0fff 55 $params['event_queue_id'] = [
d142432b
EM
56 'api.required' => 1,
57 'title' => 'Event Queue ID',
58 'type' => CRM_Utils_Type::T_INT,
cf8f0fff
CW
59 ];
60 $params['job_id'] = [
d142432b
EM
61 'api.required' => 1,
62 'title' => 'Job ID',
63 'type' => CRM_Utils_Type::T_INT,
cf8f0fff
CW
64 ];
65 $params['hash'] = [
d142432b
EM
66 'api.required' => 1,
67 'title' => 'Hash',
68 'type' => CRM_Utils_Type::T_STRING,
cf8f0fff 69 ];
6a488035 70}