private function setOrderType($data, ApiOrderInterface $order, $patch = false)
    {
        // get OrderType
        $type = $this->getProperty($data, 'type', $order->getType());
        // set order type
        if (isset($data['type'])) {
            if (is_array($type) && isset($type['id'])) {
                // if provided as array
                $typeId = $type['id'];
            } elseif (is_numeric($type)) {
                // if is numeric
                $typeId = $type;
            } else {
                throw new OrderException('No typeid given');
            }
        } elseif (!$patch) {
            // default type is manual
            $typeId = OrderType::MANUAL;
        } else {
            // keep current type
            return;
        }

        // get entity
        $orderType = $this->getOrderTypeEntityById($typeId);
        if (!$orderType) {
            throw new EntityNotFoundException(static::$orderTypeEntityName, $typeId);
        }

        // set order type
        $order->setType($orderType);
    }