public function parse(array $entry)
    {
        $identity = $this->identityService->findOneBy([
            'adapterIdentifier' => (string) $entry['id'],
            'adapterName' => PlentymarketsAdapter::NAME,
            'objectType' => Order::TYPE,
        ]);

        if (!$identity) {
            return [];
        }

        $shopIdentity = $this->identityService->findOneBy([
            'adapterIdentifier' => (string) $entry['plentyId'],
            'adapterName' => PlentymarketsAdapter::NAME,
            'objectType' => Shop::TYPE,
        ]);

        if (null === $shopIdentity) {
            $this->logger->notice('unknown shop');

            return [];
        }

        $isMappedShopIdentity = $this->identityService->isMappedIdentity(
            $shopIdentity->getObjectIdentifier(),
            $shopIdentity->getObjectType(),
            $shopIdentity->getAdapterName()
        );

        if (!$isMappedShopIdentity) {
            return [];
        }

        $orderNumber = $this->getOrdernumber($entry);
        if (null === $orderNumber) {
            return [];
        }

        $shippingProfileIdentity = $this->getShippingProfileIdentity($entry);
        if (null === $shippingProfileIdentity) {
            $this->logger->notice('no shipping profile found', ['entry' => $entry]);

            return [];
        }

        $currencyIdentity = $this->getCurrencyIdentity($entry);
        if (null === $currencyIdentity) {
            $this->logger->notice('no currency found', ['entry' => $entry]);

            return [];
        }

        $paymentMethodIdentity = $this->getPaymentMethodIdentity($entry);
        if (null === $paymentMethodIdentity) {
            $this->logger->notice('no payment method found', ['entry' => $entry]);

            return [];
        }

        $paymentStatusIdentity = $this->getPaymentStatusIdentity($entry);
        if (null === $paymentStatusIdentity) {
            $this->logger->notice('no payment status found', ['entry' => $entry]);

            return [];
        }

        $oderStatusIdentity = $this->getOrderStatusIdentity($entry);
        if (null === $oderStatusIdentity) {
            $this->logger->notice('no order status found', ['entry' => $entry]);

            return [];
        }

        $entry['customerData'] = $this->getCustomerData($entry);
        if (empty($entry['customerData'])) {
            $this->logger->notice('no customer found', ['entry' => $entry]);

            return [];
        }

        $entry['billingAddressData'] = $this->getBillingAddressData($entry);
        if (empty($entry['billingAddressData'])) {
            $this->logger->notice('no billing address found', ['entry' => $entry]);

            return [];
        }

        $entry['shippingAddressData'] = $this->getShippingAddressData($entry);
        if (empty($entry['shippingAddressData'])) {
            $this->logger->notice('no shipping address found', ['entry' => $entry]);

            return [];
        }

        $customer = $this->getCustomer($entry);
        if (null === $customer) {
            $this->logger->notice('no customer found', ['entry' => $entry]);

            return [];
        }

        $order = new Order();
        $order->setIdentifier($identity->getObjectIdentifier());
        $order->setOrderNumber($orderNumber);
        $order->setOrderTime($this->getOrderTime($entry));
        $order->setCustomer($customer);
        $order->setOrderItems($this->getOrderItems($entry));
        $order->setShopIdentifier($shopIdentity->getObjectIdentifier());
        $order->setCurrencyIdentifier($currencyIdentity->getObjectIdentifier());
        $order->setOrderStatusIdentifier($oderStatusIdentity->getObjectIdentifier());
        $order->setPaymentStatusIdentifier($paymentStatusIdentity->getObjectIdentifier());
        $order->setPaymentMethodIdentifier($paymentMethodIdentity->getObjectIdentifier());
        $order->setShippingProfileIdentifier($shippingProfileIdentity->getObjectIdentifier());
        $order->setComments($this->getComments($entry));
        $order->setPackages($this->getPackages($entry));
        $order->setAttributes([]);

        $billingAddress = $this->getBillingAddress($entry);
        if (null !== $billingAddress) {
            $order->setBillingAddress($billingAddress);
        }

        $shippingAddress = $this->getShippingAddress($entry);
        if (null !== $shippingAddress) {
            $order->setShippingAddress($shippingAddress);
        }

        return [$order];
    }
public function parse(array $entry)
    {
        $identity = $this->identityService->findOneBy([
            'adapterIdentifier' => (string) $entry['id'],
            'adapterName' => PlentymarketsAdapter::NAME,
            'objectType' => Order::TYPE,
        ]);

        if (!$identity) {
            return [];
        }

        $shopIdentity = $this->identityService->findOneBy([
            'adapterIdentifier' => (string) $entry['plentyId'],
            'adapterName' => PlentymarketsAdapter::NAME,
            'objectType' => Shop::TYPE,
        ]);

        if (null === $shopIdentity) {
            $this->logger->notice('unknown shop');

            return [];
        }

        $isMappedShopIdentity = $this->identityService->isMappedIdentity(
            $shopIdentity->getObjectIdentifier(),
            $shopIdentity->getObjectType(),
            $shopIdentity->getAdapterName()
        );

        if (!$isMappedShopIdentity) {
            return [];
        }

        $orderNumber = $this->getOrdernumber($entry);
        if (null === $orderNumber) {
            return [];
        }

        $shippingProfileIdentity = $this->getShippingProfileIdentity($entry);
        if (null === $shippingProfileIdentity) {
            $this->logger->notice('no shipping profile found', ['entry' => $entry]);

            return [];
        }

        $currencyIdentity = $this->getCurrencyIdentity($entry);
        if (null === $currencyIdentity) {
            $this->logger->notice('no currency found', ['entry' => $entry]);

            return [];
        }

        $paymentMethodIdentity = $this->getPaymentMethodIdentity($entry);
        if (null === $paymentMethodIdentity) {
            $this->logger->notice('no payment method found', ['entry' => $entry]);

            return [];
        }

        $paymentStatusIdentity = $this->getPaymentStatusIdentity($entry);
        if (null === $paymentStatusIdentity) {
            $this->logger->notice('no payment status found', ['entry' => $entry]);

            return [];
        }

        $oderStatusIdentity = $this->getOrderStatusIdentity($entry);
        if (null === $oderStatusIdentity) {
            $this->logger->notice('no order status found', ['entry' => $entry]);

            return [];
        }

        $entry['customerData'] = $this->getCustomerData($entry);
        if (empty($entry['customerData'])) {
            $this->logger->notice('no customer found', ['entry' => $entry]);

            return [];
        }

        $entry['billingAddressData'] = $this->getBillingAddressData($entry);
        if (empty($entry['billingAddressData'])) {
            $this->logger->notice('no billing address found', ['entry' => $entry]);

            return [];
        }

        $entry['shippingAddressData'] = $this->getShippingAddressData($entry);
        if (empty($entry['shippingAddressData'])) {
            $this->logger->notice('no shipping address found', ['entry' => $entry]);

            return [];
        }

        $customer = $this->getCustomer($entry);
        if (null === $customer) {
            $this->logger->notice('no customer found', ['entry' => $entry]);

            return [];
        }

        $order = new Order();
        $order->setIdentifier($identity->getObjectIdentifier());
        $order->setOrderNumber($orderNumber);
        $order->setOrderTime($this->getOrderTime($entry));
        $order->setCustomer($customer);
        $order->setOrderItems($this->getOrderItems($entry));
        $order->setShopIdentifier($shopIdentity->getObjectIdentifier());
        $order->setCurrencyIdentifier($currencyIdentity->getObjectIdentifier());
        $order->setOrderStatusIdentifier($oderStatusIdentity->getObjectIdentifier());
        $order->setPaymentStatusIdentifier($paymentStatusIdentity->getObjectIdentifier());
        $order->setPaymentMethodIdentifier($paymentMethodIdentity->getObjectIdentifier());
        $order->setShippingProfileIdentifier($shippingProfileIdentity->getObjectIdentifier());
        $order->setComments($this->getComments($entry));
        $order->setPackages($this->getPackages($entry));
        $order->setAttributes([]);

        $billingAddress = $this->getBillingAddress($entry);
        if (null !== $billingAddress) {
            $order->setBillingAddress($billingAddress);
        }

        $shippingAddress = $this->getShippingAddress($entry);
        if (null !== $shippingAddress) {
            $order->setShippingAddress($shippingAddress);
        }

        return [$order];
    }
{@inheritdoc}