protected function validatePayloadType($payloadTypeKey, $endpointTypeKey)
    {
        $metadata = $this->getStore()->getMetadataForType($endpointTypeKey);

        if (false === $metadata->isPolymorphic() && $payloadTypeKey === $endpointTypeKey) {
            return;
        }

        if (true === $metadata->isPolymorphic() && in_array($payloadTypeKey, $metadata->ownedTypes)) {
            return;
        }
        $expected = (true === $metadata->isPolymorphic()) ? implode(', ', $metadata->ownedTypes) : $endpointTypeKey;
        throw AdapterException::badRequest(sprintf('The payload "type" member does not match the API endpoint. Expected one of "%s" but received "%s"', $expected, $payloadTypeKey));
    }