public function parse(array $entry)
    {
        if (!$this->isValidOrder($entry)) {
            return [];
        }

        $taxFree = $entry['taxFree'] || $entry['net'];

        $orderItems = array_filter(
            array_map(
                function (array $orderItem) use ($taxFree) {
                    return $this->orderItemResponseParser->parse($orderItem, $taxFree);
                },
                $entry['details']
            )
        );

        $orderItems[] = $this->getShippingCosts($entry);

        $billingAddress = $this->orderAddressParser->parse($entry['billing']);
        $shippingAddress = $this->orderAddressParser->parse($entry['shipping']);

        if (null === $billingAddress || null === $shippingAddress) {
            $this->logger->warning('could not parse address,  order: ' . $entry['number']);

            return [];
        }

        if (null === $entry['customer']) {
            $this->logger->warning('could not find customer,  order: ' . $entry['number']);

            return [];
        }

        $customer = $this->customerParser->parse($entry['customer']);

        if (null === $customer) {
            $this->logger->warning('could not parse customer,  order: ' . $entry['number']);

            return [];
        }

        $customer->setMobilePhoneNumber($billingAddress->getMobilePhoneNumber());
        $customer->setPhoneNumber($billingAddress->getPhoneNumber());

        $orderStatusIdentifier = $this->getConnectorIdentifier($entry['orderStatusId'], OrderStatus::TYPE);
        $paymentStatusIdentifier = $this->getConnectorIdentifier($entry['paymentStatusId'], PaymentStatus::TYPE);
        $paymentMethodIdentifier = $this->getConnectorIdentifier($entry['paymentId'], PaymentMethod::TYPE);
        $shippingProfileIdentifier = $this->getConnectorIdentifier($entry['dispatchId'], ShippingProfile::TYPE);
        $shopIdentifier = $this->getConnectorIdentifier($entry['languageSubShop']['id'], Shop::TYPE);

        $shopwareCurrencyIdentifier = $this->currencyDataProvider->getCurrencyIdentifierByCode($entry['currency']);
        $currencyIdentifier = $this->getConnectorIdentifier($shopwareCurrencyIdentifier, Currency::TYPE);

        $orderIdentity = $this->identityService->findOneOrCreate(
            (string) $entry['id'],
            ShopwareAdapter::NAME,
            Order::TYPE
        );

        $isMappedOrderIdentity = $this->identityService->isMappedIdentity(
            $orderIdentity->getObjectIdentifier(),
            $orderIdentity->getObjectType(),
            $orderIdentity->getAdapterName()
        );

        if ($isMappedOrderIdentity) {
            return [];
        }

        $order = new Order();
        $order->setIdentifier($orderIdentity->getObjectIdentifier());
        $order->setOrderNumber($entry['number']);
        $order->setOrderItems($orderItems);
        $order->setAttributes($this->getAttributes($entry['attribute']));
        $order->setBillingAddress($billingAddress);
        $order->setShippingAddress($shippingAddress);
        $order->setComments($this->getComments($entry));
        $order->setCustomer($customer);
        $order->setOrderTime(DateTimeImmutable::createFromMutable($entry['orderTime']));
        $order->setOrderStatusIdentifier($orderStatusIdentifier);
        $order->setPaymentStatusIdentifier($paymentStatusIdentifier);
        $order->setPaymentMethodIdentifier($paymentMethodIdentifier);
        $order->setShippingProfileIdentifier($shippingProfileIdentifier);
        $order->setCurrencyIdentifier($currencyIdentifier);
        $order->setShopIdentifier($shopIdentifier);

        return [$order];
    }
public function parse(array $entry)
    {
        if (!$this->isValidOrder($entry)) {
            return [];
        }

        $taxFree = $entry['taxFree'] || $entry['net'];

        $orderItems = array_filter(
            array_map(
                function (array $orderItem) use ($taxFree) {
                    return $this->orderItemResponseParser->parse($orderItem, $taxFree);
                },
                $entry['details']
            )
        );

        $orderItems[] = $this->getShippingCosts($entry);

        $billingAddress = $this->orderAddressParser->parse($entry['billing']);
        $shippingAddress = $this->orderAddressParser->parse($entry['shipping']);

        if (null === $billingAddress || null === $shippingAddress) {
            $this->logger->warning('could not parse address,  order: ' . $entry['number']);

            return [];
        }

        if (null === $entry['customer']) {
            $this->logger->warning('could not find customer,  order: ' . $entry['number']);

            return [];
        }

        $customer = $this->customerParser->parse($entry['customer']);

        if (null === $customer) {
            $this->logger->warning('could not parse customer,  order: ' . $entry['number']);

            return [];
        }

        $customer->setMobilePhoneNumber($billingAddress->getMobilePhoneNumber());
        $customer->setPhoneNumber($billingAddress->getPhoneNumber());

        $orderStatusIdentifier = $this->getConnectorIdentifier($entry['orderStatusId'], OrderStatus::TYPE);
        $paymentStatusIdentifier = $this->getConnectorIdentifier($entry['paymentStatusId'], PaymentStatus::TYPE);
        $paymentMethodIdentifier = $this->getConnectorIdentifier($entry['paymentId'], PaymentMethod::TYPE);
        $shippingProfileIdentifier = $this->getConnectorIdentifier($entry['dispatchId'], ShippingProfile::TYPE);
        $shopIdentifier = $this->getConnectorIdentifier($entry['languageSubShop']['id'], Shop::TYPE);

        $shopwareCurrencyIdentifier = $this->currencyDataProvider->getCurrencyIdentifierByCode($entry['currency']);
        $currencyIdentifier = $this->getConnectorIdentifier($shopwareCurrencyIdentifier, Currency::TYPE);

        $orderIdentity = $this->identityService->findOneOrCreate(
            (string) $entry['id'],
            ShopwareAdapter::NAME,
            Order::TYPE
        );

        $isMappedOrderIdentity = $this->identityService->isMappedIdentity(
            $orderIdentity->getObjectIdentifier(),
            $orderIdentity->getObjectType(),
            $orderIdentity->getAdapterName()
        );

        if ($isMappedOrderIdentity) {
            return [];
        }

        $order = new Order();
        $order->setIdentifier($orderIdentity->getObjectIdentifier());
        $order->setOrderNumber($entry['number']);
        $order->setOrderItems($orderItems);
        $order->setAttributes($this->getAttributes($entry['attribute']));
        $order->setBillingAddress($billingAddress);
        $order->setShippingAddress($shippingAddress);
        $order->setComments($this->getComments($entry));
        $order->setCustomer($customer);
        $order->setOrderTime(DateTimeImmutable::createFromMutable($entry['orderTime']));
        $order->setOrderStatusIdentifier($orderStatusIdentifier);
        $order->setPaymentStatusIdentifier($paymentStatusIdentifier);
        $order->setPaymentMethodIdentifier($paymentMethodIdentifier);
        $order->setShippingProfileIdentifier($shippingProfileIdentifier);
        $order->setCurrencyIdentifier($currencyIdentifier);
        $order->setShopIdentifier($shopIdentifier);

        return [$order];
    }
{@inheritdoc}