@@ 97-120 (lines=24) @@ | ||
94 | * |
|
95 | * @return stdClass |
|
96 | */ |
|
97 | public function track($trackingNumber, $requestOption = 'activity') |
|
98 | { |
|
99 | $this->trackingNumber = $trackingNumber; |
|
100 | $this->requestOption = $requestOption; |
|
101 | ||
102 | $access = $this->createAccess(); |
|
103 | $request = $this->createRequest(); |
|
104 | ||
105 | $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT)); |
|
106 | $response = $this->response->getResponse(); |
|
107 | ||
108 | if (null === $response) { |
|
109 | throw new Exception('Failure (0): Unknown error', 0); |
|
110 | } |
|
111 | ||
112 | if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) { |
|
113 | throw new Exception( |
|
114 | "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}", |
|
115 | (int)$response->Response->Error->ErrorCode |
|
116 | ); |
|
117 | } else { |
|
118 | return $this->formatResponse($response); |
|
119 | } |
|
120 | } |
|
121 | ||
122 | /** |
|
123 | * Get package tracking information. |
|
@@ 132-155 (lines=24) @@ | ||
129 | * |
|
130 | * @return stdClass |
|
131 | */ |
|
132 | public function trackByReference($referenceNumber, $requestOption = 'activity') |
|
133 | { |
|
134 | $this->referenceNumber = $referenceNumber; |
|
135 | $this->requestOption = $requestOption; |
|
136 | ||
137 | $access = $this->createAccess(); |
|
138 | $request = $this->createRequest(); |
|
139 | ||
140 | $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT)); |
|
141 | $response = $this->response->getResponse(); |
|
142 | ||
143 | if (null === $response) { |
|
144 | throw new Exception('Failure (0): Unknown error', 0); |
|
145 | } |
|
146 | ||
147 | if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) { |
|
148 | throw new Exception( |
|
149 | "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}", |
|
150 | (int)$response->Response->Error->ErrorCode |
|
151 | ); |
|
152 | } else { |
|
153 | return $this->formatResponse($response); |
|
154 | } |
|
155 | } |
|
156 | ||
157 | /** |
|
158 | * Set shipper number |