. */ declare(strict_types=1); namespace App\Services\Spectre\Request; use App\Exceptions\ImporterErrorException; use App\Exceptions\ImporterHttpException; use App\Services\Shared\Response\Response; use App\Services\Spectre\Response\ErrorResponse; use App\Services\Spectre\Response\ListCustomersResponse; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Support\Facades\Log; /** * Class ListCustomersRequest * TODO is not yet paginated. */ class ListCustomersRequest extends Request { /** * ListCustomersRequest constructor. */ public function __construct(string $url, string $appId, string $secret) { $this->type = 'all'; $this->setBase($url); $this->setAppId($appId); $this->setSecret($secret); $this->setParameters([]); $this->setUrl('customers'); } public function get(): Response { try { $response = $this->authenticatedGet(); } catch (GuzzleException|ImporterErrorException|ImporterHttpException $e) { Log::error($e->getMessage()); // JSON thing. return new ErrorResponse($e->json ?? []); } return new ListCustomersResponse($response['data']); } public function post(): Response { // Implement post() method. } public function put(): Response { // Implement put() method. } }