1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Speicher210\Fastbill\Api\Model; |
4
|
|
|
|
5
|
|
|
use JMS\Serializer\Annotation as JMS; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trait for coupon data. |
9
|
|
|
*/ |
10
|
|
|
trait CouponTrait |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The coupon code. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
* |
17
|
|
|
* @JMS\Type("string") |
18
|
|
|
* @JMS\SerializedName("CODE") |
19
|
|
|
*/ |
20
|
|
|
protected $code; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The coupon title. |
24
|
|
|
* |
25
|
|
|
* @var string |
26
|
|
|
* |
27
|
|
|
* @JMS\Type("string") |
28
|
|
|
* @JMS\SerializedName("TITLE") |
29
|
|
|
*/ |
30
|
|
|
protected $title; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* The coupon discount. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @JMS\Type("string") |
38
|
|
|
* @JMS\SerializedName("DISCOUNT") |
39
|
|
|
*/ |
40
|
|
|
protected $discount; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The coupon discount amount. |
44
|
|
|
* |
45
|
|
|
* @var float |
46
|
|
|
* |
47
|
|
|
* @JMS\Type("float") |
48
|
|
|
* @JMS\SerializedName("DISCOUNT_AMOUNT") |
49
|
|
|
*/ |
50
|
|
|
protected $discountAmount; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* The coupon discount type. |
54
|
|
|
* |
55
|
|
|
* @var string |
56
|
|
|
* |
57
|
|
|
* @JMS\Type("string") |
58
|
|
|
* @JMS\SerializedName("DISCOUNT_TYPE") |
59
|
|
|
*/ |
60
|
|
|
protected $discountType; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* The coupon discount period. |
64
|
|
|
* |
65
|
|
|
* @var string |
66
|
|
|
* |
67
|
|
|
* @JMS\Type("string") |
68
|
|
|
* @JMS\SerializedName("DISCOUNT_PERIOD") |
69
|
|
|
*/ |
70
|
|
|
protected $discountPeriod; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* The coupon discount period amount. |
74
|
|
|
* |
75
|
|
|
* @var integer |
76
|
|
|
* |
77
|
|
|
* @JMS\Type("integer") |
78
|
|
|
* @JMS\SerializedName("DISCOUNT_PERIOD_AMOUNT") |
79
|
|
|
*/ |
80
|
|
|
protected $discountPeriodAmount; |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* The coupon discount period unit. |
84
|
|
|
* |
85
|
|
|
* @var string |
86
|
|
|
* |
87
|
|
|
* @JMS\Type("string") |
88
|
|
|
* @JMS\SerializedName("DISCOUNT_PERIOD_UNIT") |
89
|
|
|
*/ |
90
|
|
|
protected $discountPeriodUnit; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* The coupon campaign. |
94
|
|
|
* |
95
|
|
|
* @var string |
96
|
|
|
* |
97
|
|
|
* @JMS\Type("string") |
98
|
|
|
* @JMS\SerializedName("CAMPAIGN") |
99
|
|
|
*/ |
100
|
|
|
protected $campaign = ''; |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* The coupon valid from. |
104
|
|
|
* |
105
|
|
|
* @var \DateTime |
106
|
|
|
* |
107
|
|
|
* @JMS\Type("DateTime<'Y-m-d'>") |
108
|
|
|
* @JMS\SerializedName("VALID_FROM") |
109
|
|
|
*/ |
110
|
|
|
protected $validFrom; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* The coupon valid to. |
114
|
|
|
* |
115
|
|
|
* @var \DateTime |
116
|
|
|
* |
117
|
|
|
* @JMS\Type("DateTime<'Y-m-d'>") |
118
|
|
|
* @JMS\SerializedName("VALID_TO") |
119
|
|
|
*/ |
120
|
|
|
protected $validTo; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* The coupon assigned articles. |
124
|
|
|
* |
125
|
|
|
* @var string |
126
|
|
|
* |
127
|
|
|
* @JMS\Type("string") |
128
|
|
|
* @JMS\SerializedName("ASSIGNED_ARTICLES") |
129
|
|
|
*/ |
130
|
|
|
protected $assignedArticles = ''; |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* The coupon affiliate. |
134
|
|
|
* |
135
|
|
|
* @var string |
136
|
|
|
* |
137
|
|
|
* @JMS\Type("string") |
138
|
|
|
* @JMS\SerializedName("AFFILIATE") |
139
|
|
|
*/ |
140
|
|
|
protected $affiliate; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* The coupon number of usages. |
144
|
|
|
* |
145
|
|
|
* @var integer |
146
|
|
|
* |
147
|
|
|
* @JMS\Type("integer") |
148
|
|
|
* @JMS\SerializedName("USAGES") |
149
|
|
|
*/ |
150
|
|
|
protected $usages; |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* The coupon maximum number of usages. |
154
|
|
|
* |
155
|
|
|
* @var integer |
156
|
|
|
* |
157
|
|
|
* @JMS\Type("integer") |
158
|
|
|
* @JMS\SerializedName("USAGES_MAX") |
159
|
|
|
*/ |
160
|
|
|
protected $usagesMax; |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* The coupon state. |
164
|
|
|
* |
165
|
|
|
* @var string |
166
|
|
|
* |
167
|
|
|
* @JMS\Type("string") |
168
|
|
|
* @JMS\SerializedName("STATE") |
169
|
|
|
*/ |
170
|
|
|
protected $state; |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Get the code. |
174
|
|
|
* |
175
|
|
|
* @return string |
176
|
|
|
*/ |
177
|
|
|
public function getCode() |
178
|
|
|
{ |
179
|
|
|
return $this->code; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Set the code. |
184
|
|
|
* |
185
|
|
|
* @param string $code The code to set. |
186
|
|
|
* @return $this |
187
|
|
|
*/ |
188
|
6 |
|
public function setCode($code) |
189
|
|
|
{ |
190
|
6 |
|
$this->code = $code; |
191
|
|
|
|
192
|
6 |
|
return $this; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Get the title. |
197
|
|
|
* |
198
|
|
|
* @return string |
199
|
|
|
*/ |
200
|
|
|
public function getTitle() |
201
|
|
|
{ |
202
|
|
|
return $this->title; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Set the title. |
207
|
|
|
* |
208
|
|
|
* @param string $title The title. |
209
|
|
|
* @return $this |
210
|
|
|
*/ |
211
|
6 |
|
public function setTitle($title) |
212
|
|
|
{ |
213
|
6 |
|
$this->title = $title; |
214
|
|
|
|
215
|
6 |
|
return $this; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Get the discount. |
220
|
|
|
* |
221
|
|
|
* @return string |
222
|
|
|
*/ |
223
|
|
|
public function getDiscount() |
224
|
|
|
{ |
225
|
|
|
return $this->discount; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* Set the discount. |
230
|
|
|
* |
231
|
|
|
* @param string $discount |
232
|
|
|
* @return $this |
233
|
|
|
*/ |
234
|
3 |
|
public function setDiscount($discount) |
235
|
|
|
{ |
236
|
3 |
|
$this->discount = $discount; |
237
|
|
|
|
238
|
3 |
|
return $this; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Get the discount amount. |
243
|
|
|
* |
244
|
|
|
* @return string |
245
|
|
|
*/ |
246
|
|
|
public function getDiscountAmount() |
247
|
|
|
{ |
248
|
|
|
return $this->discountAmount; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Set the discount amount. |
253
|
|
|
* |
254
|
|
|
* @param float $discountAmount |
255
|
|
|
* @return $this |
256
|
|
|
*/ |
257
|
3 |
|
public function setDiscountAmount($discountAmount) |
258
|
|
|
{ |
259
|
3 |
|
$this->discountAmount = $discountAmount; |
260
|
|
|
|
261
|
3 |
|
return $this; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* Get the discount type. |
266
|
|
|
* |
267
|
|
|
* @return string |
268
|
|
|
*/ |
269
|
|
|
public function getDiscountType() |
270
|
|
|
{ |
271
|
|
|
return $this->discountType; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Set the discount type. |
276
|
|
|
* |
277
|
|
|
* @param string $discountType |
278
|
|
|
* @return $this |
279
|
|
|
*/ |
280
|
3 |
|
public function setDiscountType($discountType) |
281
|
|
|
{ |
282
|
3 |
|
$this->discountType = $discountType; |
283
|
|
|
|
284
|
3 |
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* Get the discount period. |
289
|
|
|
* |
290
|
|
|
* @return string |
291
|
|
|
*/ |
292
|
|
|
public function getDiscountPeriod() |
293
|
|
|
{ |
294
|
|
|
return $this->discountPeriod; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
/** |
298
|
|
|
* Set the discount period. |
299
|
|
|
* |
300
|
|
|
* @param string $discountPeriod The period to set. |
301
|
|
|
* @return $this |
302
|
|
|
*/ |
303
|
3 |
|
public function setDiscountPeriod($discountPeriod) |
304
|
|
|
{ |
305
|
3 |
|
$this->discountPeriod = $discountPeriod; |
306
|
|
|
|
307
|
3 |
|
return $this; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* Get the discount period amount. |
312
|
|
|
* |
313
|
|
|
* @return integer |
314
|
|
|
*/ |
315
|
|
|
public function getDiscountPeriodAmount() |
316
|
|
|
{ |
317
|
|
|
return $this->discountPeriodAmount; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Set the discount period amount. |
322
|
|
|
* |
323
|
|
|
* @param integer $discountPeriodAmount |
324
|
|
|
* @return $this |
325
|
|
|
*/ |
326
|
6 |
|
public function setDiscountPeriodAmount($discountPeriodAmount) |
327
|
|
|
{ |
328
|
6 |
|
$this->discountPeriodAmount = $discountPeriodAmount; |
329
|
|
|
|
330
|
6 |
|
return $this; |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
/** |
334
|
|
|
* Get the discount period unit. |
335
|
|
|
* |
336
|
|
|
* @return string |
337
|
|
|
*/ |
338
|
|
|
public function getDiscountPeriodUnit() |
339
|
|
|
{ |
340
|
|
|
return $this->discountPeriodUnit; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Set the discount period unit. |
345
|
|
|
* |
346
|
|
|
* @param string $discountPeriodUnit |
347
|
|
|
* @return $this |
348
|
|
|
*/ |
349
|
6 |
|
public function setDiscountPeriodUnit($discountPeriodUnit) |
350
|
|
|
{ |
351
|
6 |
|
$this->discountPeriodUnit = $discountPeriodUnit; |
352
|
|
|
|
353
|
6 |
|
return $this; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* Get the campaign. |
358
|
|
|
* |
359
|
|
|
* @return string |
360
|
|
|
*/ |
361
|
|
|
public function getCampaign() |
362
|
|
|
{ |
363
|
|
|
return $this->campaign; |
364
|
|
|
} |
365
|
|
|
|
366
|
|
|
/** |
367
|
|
|
* Set the campaign. |
368
|
|
|
* |
369
|
|
|
* @param string $campaign The campaign. |
370
|
|
|
* @return $this |
371
|
|
|
*/ |
372
|
3 |
|
public function setCampaign($campaign) |
373
|
|
|
{ |
374
|
3 |
|
$this->campaign = $campaign; |
375
|
|
|
|
376
|
3 |
|
return $this; |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Check if the coupon is part of a campaign. |
381
|
|
|
* |
382
|
|
|
* @return boolean |
383
|
|
|
*/ |
384
|
|
|
public function hasCampaign() |
385
|
|
|
{ |
386
|
|
|
return $this->campaign != null; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Get the date from which the coupon is valid. |
391
|
|
|
* |
392
|
|
|
* @return \DateTime |
393
|
|
|
*/ |
394
|
3 |
|
public function getValidFrom() |
395
|
|
|
{ |
396
|
3 |
|
return $this->validFrom; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Set the date from which the coupon is valid. |
401
|
|
|
* |
402
|
|
|
* @param \DateTime $validFrom The date. |
403
|
|
|
* @return $this |
404
|
|
|
*/ |
405
|
3 |
|
public function setValidFrom(\DateTime $validFrom) |
406
|
|
|
{ |
407
|
3 |
|
$this->validFrom = $validFrom; |
408
|
|
|
|
409
|
3 |
|
return $this; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* Get the date until the coupon is valid. |
414
|
|
|
* |
415
|
|
|
* @return \DateTime |
416
|
|
|
*/ |
417
|
3 |
|
public function getValidTo() |
418
|
|
|
{ |
419
|
3 |
|
return $this->validTo; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* Set the date until the coupon is valid. |
424
|
|
|
* |
425
|
|
|
* @param mixed $validTo The date. |
426
|
|
|
* @return $this |
427
|
|
|
*/ |
428
|
3 |
|
public function setValidTo($validTo) |
429
|
|
|
{ |
430
|
3 |
|
$this->validTo = $validTo; |
431
|
|
|
|
432
|
3 |
|
return $this; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Get the assigned articles. |
437
|
|
|
* |
438
|
|
|
* @return array |
439
|
|
|
*/ |
440
|
|
|
public function getAssignedArticles() |
441
|
|
|
{ |
442
|
|
|
$articles = explode(',', $this->assignedArticles); |
443
|
|
|
|
444
|
|
|
return array_map('trim', $articles); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Set the assigned articles. |
449
|
|
|
* |
450
|
|
|
* @param array $assignedArticles The assigned articles. |
451
|
|
|
* @return $this |
452
|
|
|
*/ |
453
|
3 |
|
public function setAssignedArticles(array $assignedArticles) |
454
|
|
|
{ |
455
|
3 |
|
$this->assignedArticles = implode(', ', $assignedArticles); |
456
|
|
|
|
457
|
3 |
|
return $this; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* Get the affiliate. |
462
|
|
|
* |
463
|
|
|
* @return string |
464
|
|
|
*/ |
465
|
|
|
public function getAffiliate() |
466
|
|
|
{ |
467
|
|
|
return $this->affiliate; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
/** |
471
|
|
|
* Set the affiliate. |
472
|
|
|
* |
473
|
|
|
* @param string $affiliate The affiliate. |
474
|
|
|
* @return $this |
475
|
|
|
*/ |
476
|
|
|
public function setAffiliate($affiliate) |
477
|
|
|
{ |
478
|
|
|
$this->affiliate = $affiliate; |
479
|
|
|
|
480
|
|
|
return $this; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
/** |
484
|
|
|
* Get the number of usages. |
485
|
|
|
* |
486
|
|
|
* @return integer |
487
|
|
|
*/ |
488
|
|
|
public function getUsages() |
489
|
|
|
{ |
490
|
|
|
return $this->usages; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Set the number of usages. |
495
|
|
|
* |
496
|
|
|
* @param integer $usages The usages. |
497
|
|
|
* @return $this |
498
|
|
|
*/ |
499
|
3 |
|
public function setUsages($usages) |
500
|
|
|
{ |
501
|
3 |
|
$this->usages = $usages; |
502
|
|
|
|
503
|
3 |
|
return $this; |
504
|
|
|
} |
505
|
|
|
|
506
|
|
|
/** |
507
|
|
|
* Get the maximum usages. |
508
|
|
|
* |
509
|
|
|
* @return integer |
510
|
|
|
*/ |
511
|
|
|
public function getUsagesMax() |
512
|
|
|
{ |
513
|
|
|
return $this->usagesMax; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Set the maximum usages. |
518
|
|
|
* |
519
|
|
|
* @param integer $usagesMax The maximum usages. |
520
|
|
|
* @return $this |
521
|
|
|
*/ |
522
|
6 |
|
public function setUsagesMax($usagesMax) |
523
|
|
|
{ |
524
|
6 |
|
$this->usagesMax = $usagesMax; |
525
|
|
|
|
526
|
6 |
|
return $this; |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Get the state. |
531
|
|
|
* |
532
|
|
|
* @return string |
533
|
|
|
*/ |
534
|
|
|
public function getState() |
535
|
|
|
{ |
536
|
|
|
return $this->state; |
537
|
|
|
} |
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* Set the state. |
541
|
|
|
* |
542
|
|
|
* @param string $state The state. |
543
|
|
|
* @return $this |
544
|
|
|
*/ |
545
|
3 |
|
public function setState($state) |
546
|
|
|
{ |
547
|
3 |
|
$this->state = $state; |
548
|
|
|
|
549
|
3 |
|
return $this; |
550
|
|
|
} |
551
|
|
|
} |
552
|
|
|
|