1
|
|
|
<?php namespace SimpleUPS\Track\SmallPackage; |
2
|
|
|
|
3
|
|
|
use \SimpleUPS\Api\MissingParameterException; |
4
|
|
|
use \SimpleUPS\UPS; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @internal |
8
|
|
|
*/ |
9
|
|
|
class Request extends \SimpleUPS\Track\Request |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
private |
13
|
|
|
/* @var string $trackingNumber */ |
14
|
|
|
$trackingNumber; |
15
|
|
|
|
16
|
|
|
public function __construct($debug = null) |
17
|
|
|
{ |
18
|
|
|
parent::__construct($debug); |
19
|
|
|
|
20
|
|
|
$this->responseClass = '\SimpleUPS\Track\SmallPackage\Response'; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Build the validate address request |
25
|
|
|
* @return string |
26
|
|
|
* @throws \SimpleUPS\Api\MissingParameterException |
27
|
|
|
*/ |
28
|
|
|
public function buildXml() |
29
|
|
|
{ |
30
|
|
|
if ($this->getTrackingNumber() === null) { |
31
|
|
|
throw new MissingParameterException('Tracking lookup requires either a tracking number'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$dom = new \DomDocument('1.0'); |
35
|
|
|
$dom->formatOutput = $this->getDebug(); |
36
|
|
|
$dom->appendChild($trackingRequest = $dom->createElement('TrackRequest')); |
37
|
|
|
$addressRequestLang = $dom->createAttribute('xml:lang'); |
38
|
|
|
$addressRequestLang->value = parent::getXmlLang(); |
|
|
|
|
39
|
|
|
$trackingRequest->appendChild($request = $dom->createElement('Request')); |
40
|
|
|
$request->appendChild($transactionReference = $dom->createElement('TransactionReference')); |
41
|
|
|
$transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext())); |
42
|
|
|
|
43
|
|
|
$request->appendChild($dom->createElement('RequestAction', 'Track')); |
44
|
|
|
$request->appendChild($dom->createElement('RequestOption', '1')); |
45
|
|
|
|
46
|
|
|
$trackingRequest->appendChild($shipmentType = $dom->createElement('ShipmentType')); |
47
|
|
|
$shipmentType->appendChild( |
48
|
|
|
$shipmentType = $dom->createElement('Code', \SimpleUPS\Track\Request::TYPE_SMALL_PACKAGE) |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
if ($this->getTrackingNumber() !== null) { |
52
|
|
|
$trackingRequest->appendChild($dom->createElement('TrackingNumber', $this->getTrackingNumber())); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$xml = parent::buildAuthenticationXml() . $dom->saveXML(); |
|
|
|
|
56
|
|
|
|
57
|
|
|
return $xml; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param string $trackingNumber |
62
|
|
|
*/ |
63
|
|
|
public function setTrackingNumber($trackingNumber) |
64
|
|
|
{ |
65
|
|
|
$this->trackingNumber = $trackingNumber; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getTrackingNumber() |
72
|
|
|
{ |
73
|
|
|
return $this->trackingNumber; |
74
|
|
|
} |
75
|
|
|
} |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.