@@ 70-93 (lines=24) @@ | ||
67 | * |
|
68 | * @return stdClass |
|
69 | */ |
|
70 | public function track($trackingNumber, $requestOption = 'activity') |
|
71 | { |
|
72 | $this->trackingNumber = $trackingNumber; |
|
73 | $this->requestOption = $requestOption; |
|
74 | ||
75 | $access = $this->createAccess(); |
|
76 | $request = $this->createRequest(); |
|
77 | ||
78 | $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT)); |
|
79 | $response = $this->response->getResponse(); |
|
80 | ||
81 | if (null === $response) { |
|
82 | throw new Exception('Failure (0): Unknown error', 0); |
|
83 | } |
|
84 | ||
85 | if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) { |
|
86 | throw new Exception( |
|
87 | "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}", |
|
88 | (int)$response->Response->Error->ErrorCode |
|
89 | ); |
|
90 | } else { |
|
91 | return $this->formatResponse($response); |
|
92 | } |
|
93 | } |
|
94 | ||
95 | /** |
|
96 | * Get package tracking information. |
|
@@ 103-126 (lines=24) @@ | ||
100 | * |
|
101 | * @return stdClass |
|
102 | */ |
|
103 | public function trackByReference($referenceNumber, $requestOption = 'activity') |
|
104 | { |
|
105 | $this->referenceNumber = $referenceNumber; |
|
106 | $this->requestOption = $requestOption; |
|
107 | ||
108 | $access = $this->createAccess(); |
|
109 | $request = $this->createRequest(); |
|
110 | ||
111 | $this->response = $this->getRequest()->request($access, $request, $this->compileEndpointUrl(self::ENDPOINT)); |
|
112 | $response = $this->response->getResponse(); |
|
113 | ||
114 | if (null === $response) { |
|
115 | throw new Exception('Failure (0): Unknown error', 0); |
|
116 | } |
|
117 | ||
118 | if ($response instanceof SimpleXMLElement && $response->Response->ResponseStatusCode == 0) { |
|
119 | throw new Exception( |
|
120 | "Failure ({$response->Response->Error->ErrorSeverity}): {$response->Response->Error->ErrorDescription}", |
|
121 | (int)$response->Response->Error->ErrorCode |
|
122 | ); |
|
123 | } else { |
|
124 | return $this->formatResponse($response); |
|
125 | } |
|
126 | } |
|
127 | ||
128 | /** |
|
129 | * Check if tracking number is for mail innovations. |