Update copyright date for 2020
[civicrm-core.git] / tests / phpunit / api / v3 / custom_api / MailingProviderData.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * @package CRM
30 * @copyright CiviCRM LLC (c) 2004-2020
31 *
32 * Generated from xml/schema/CRM/Omnimail/MailingProviderData.xml
33 * DO NOT EDIT. Generated by CRM_Core_CodeGen
34 * (GenCodeChecksum:a204d62995809fae79a76799b88a69f8)
35 */
36
37 /**
38 * CRM_Omnimail_DAO_MailingProviderData constructor.
39 */
40 class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 protected static $_tableName = 'civicrm_mailing_provider_data';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var bool
51 */
52 protected static $_log = FALSE;
53 /**
54 * External reference for the contact
55 *
56 * @var string
57 */
58 public $contact_identifier;
59 /**
60 * External Reference for the mailing
61 *
62 * @var string
63 */
64 public $mailing_identifier;
65 /**
66 * Email Address
67 *
68 * @var string
69 */
70 public $email;
71 /**
72 * Type of action
73 *
74 * @var string
75 */
76 public $event_type;
77 /**
78 * When the action happened
79 *
80 * @var timestamp
81 */
82 public $recipient_action_datetime;
83 /**
84 * Contact in CiviCRM
85 *
86 * @var int
87 */
88 public $contact_id;
89 /**
90 * Has the action been synchronised through to CiviCRM
91 *
92 * @var bool
93 */
94 public $is_civicrm_updated;
95
96 /**
97 * Class constructor.
98 */
99 public function __construct() {
100 $this->__table = 'civicrm_mailing_provider_data';
101 parent::__construct();
102 }
103
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
109 public static function &fields() {
110 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
111 Civi::$statics[__CLASS__]['fields'] = [
112 'contact_identifier' => [
113 'name' => 'contact_identifier',
114 'type' => CRM_Utils_Type::T_STRING,
115 'title' => ts('Contact Identifier') ,
116 'description' => 'External reference for the contact',
117 'maxlength' => 255,
118 'size' => CRM_Utils_Type::HUGE,
119 'table_name' => 'civicrm_mailing_provider_data',
120 'entity' => 'MailingProviderData',
121 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
122 'localizable' => 0,
123 ] ,
124 'mailing_identifier' => [
125 'name' => 'mailing_identifier',
126 'type' => CRM_Utils_Type::T_STRING,
127 'title' => ts('Mailing Identifier') ,
128 'description' => 'External Referencefor the mailing',
129 'maxlength' => 255,
130 'size' => CRM_Utils_Type::HUGE,
131 'table_name' => 'civicrm_mailing_provider_data',
132 'entity' => 'MailingProviderData',
133 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
134 'localizable' => 0,
135 ] ,
136 'email' => [
137 'name' => 'email',
138 'type' => CRM_Utils_Type::T_STRING,
139 'title' => ts('Email') ,
140 'description' => 'Email Address',
141 'maxlength' => 255,
142 'size' => CRM_Utils_Type::HUGE,
143 'table_name' => 'civicrm_mailing_provider_data',
144 'entity' => 'MailingProviderData',
145 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
146 'localizable' => 0,
147 ] ,
148 'event_type' => [
149 'name' => 'event_type',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Recipient Action Type') ,
152 'description' => 'Type of action',
153 'maxlength' => 255,
154 'size' => CRM_Utils_Type::HUGE,
155 'table_name' => 'civicrm_mailing_provider_data',
156 'entity' => 'MailingProviderData',
157 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
158 'localizable' => 0,
159 ] ,
160 'recipient_action_datetime' => [
161 'name' => 'recipient_action_datetime',
162 'type' => CRM_Utils_Type::T_TIMESTAMP,
163 'title' => ts('Recipient Action Datetime') ,
164 'description' => 'When the action happened',
165 'table_name' => 'civicrm_mailing_provider_data',
166 'entity' => 'MailingProviderData',
167 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
168 'localizable' => 0,
169 ],
170 'contact_id' => [
171 'name' => 'contact_id',
172 'type' => CRM_Utils_Type::T_INT,
173 'description' => 'Contact in CiviCRM',
174 'table_name' => 'civicrm_mailing_provider_data',
175 'entity' => 'MailingProviderData',
176 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
177 'localizable' => 0,
178 ] ,
179 'is_civicrm_updated' => [
180 'name' => 'is_civicrm_updated',
181 'type' => CRM_Utils_Type::T_BOOLEAN,
182 'description' => 'Has the action been synchronised through to CiviCRM',
183 'table_name' => 'civicrm_mailing_provider_data',
184 'entity' => 'MailingProviderData',
185 'bao' => 'CRM_Omnimail_DAO_MailingProviderData',
186 'localizable' => 0,
187 ] ,
188 ];
189 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
190 }
191 return Civi::$statics[__CLASS__]['fields'];
192 }
193
194 /**
195 * Return a mapping from field-name to the corresponding key (as used in fields()).
196 *
197 * @return array
198 * Array(string $name => string $uniqueName).
199 */
200 public static function &fieldKeys() {
201 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
202 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
203 }
204 return Civi::$statics[__CLASS__]['fieldKeys'];
205 }
206
207 /**
208 * Returns the names of this table
209 *
210 * @return string
211 */
212 public static function getTableName() {
213 return self::$_tableName;
214 }
215
216 /**
217 * Returns if this table needs to be logged
218 *
219 * @return bool
220 */
221 public function getLog() {
222 return self::$_log;
223 }
224
225 /**
226 * Returns the list of fields that can be imported
227 *
228 * @param bool $prefix
229 *
230 * @return array
231 */
232 public static function &import($prefix = FALSE) {
233 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_provider_data', $prefix, []);
234 return $r;
235 }
236
237 /**
238 * Returns the list of fields that can be exported
239 *
240 * @param bool $prefix
241 *
242 * @return array
243 */
244 public static function &export($prefix = FALSE) {
245 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_provider_data', $prefix, []);
246 return $r;
247 }
248
249 /**
250 * Returns the list of indices
251 */
252 public static function indices($localize = TRUE) {
253 $indices = [];
254 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
255 }
256
257 }
258
259 /**
260 * CRM_Omnimail_BAO_MailingProviderData constructor.
261 */
262 class CRM_Omnimail_BAO_MailingProviderData extends CRM_Omnimail_DAO_MailingProviderData {
263
264 }
265
266 /**
267 * MailingProviderData.get API
268 *
269 * @param array $params
270 * @return array API result descriptor
271 * @throws API_Exception
272 */
273 function civicrm_api3_mailing_provider_data_get($params) {
274 $sql = CRM_Utils_SQL_Select::fragment();
275 $sql->select('CONCAT(contact_identifier, mailing_identifier, recipient_action_datetime) as id');
276 return civicrm_api3_create_success(_civicrm_api3_basic_get('CRM_Omnimail_BAO_MailingProviderData', $params, FALSE, 'MailingProviderData', $sql, FALSE));
277 }
278
279 /**
280 * Metadata for MailingProviderData.get API
281 *
282 * @param array $params
283 *
284 * @throws API_Exception
285 */
286 function _civicrm_api3_mailing_provider_data_get_spec(&$params) {
287 $params['mailing_identifier']['FKClassName'] = 'CRM_Mailing_BAO_Mailing';
288 $params['mailing_identifier']['FKApiName'] = 'Mailing';
289 $params['mailing_identifier']['FKKeyColumn'] = 'hash';
290 }
291
292 /**
293 * MailingProviderData.create API
294 *
295 * @param array $params
296 * @return array API result descriptor
297 * @throws API_Exception
298 */
299 function civicrm_api3_mailing_provider_data_create($params) {
300 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
301 }