protected function serializeModel(Model $model, AdapterInterface $adapter)
    {
        $metadata = $model->getMetadata();
        $serialized = [
            'type'  => $model->getType(),
            'id'    => $model->getId(),
        ];
        if ($this->depth > 0) {
            // $this->includeResource($resource);
            return $serialized;
        }

        foreach ($metadata->getAttributes() as $key => $attrMeta) {
            if (false === $attrMeta->shouldSerialize()) {
                continue;
            }
            $value = $model->get($key);
            $serialized['attributes'][$key] = $this->serializeAttribute($value, $attrMeta);
        }

        foreach ($metadata->getEmbeds() as $key => $embeddedPropMeta) {
            if (false === $attrMeta->shouldSerialize()) {
                continue;
            }
            $value = $model->get($key);
            $serialized['attributes'][$key] = $this->serializeEmbed($value, $embeddedPropMeta);
        }

        $serialized['links'] = ['self' => $adapter->buildUrl($metadata, $model->getId())];

        $model->enableCollectionAutoInit(false);
        $this->increaseDepth();
        foreach ($metadata->getRelationships() as $key => $relMeta) {
            if (false === $relMeta->shouldSerialize()) {
                continue;
            }
            $relationship = $model->get($key);
            $serialized['relationships'][$key] = $this->serializeRelationship($model, $relationship, $relMeta, $adapter);
        }
        $this->decreaseDepth();
        $model->enableCollectionAutoInit(true);
        return $serialized;
    }