| @@ 441-454 (lines=14) @@ | ||
| 438 | * |
|
| 439 | * @return SMSAResponse |
|
| 440 | */ |
|
| 441 | protected function successResponse($type, $payload, $data): SMSAResponse |
|
| 442 | { |
|
| 443 | $response = new SMSAResponse( |
|
| 444 | true, |
|
| 445 | $data, |
|
| 446 | null, |
|
| 447 | $type, |
|
| 448 | $payload, |
|
| 449 | $this->service->getLastRequest(true), |
|
| 450 | $this->service->getLastResponse(true) |
|
| 451 | ); |
|
| 452 | ||
| 453 | return $response; |
|
| 454 | } |
|
| 455 | ||
| 456 | /** |
|
| 457 | * Send a Response with failed request. |
|
| @@ 499-516 (lines=18) @@ | ||
| 496 | * |
|
| 497 | * @return SMSAResponse |
|
| 498 | */ |
|
| 499 | protected function failedResponse($type, $payload, $error) |
|
| 500 | { |
|
| 501 | $response = new SMSAResponse( |
|
| 502 | false, |
|
| 503 | null, |
|
| 504 | $error, |
|
| 505 | $type, |
|
| 506 | $payload, |
|
| 507 | $this->service->getLastRequest(true), |
|
| 508 | $this->service->getLastResponse(true) |
|
| 509 | ); |
|
| 510 | ||
| 511 | if ($this->shouldUseExceptions()) { |
|
| 512 | throw new FailedResponse($response, $error); |
|
| 513 | } |
|
| 514 | ||
| 515 | return $response; |
|
| 516 | } |
|
| 517 | ||
| 518 | protected function shouldUseExceptions() |
|
| 519 | { |
|