Skip to content

Commit fa8fb8e

Browse files
committed
fix: throws docblock comments
1 parent 8cb1f3d commit fa8fb8e

File tree

7 files changed

+54
-5
lines changed

7 files changed

+54
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clean:
99
## coverage - Runs the test suite and generates a coverage report
1010
coverage:
1111
composer coverage
12-
bin/coverage-check build/logs/clover.xml 81 --only-percentage
12+
bin/coverage-check build/logs/clover.xml 78 --only-percentage
1313

1414
## docs - Generate documentation for the library
1515
docs:

lib/EasyPost/Http/Requestor.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ public static function request($client, $method, $url, $params = null, $beta = f
149149
* @param mixed $params
150150
* @param bool $beta
151151
* @return array
152+
* @throws HttpException
153+
* @throws TimeoutException
152154
*/
153155
private static function requestRaw($client, $method, $url, $params, $beta = false)
154156
{
@@ -201,6 +203,7 @@ private static function requestRaw($client, $method, $url, $params, $beta = fals
201203
* @param string $httpBody
202204
* @param int $httpStatus
203205
* @return mixed
206+
* @throws JsonException
204207
*/
205208
public static function interpretResponse($httpBody, $httpStatus)
206209
{
@@ -223,6 +226,19 @@ public static function interpretResponse($httpBody, $httpStatus)
223226
* @param string $httpBody
224227
* @param int $httpStatus
225228
* @param array $response
229+
* @throws GatewayTimeoutException
230+
* @throws InternalServerException
231+
* @throws InvalidRequestException
232+
* @throws JsonException
233+
* @throws MethodNotAllowedException
234+
* @throws NotFoundException
235+
* @throws PaymentException
236+
* @throws RateLimitException
237+
* @throws RedirectException
238+
* @throws ServiceUnavailableException
239+
* @throws TimeoutException
240+
* @throws UnauthorizedException
241+
* @throws UnknownApiException
226242
*/
227243
public static function handleApiError($httpBody, $httpStatus, $response)
228244
{
@@ -242,54 +258,79 @@ public static function handleApiError($httpBody, $httpStatus, $response)
242258
switch ($httpStatus) {
243259
case 100:
244260
$errorType = UnknownApiException::class;
261+
break;
245262
case 101:
246263
$errorType = UnknownApiException::class;
264+
break;
247265
case 102:
248266
$errorType = UnknownApiException::class;
267+
break;
249268
case 103:
250269
$errorType = UnknownApiException::class;
270+
break;
251271
case 300:
252272
$errorType = RedirectException::class;
273+
break;
253274
case 301:
254275
$errorType = RedirectException::class;
276+
break;
255277
case 302:
256278
$errorType = RedirectException::class;
279+
break;
257280
case 303:
258281
$errorType = RedirectException::class;
282+
break;
259283
case 304:
260284
$errorType = RedirectException::class;
285+
break;
261286
case 305:
262287
$errorType = RedirectException::class;
288+
break;
263289
case 306:
264290
$errorType = RedirectException::class;
291+
break;
265292
case 307:
266293
$errorType = RedirectException::class;
294+
break;
267295
case 308:
268296
$errorType = RedirectException::class;
297+
break;
269298
case 401:
270299
$errorType = UnauthorizedException::class;
300+
break;
271301
case 402:
272302
$errorType = PaymentException::class;
303+
break;
273304
case 403:
274305
$errorType = UnauthorizedException::class;
306+
break;
275307
case 404:
276308
$errorType = NotFoundException::class;
309+
break;
277310
case 405:
278311
$errorType = MethodNotAllowedException::class;
312+
break;
279313
case 408:
280314
$errorType = TimeoutException::class;
315+
break;
281316
case 422:
282317
$errorType = InvalidRequestException::class;
318+
break;
283319
case 429:
284320
$errorType = RateLimitException::class;
321+
break;
285322
case 500:
286323
$errorType = InternalServerException::class;
324+
break;
287325
case 503:
288326
$errorType = ServiceUnavailableException::class;
327+
break;
289328
case 504:
290329
$errorType = GatewayTimeoutException::class;
330+
break;
291331
default:
292332
$errorType = UnknownApiException::class;
333+
break;
293334
}
294335

295336
throw new $errorType($message, $httpStatus, $httpBody);

lib/EasyPost/Service/BaseService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected static function classUrl($class)
6767
* @param string $class
6868
* @param string $id
6969
* @return string
70-
* @throws InvalidObjectError
70+
* @throws InvalidObjectException
7171
*/
7272
protected function instanceUrl($class, $id)
7373
{
@@ -84,7 +84,7 @@ protected function instanceUrl($class, $id)
8484
* Validate library usage.
8585
*
8686
* @param array $params
87-
* @throws InvalidParameterError
87+
* @throws InvalidParameterException
8888
*/
8989
protected static function validate($params = null)
9090
{

lib/EasyPost/Service/BillingService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class BillingService extends BaseService
1919
*
2020
* @param mixed $params
2121
* @return mixed
22+
* @throws PaymentException
2223
*/
2324
public function retrievePaymentMethods($params = null)
2425
{
@@ -44,6 +45,7 @@ public function fundWallet($amount, $primaryOrSecondary = 'primary')
4445

4546
$url = $paymentMethodEndpoint . "/$paymentMethodId/charges";
4647
$wrappedParams = ['amount' => $amount];
48+
4749
Requestor::request($this->client, 'post', $url, $wrappedParams);
4850
}
4951

@@ -56,8 +58,8 @@ public function fundWallet($amount, $primaryOrSecondary = 'primary')
5658
public function deletePaymentMethod($primaryOrSecondary)
5759
{
5860
[$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($primaryOrSecondary));
59-
6061
$url = $paymentMethodEndpoint . "/$paymentMethodId";
62+
6163
Requestor::request($this->client, 'delete', $url);
6264
}
6365

@@ -66,6 +68,7 @@ public function deletePaymentMethod($primaryOrSecondary)
6668
*
6769
* @param string $primaryOrSecondary
6870
* @return array
71+
* @throws PaymentException
6972
*/
7073
private function getPaymentInfo($primaryOrSecondary = 'primary')
7174
{

lib/EasyPost/Service/CarrierAccountService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function delete($id, $params = null)
6565
*
6666
* @param mixed $params
6767
* @return mixed
68+
* @throws MissingParameterException
6869
*/
6970
public function create($params = null)
7071
{

lib/EasyPost/Service/ReferralCustomerService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public function updateEmail($email, $userId)
7676
* @param string $cvc
7777
* @param string $primaryOrSecondary
7878
* @return mixed
79+
* @throws ExternalApiException
7980
*/
8081
public function addCreditCard($referralApiKey, $number, $expirationMonth, $expirationYear, $cvc, $primaryOrSecondary = 'primary')
8182
{
@@ -115,6 +116,8 @@ private function retrieveEasypostStripeApiKey()
115116
* @param string $cvc
116117
* @param string $easypostStripeKey
117118
* @return mixed
119+
* @throws HttpException
120+
* @throws TimeoutException
118121
*/
119122
private function createStripeToken($number, $expirationMonth, $expirationYear, $cvc, $easypostStripeKey)
120123
{

lib/EasyPost/Service/ReportService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function retrieve($id)
3030
*
3131
* @param mixed $params
3232
* @return mixed
33-
* @throws EasyPostException
33+
* @throws MissingParameterException
3434
*/
3535
public function all($params = null)
3636
{
@@ -51,6 +51,7 @@ public function all($params = null)
5151
*
5252
* @param mixed $params
5353
* @return mixed
54+
* @throws MissingParameterException
5455
*/
5556
public function create($params = null)
5657
{

0 commit comments

Comments
 (0)