protected function deserialize(array $document, $record = null): ResourceObject
    {
        $data = $document['data'] ?? [];

        if (!is_array($data) || empty($data)) {
            throw new \InvalidArgumentException('Expecting a JSON API document with a data member.');
        }

        return ResourceObject::create($data);
    }