private function checkStatus($expectedStatus)
    {
        $status = $this->response->getStatusCode();
        
        if ($status != $expectedStatus) {
            throw new EndpointException("Unexpected HTTP status {$status} " . $this->response->getReasonPhrase());
        }
    }