Completed
Push — master ( d6c0fd...e0d2a4 )
by Joachim
12:44
created

Label::getSenderTelephone()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Loevgaard\PakkelabelsBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\Table(name="pakkelabels_labels")
10
 */
11
class Label
12
{
13
    const STATUS_PENDING_NORMALIZATION = 'pending_normalization';
14
    const STATUS_PENDING_CREATION = 'pending_creation';
15
    const STATUS_ERROR = 'error';
16
    const STATUS_SUCCESS = 'success';
17
18
    const LABEL_FORMAT_A4_PDF = 'a4_pdf';
19
    const LABEL_FORMAT_10_X_19_PDF = '10x19_pdf';
20
    const LABEL_FORMAT_PNG = 'png';
21
    const LABEL_FORMAT_ZPL = 'zpl';
22
23
    /**
24
     * @var int
25
     *
26
     * @ORM\Id
27
     * @ORM\GeneratedValue
28
     * @ORM\Column(type="integer")
29
     */
30
    protected $id;
31
32
    /**
33
     * @var string
34
     *
35
     * @ORM\Column(type="string")
36
     */
37
    protected $status;
38
39
    /**
40
     * @var string
41
     *
42
     * @ORM\Column(type="text", nullable=true)
43
     */
44
    protected $error;
45
46
    /**
47
     * The shipping method property is used in normalization. We check the mappings table to see
48
     * if there is a shipping method matching this. If there is, we will populate the product code
49
     * and services codes properties
50
     *
51
     * @var string
52
     *
53
     * @ORM\Column(type="string", nullable=true)
54
     */
55
    protected $shippingMethod;
56
57
    /**************************
58
     * Pakkelabels properties *
59
     *************************/
60
    /**
61
     * @var string
62
     *
63
     * @ORM\Column(type="string", nullable=true)
64
     */
65
    protected $orderId;
66
67
    /**
68
     * @var string
69
     *
70
     * @ORM\Column(type="string", nullable=true)
71
     */
72
    protected $reference;
73
74
    /**
75
     * @var string
76
     *
77
     * @ORM\Column(type="string", nullable=true)
78
     */
79
    protected $source;
80
81
    /**
82
     * @var boolean
83
     *
84
     * @ORM\Column(type="boolean")
85
     */
86
    protected $ownAgreement;
87
88
    /**
89
     * @var string
90
     *
91
     * @ORM\Column(type="string", nullable=true)
92
     */
93
    protected $labelFormat;
94
95
    /**
96
     * @var string
97
     *
98
     * @ORM\Column(type="string")
99
     */
100
    protected $productCode;
101
102
    /**
103
     * @var string
104
     *
105
     * @ORM\Column(type="string")
106
     */
107
    protected $serviceCodes;
108
109
    /**
110
     * @var boolean
111
     *
112
     * @ORM\Column(type="boolean")
113
     */
114
    protected $automaticSelectServicePoint;
115
116
    /**
117
     * @var string
118
     *
119
     * @ORM\Column(type="string")
120
     */
121
    protected $servicePointId;
122
123
    /**
124
     * @var boolean
125
     *
126
     * @ORM\Column(type="boolean")
127
     */
128
    protected $smsNotification;
129
130
    /**
131
     * @var boolean
132
     *
133
     * @ORM\Column(type="boolean")
134
     */
135
    protected $emailNotification;
136
137
    /**
138
     * @var string
139
     *
140
     * @ORM\Column(type="string")
141
     */
142
    protected $senderName;
143
144
    /**
145
     * @var string
146
     *
147
     * @ORM\Column(type="string")
148
     */
149
    protected $senderAddress1;
150
151
    /**
152
     * @var string
153
     *
154
     * @ORM\Column(type="string", nullable=true)
155
     */
156
    protected $senderAddress2;
157
158
    /**
159
     * @var string
160
     *
161
     * @ORM\Column(type="string")
162
     */
163
    protected $senderCountryCode;
164
165
    /**
166
     * @var string
167
     *
168
     * @ORM\Column(type="string")
169
     */
170
    protected $senderZipCode;
171
172
    /**
173
     * @var string
174
     *
175
     * @ORM\Column(type="string")
176
     */
177
    protected $senderCity;
178
179
    /**
180
     * @var string
181
     *
182
     * @ORM\Column(type="string", nullable=true)
183
     */
184
    protected $senderAttention;
185
186
    /**
187
     * @var string
188
     *
189
     * @ORM\Column(type="string")
190
     */
191
    protected $senderEmail;
192
193
    /**
194
     * @var string
195
     *
196
     * @ORM\Column(type="string")
197
     */
198
    protected $senderTelephone;
199
200
    /**
201
     * @var string
202
     *
203
     * @ORM\Column(type="string")
204
     */
205
    protected $senderMobile;
206
207
    /**
208
     * @var string
209
     *
210
     * @ORM\Column(type="string")
211
     */
212
    protected $receiverName;
213
214
    /**
215
     * @var string
216
     *
217
     * @ORM\Column(type="string")
218
     */
219
    protected $receiverAddress1;
220
221
    /**
222
     * @var string
223
     *
224
     * @ORM\Column(type="string", nullable=true)
225
     */
226
    protected $receiverAddress2;
227
228
    /**
229
     * @var string
230
     *
231
     * @ORM\Column(type="string")
232
     */
233
    protected $receiverCountryCode;
234
235
    /**
236
     * @var string
237
     *
238
     * @ORM\Column(type="string")
239
     */
240
    protected $receiverZipCode;
241
242
    /**
243
     * @var string
244
     *
245
     * @ORM\Column(type="string")
246
     */
247
    protected $receiverCity;
248
249
    /**
250
     * @var string
251
     *
252
     * @ORM\Column(type="string", nullable=true)
253
     */
254
    protected $receiverAttention;
255
256
    /**
257
     * @var string
258
     *
259
     * @ORM\Column(type="string")
260
     */
261
    protected $receiverEmail;
262
263
    /**
264
     * @var string
265
     *
266
     * @ORM\Column(type="string")
267
     */
268
    protected $receiverTelephone;
269
270
    /**
271
     * @var string
272
     *
273
     * @ORM\Column(type="string")
274
     */
275
    protected $receiverMobile;
276
277
    /**
278
     * @var string
279
     *
280
     * @ORM\Column(type="text", nullable=true)
281
     */
282
    protected $receiverInstruction;
283
284
    public function __construct()
285
    {
286
        $this->status = static::STATUS_PENDING_NORMALIZATION;
287
        $this->smsNotification = false;
288
        $this->emailNotification = false;
289
    }
290
291
    public function arrayForApi() : array
292
    {
293
        $data = [
294
            'order_id' => $this->orderId,
295
            'reference' => $this->reference,
296
            'source' => $this->source,
297
            'own_agreement' => $this->ownAgreement,
298
            'label_format' => $this->labelFormat,
299
            'product_code' => $this->productCode,
300
            'service_codes' => $this->serviceCodes,
301
            'automatic_select_service_point' => $this->automaticSelectServicePoint,
302
            'sms_notification' => $this->smsNotification,
303
            'email_notification' => $this->emailNotification,
304
            'service_point' => [
305
                'id' => $this->servicePointId
306
            ],
307
            'sender' => [
308
                'name' => $this->senderName,
309
                'address1' => $this->senderAddress1,
310
                'address2' => $this->senderAddress2,
311
                'country_code' => $this->senderCountryCode,
312
                'zipcode' => $this->senderZipCode,
313
                'city' => $this->senderCity,
314
                'attention' => $this->senderAttention,
315
                'email' => $this->senderEmail,
316
                'telephone' => $this->senderTelephone,
317
                'mobile' => $this->senderMobile
318
            ],
319
            'receiver' => [
320
                'name' => $this->receiverName,
321
                'address1' => $this->receiverAddress1,
322
                'address2' => $this->receiverAddress2,
323
                'country_code' => $this->receiverCountryCode,
324
                'zipcode' => $this->receiverZipCode,
325
                'city' => $this->receiverCity,
326
                'attention' => $this->receiverAttention,
327
                'email' => $this->receiverEmail,
328
                'telephone' => $this->receiverTelephone,
329
                'mobile' => $this->receiverMobile,
330
                'instruction' => $this->receiverInstruction
331
            ],
332
            'parcels' => [
333
                [
334
                    'weight' => 1000
335
                ]
336
            ]
337
        ];
338
339
        $data = array_filter($data, function($elm) {
340
            return !is_null($elm);
341
        });
342
343
        return $data;
344
    }
345
346
    public function markAsError(string $error)
347
    {
348
        $this->error = $error;
349
        $this->status = static::STATUS_ERROR;
350
    }
351
352
    public function markAsSuccess()
353
    {
354
        $this->error = null;
355
        $this->status = static::STATUS_SUCCESS;
356
    }
357
358
    /*********************
359
     * Getters / Setters *
360
     ********************/
361
    /**
362
     * @return int
363
     */
364
    public function getId(): int
365
    {
366
        return $this->id;
367
    }
368
369
    /**
370
     * @param int $id
371
     * @return Label
372
     */
373
    public function setId(int $id)
374
    {
375
        $this->id = $id;
376
        return $this;
377
    }
378
379
    /**
380
     * @return string
381
     */
382
    public function getStatus(): string
383
    {
384
        return $this->status;
385
    }
386
387
    /**
388
     * @param string $status
389
     * @return Label
390
     */
391
    public function setStatus(string $status)
392
    {
393
        $this->status = $status;
394
        return $this;
395
    }
396
397
    /**
398
     * @return string
399
     */
400
    public function getError(): string
401
    {
402
        return $this->error;
403
    }
404
405
    /**
406
     * @param string $error
407
     * @return Label
408
     */
409
    public function setError(string $error)
410
    {
411
        $this->error = $error;
412
        return $this;
413
    }
414
415
    /**
416
     * @return string
417
     */
418
    public function getShippingMethod(): string
419
    {
420
        return $this->shippingMethod;
421
    }
422
423
    /**
424
     * @param string $shippingMethod
425
     * @return Label
426
     */
427
    public function setShippingMethod(string $shippingMethod)
428
    {
429
        $this->shippingMethod = $shippingMethod;
430
        return $this;
431
    }
432
433
    /**
434
     * @return string
435
     */
436
    public function getOrderId(): string
437
    {
438
        return $this->orderId;
439
    }
440
441
    /**
442
     * @param string $orderId
443
     * @return Label
444
     */
445
    public function setOrderId(string $orderId)
446
    {
447
        $this->orderId = $orderId;
448
        return $this;
449
    }
450
451
    /**
452
     * @return string
453
     */
454
    public function getReference(): string
455
    {
456
        return $this->reference;
457
    }
458
459
    /**
460
     * @param string $reference
461
     * @return Label
462
     */
463
    public function setReference(string $reference)
464
    {
465
        $this->reference = $reference;
466
        return $this;
467
    }
468
469
    /**
470
     * @return string
471
     */
472
    public function getSource(): string
473
    {
474
        return $this->source;
475
    }
476
477
    /**
478
     * @param string $source
479
     * @return Label
480
     */
481
    public function setSource(string $source)
482
    {
483
        $this->source = $source;
484
        return $this;
485
    }
486
487
    /**
488
     * @return bool
489
     */
490
    public function isOwnAgreement(): bool
491
    {
492
        return $this->ownAgreement;
493
    }
494
495
    /**
496
     * @param bool $ownAgreement
497
     * @return Label
498
     */
499
    public function setOwnAgreement(bool $ownAgreement)
500
    {
501
        $this->ownAgreement = $ownAgreement;
502
        return $this;
503
    }
504
505
    /**
506
     * @return string
507
     */
508
    public function getLabelFormat(): string
509
    {
510
        return $this->labelFormat;
511
    }
512
513
    /**
514
     * @param string $labelFormat
515
     * @return Label
516
     */
517
    public function setLabelFormat(string $labelFormat)
518
    {
519
        $this->labelFormat = $labelFormat;
520
        return $this;
521
    }
522
523
    /**
524
     * @return string
525
     */
526
    public function getProductCode(): string
527
    {
528
        return $this->productCode;
529
    }
530
531
    /**
532
     * @param string $productCode
533
     * @return Label
534
     */
535
    public function setProductCode(string $productCode)
536
    {
537
        $this->productCode = $productCode;
538
        return $this;
539
    }
540
541
    /**
542
     * @return string
543
     */
544
    public function getServiceCodes(): string
545
    {
546
        return $this->serviceCodes;
547
    }
548
549
    /**
550
     * @param string $serviceCodes
551
     * @return Label
552
     */
553
    public function setServiceCodes(string $serviceCodes)
554
    {
555
        $this->serviceCodes = $serviceCodes;
556
        return $this;
557
    }
558
559
    /**
560
     * @return bool
561
     */
562
    public function isAutomaticSelectServicePoint(): bool
563
    {
564
        return $this->automaticSelectServicePoint;
565
    }
566
567
    /**
568
     * @param bool $automaticSelectServicePoint
569
     * @return Label
570
     */
571
    public function setAutomaticSelectServicePoint(bool $automaticSelectServicePoint)
572
    {
573
        $this->automaticSelectServicePoint = $automaticSelectServicePoint;
574
        return $this;
575
    }
576
577
    /**
578
     * @return string
579
     */
580
    public function getServicePointId(): string
581
    {
582
        return $this->servicePointId;
583
    }
584
585
    /**
586
     * @param string $servicePointId
587
     * @return Label
588
     */
589
    public function setServicePointId(string $servicePointId)
590
    {
591
        $this->servicePointId = $servicePointId;
592
        return $this;
593
    }
594
595
    /**
596
     * @return bool
597
     */
598
    public function isSmsNotification(): bool
599
    {
600
        return $this->smsNotification;
601
    }
602
603
    /**
604
     * @param bool $smsNotification
605
     * @return Label
606
     */
607
    public function setSmsNotification(bool $smsNotification)
608
    {
609
        $this->smsNotification = $smsNotification;
610
        return $this;
611
    }
612
613
    /**
614
     * @return bool
615
     */
616
    public function isEmailNotification(): bool
617
    {
618
        return $this->emailNotification;
619
    }
620
621
    /**
622
     * @param bool $emailNotification
623
     * @return Label
624
     */
625
    public function setEmailNotification(bool $emailNotification)
626
    {
627
        $this->emailNotification = $emailNotification;
628
        return $this;
629
    }
630
631
    /**
632
     * @return string
633
     */
634
    public function getSenderName(): string
635
    {
636
        return $this->senderName;
637
    }
638
639
    /**
640
     * @param string $senderName
641
     * @return Label
642
     */
643
    public function setSenderName(string $senderName)
644
    {
645
        $this->senderName = $senderName;
646
        return $this;
647
    }
648
649
    /**
650
     * @return string
651
     */
652
    public function getSenderAddress1(): string
653
    {
654
        return $this->senderAddress1;
655
    }
656
657
    /**
658
     * @param string $senderAddress1
659
     * @return Label
660
     */
661
    public function setSenderAddress1(string $senderAddress1)
662
    {
663
        $this->senderAddress1 = $senderAddress1;
664
        return $this;
665
    }
666
667
    /**
668
     * @return string
669
     */
670
    public function getSenderAddress2(): string
671
    {
672
        return $this->senderAddress2;
673
    }
674
675
    /**
676
     * @param string $senderAddress2
677
     * @return Label
678
     */
679
    public function setSenderAddress2(string $senderAddress2)
680
    {
681
        $this->senderAddress2 = $senderAddress2;
682
        return $this;
683
    }
684
685
    /**
686
     * @return string
687
     */
688
    public function getSenderCountryCode(): string
689
    {
690
        return $this->senderCountryCode;
691
    }
692
693
    /**
694
     * @param string $senderCountryCode
695
     * @return Label
696
     */
697
    public function setSenderCountryCode(string $senderCountryCode)
698
    {
699
        $this->senderCountryCode = $senderCountryCode;
700
        return $this;
701
    }
702
703
    /**
704
     * @return string
705
     */
706
    public function getSenderZipCode(): string
707
    {
708
        return $this->senderZipCode;
709
    }
710
711
    /**
712
     * @param string $senderZipCode
713
     * @return Label
714
     */
715
    public function setSenderZipCode(string $senderZipCode)
716
    {
717
        $this->senderZipCode = $senderZipCode;
718
        return $this;
719
    }
720
721
    /**
722
     * @return string
723
     */
724
    public function getSenderCity(): string
725
    {
726
        return $this->senderCity;
727
    }
728
729
    /**
730
     * @param string $senderCity
731
     * @return Label
732
     */
733
    public function setSenderCity(string $senderCity)
734
    {
735
        $this->senderCity = $senderCity;
736
        return $this;
737
    }
738
739
    /**
740
     * @return string
741
     */
742
    public function getSenderAttention(): string
743
    {
744
        return $this->senderAttention;
745
    }
746
747
    /**
748
     * @param string $senderAttention
749
     * @return Label
750
     */
751
    public function setSenderAttention(string $senderAttention)
752
    {
753
        $this->senderAttention = $senderAttention;
754
        return $this;
755
    }
756
757
    /**
758
     * @return string
759
     */
760
    public function getSenderEmail(): string
761
    {
762
        return $this->senderEmail;
763
    }
764
765
    /**
766
     * @param string $senderEmail
767
     * @return Label
768
     */
769
    public function setSenderEmail(string $senderEmail)
770
    {
771
        $this->senderEmail = $senderEmail;
772
        return $this;
773
    }
774
775
    /**
776
     * @return string
777
     */
778
    public function getSenderTelephone(): string
779
    {
780
        return $this->senderTelephone;
781
    }
782
783
    /**
784
     * @param string $senderTelephone
785
     * @return Label
786
     */
787
    public function setSenderTelephone(string $senderTelephone)
788
    {
789
        $this->senderTelephone = $senderTelephone;
790
        return $this;
791
    }
792
793
    /**
794
     * @return string
795
     */
796
    public function getSenderMobile(): string
797
    {
798
        return $this->senderMobile;
799
    }
800
801
    /**
802
     * @param string $senderMobile
803
     * @return Label
804
     */
805
    public function setSenderMobile(string $senderMobile)
806
    {
807
        $this->senderMobile = $senderMobile;
808
        return $this;
809
    }
810
811
    /**
812
     * @return string
813
     */
814
    public function getReceiverName(): string
815
    {
816
        return $this->receiverName;
817
    }
818
819
    /**
820
     * @param string $receiverName
821
     * @return Label
822
     */
823
    public function setReceiverName(string $receiverName)
824
    {
825
        $this->receiverName = $receiverName;
826
        return $this;
827
    }
828
829
    /**
830
     * @return string
831
     */
832
    public function getReceiverAddress1(): string
833
    {
834
        return $this->receiverAddress1;
835
    }
836
837
    /**
838
     * @param string $receiverAddress1
839
     * @return Label
840
     */
841
    public function setReceiverAddress1(string $receiverAddress1)
842
    {
843
        $this->receiverAddress1 = $receiverAddress1;
844
        return $this;
845
    }
846
847
    /**
848
     * @return string
849
     */
850
    public function getReceiverAddress2(): string
851
    {
852
        return $this->receiverAddress2;
853
    }
854
855
    /**
856
     * @param string $receiverAddress2
857
     * @return Label
858
     */
859
    public function setReceiverAddress2(string $receiverAddress2)
860
    {
861
        $this->receiverAddress2 = $receiverAddress2;
862
        return $this;
863
    }
864
865
    /**
866
     * @return string
867
     */
868
    public function getReceiverCountryCode(): string
869
    {
870
        return $this->receiverCountryCode;
871
    }
872
873
    /**
874
     * @param string $receiverCountryCode
875
     * @return Label
876
     */
877
    public function setReceiverCountryCode(string $receiverCountryCode)
878
    {
879
        $this->receiverCountryCode = $receiverCountryCode;
880
        return $this;
881
    }
882
883
    /**
884
     * @return string
885
     */
886
    public function getReceiverZipCode(): string
887
    {
888
        return $this->receiverZipCode;
889
    }
890
891
    /**
892
     * @param string $receiverZipCode
893
     * @return Label
894
     */
895
    public function setReceiverZipCode(string $receiverZipCode)
896
    {
897
        $this->receiverZipCode = $receiverZipCode;
898
        return $this;
899
    }
900
901
    /**
902
     * @return string
903
     */
904
    public function getReceiverCity(): string
905
    {
906
        return $this->receiverCity;
907
    }
908
909
    /**
910
     * @param string $receiverCity
911
     * @return Label
912
     */
913
    public function setReceiverCity(string $receiverCity)
914
    {
915
        $this->receiverCity = $receiverCity;
916
        return $this;
917
    }
918
919
    /**
920
     * @return string
921
     */
922
    public function getReceiverAttention(): string
923
    {
924
        return $this->receiverAttention;
925
    }
926
927
    /**
928
     * @param string $receiverAttention
929
     * @return Label
930
     */
931
    public function setReceiverAttention(string $receiverAttention)
932
    {
933
        $this->receiverAttention = $receiverAttention;
934
        return $this;
935
    }
936
937
    /**
938
     * @return string
939
     */
940
    public function getReceiverEmail(): string
941
    {
942
        return $this->receiverEmail;
943
    }
944
945
    /**
946
     * @param string $receiverEmail
947
     * @return Label
948
     */
949
    public function setReceiverEmail(string $receiverEmail)
950
    {
951
        $this->receiverEmail = $receiverEmail;
952
        return $this;
953
    }
954
955
    /**
956
     * @return string
957
     */
958
    public function getReceiverTelephone(): string
959
    {
960
        return $this->receiverTelephone;
961
    }
962
963
    /**
964
     * @param string $receiverTelephone
965
     * @return Label
966
     */
967
    public function setReceiverTelephone(string $receiverTelephone)
968
    {
969
        $this->receiverTelephone = $receiverTelephone;
970
        return $this;
971
    }
972
973
    /**
974
     * @return string
975
     */
976
    public function getReceiverMobile(): string
977
    {
978
        return $this->receiverMobile;
979
    }
980
981
    /**
982
     * @param string $receiverMobile
983
     * @return Label
984
     */
985
    public function setReceiverMobile(string $receiverMobile)
986
    {
987
        $this->receiverMobile = $receiverMobile;
988
        return $this;
989
    }
990
991
    /**
992
     * @return string
993
     */
994
    public function getReceiverInstruction(): string
995
    {
996
        return $this->receiverInstruction;
997
    }
998
999
    /**
1000
     * @param string $receiverInstruction
1001
     * @return Label
1002
     */
1003
    public function setReceiverInstruction(string $receiverInstruction)
1004
    {
1005
        $this->receiverInstruction = $receiverInstruction;
1006
        return $this;
1007
    }
1008
}
1009