1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Octante\UpsAPIBundle\Library; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the UpsAPIBundle package. |
7
|
|
|
* |
8
|
|
|
* (c) Issel Guberna <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
use Ups\RequestInterface; |
15
|
|
|
use Ups\ResponseInterface; |
16
|
|
|
use Ups\Tracking; |
17
|
|
|
use Ups\Entity\Exception; |
18
|
|
|
|
19
|
|
View Code Duplication |
class TrackingWrapper |
|
|
|
|
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var \Ups\Tracking |
23
|
|
|
*/ |
24
|
|
|
private $upsTracking; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Shipping constructor. |
28
|
|
|
* |
29
|
|
|
* @param Tracking $upsTracking |
30
|
|
|
*/ |
31
|
|
|
public function __construct(Tracking $upsTracking) |
32
|
|
|
{ |
33
|
|
|
$this->upsTracking = $upsTracking; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get package tracking information. |
38
|
|
|
* |
39
|
|
|
* @param string $trackingNumber The package's tracking number. |
40
|
|
|
* @param string $requestOption Optional processing. For Mail Innovations the only valid options are Last Activity and All activity. |
41
|
|
|
* |
42
|
|
|
* @throws Exception |
43
|
|
|
* |
44
|
|
|
* @return \StdClass |
45
|
|
|
*/ |
46
|
|
|
public function track($trackingNumber, $requestOption = 'activity') |
47
|
|
|
{ |
48
|
|
|
$this->upsTracking->track($trackingNumber, $requestOption); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get package tracking information. |
53
|
|
|
* |
54
|
|
|
* @param string $referenceNumber Reference numbers can be a purchase order number, job number, etc. Reference number can be added when creating a shipment. |
55
|
|
|
* |
56
|
|
|
* @throws Exception |
57
|
|
|
* |
58
|
|
|
* @return \StdClass |
59
|
|
|
*/ |
60
|
|
|
public function trackByReference($referenceNumber, $requestOption = 'activity') |
61
|
|
|
{ |
62
|
|
|
$this->upsTracking->trackByReference($referenceNumber, $requestOption); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return RequestInterface |
67
|
|
|
*/ |
68
|
|
|
public function getRequest() |
69
|
|
|
{ |
70
|
|
|
return $this->upsTracking->getRequest(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param RequestInterface $request |
75
|
|
|
* |
76
|
|
|
* @return $this |
77
|
|
|
*/ |
78
|
|
|
public function setRequest(RequestInterface $request) |
79
|
|
|
{ |
80
|
|
|
$this->upsTracking->setRequest($request); |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return ResponseInterface |
87
|
|
|
*/ |
88
|
|
|
public function getResponse() |
89
|
|
|
{ |
90
|
|
|
return $this->upsTracking->getResponse(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param ResponseInterface $response |
95
|
|
|
* |
96
|
|
|
* @return $this |
97
|
|
|
*/ |
98
|
|
|
public function setResponse(ResponseInterface $response) |
99
|
|
|
{ |
100
|
|
|
$this->upsTracking->setResponse($response); |
101
|
|
|
|
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.