Commit | Line | Data |
---|---|---|
425723d9 | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
425723d9 | 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 | | |
425723d9 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
425723d9 | 11 | /** |
12 | * | |
13 | * APIv3 functions for registering/processing mailing group events. | |
14 | * | |
15 | * @package CiviCRM_APIv3 | |
425723d9 | 16 | */ |
5c766a0b | 17 | |
425723d9 | 18 | /** |
244bbdd8 | 19 | * Handle a queue event. |
425723d9 | 20 | * |
cf470720 | 21 | * @param array $params |
2e66abf8 | 22 | * Array of property. |
425723d9 | 23 | * |
24 | * @throws Exception | |
a6c01b45 | 25 | * @return array |
72b3a70c | 26 | * api result array |
425723d9 | 27 | */ |
28 | function civicrm_api3_mailing_event_queue_create($params) { | |
bd6658bd | 29 | if (!array_key_exists('id', $params) && !array_key_exists('email_id', $params) && !array_key_exists('phone_id', $params)) { |
481a74f4 | 30 | throw new API_Exception("Mandatory key missing from params array: id, email_id, or phone_id field is required"); |
425723d9 | 31 | } |
32 | civicrm_api3_verify_mandatory($params, | |
33 | 'CRM_Mailing_DAO_MailingJob', | |
cf8f0fff | 34 | ['job_id', 'contact_id'], |
425723d9 | 35 | FALSE |
36 | ); | |
a25b46e9 | 37 | return _civicrm_api3_basic_create('CRM_Mailing_Event_BAO_Queue', $params, 'Queue'); |
425723d9 | 38 | } |
bd6658bd | 39 | |
c23f45d3 | 40 | /** |
2e66abf8 EM |
41 | * Get mailing event queue record. |
42 | * | |
c23f45d3 | 43 | * @param array $params |
dc64d047 | 44 | * |
c23f45d3 EM |
45 | * @return array |
46 | */ | |
425723d9 | 47 | function civicrm_api3_mailing_event_queue_get($params) { |
48 | return _civicrm_api3_basic_get('CRM_Mailing_Event_BAO_Queue', $params); | |
49 | } | |
bd6658bd | 50 | |
c23f45d3 | 51 | /** |
2e66abf8 EM |
52 | * Delete mailing event queue record. |
53 | * | |
c23f45d3 | 54 | * @param array $params |
2e66abf8 | 55 | * |
c23f45d3 EM |
56 | * @return array |
57 | * @throws \API_Exception | |
58 | */ | |
bd6658bd TO |
59 | function civicrm_api3_mailing_event_queue_delete($params) { |
60 | return _civicrm_api3_basic_delete('CRM_Mailing_Event_BAO_Queue', $params); | |
61 | } | |
62 | ||
425723d9 | 63 | /** |
0aa0303c EM |
64 | * Adjust Metadata for Create action. |
65 | * | |
66 | * The metadata is used for setting defaults, documentation & validation. | |
425723d9 | 67 | * |
cf470720 | 68 | * @param array $params |
b081365f | 69 | * Array of parameters determined by getfields. |
425723d9 | 70 | */ |
71 | function _civicrm_api3_mailing_event_queue_create_spec(&$params) { | |
72 | $params['job_id']['api.required'] = 1; | |
73 | $params['contact_id']['api.required'] = 1; | |
74 | } |