Ejemplo n.º 1
0
 public function __construct(Order $order, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $order;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = $this->getEntityDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->referenceNumber = $this->entity->getReferenceNumber();
     $this->entityDTO->externalId = $this->entity->getExternalId();
     $this->entityDTO->totalItems = $this->entity->totalItems();
     $this->entityDTO->totalQuantity = $this->entity->totalQuantity();
     $this->entityDTO->discountNames = $this->entity->getDiscountNames();
     $this->entityDTO->status = $this->dtoBuilderFactory->getOrderStatusTypeDTOBuilder($this->entity->getStatus())->build();
     if ($this->entity->getShippingAddress() !== null) {
         $this->entityDTO->shippingAddress = $this->dtoBuilderFactory->getOrderAddressDTOBuilder($this->entity->getShippingAddress())->build();
     }
     if ($this->entity->getBillingAddress() !== null) {
         $this->entityDTO->billingAddress = $this->dtoBuilderFactory->getOrderAddressDTOBuilder($this->entity->getBillingAddress())->build();
     }
     if ($this->entity->getTotal() !== null) {
         $this->entityDTO->total = $this->dtoBuilderFactory->getCartTotalDTOBuilder($this->entity->getTotal())->withAllData()->build();
     }
     if ($this->entity->getShipmentRate() !== null) {
         $this->entityDTO->shipmentRate = $this->dtoBuilderFactory->getShipmentRateDTOBuilder($this->entity->getShipmentRate())->build();
     }
     if ($this->entity->getTaxRate() !== null) {
         $this->entityDTO->taxRate = $this->dtoBuilderFactory->getTaxRateDTOBuilder($this->entity->getTaxRate())->build();
     }
     foreach ($this->entity->getShipments() as $shipment) {
         $this->entityDTO->shipments[] = $this->dtoBuilderFactory->getShipmentDTOBuilder($shipment)->build();
     }
 }
 public function handle(GetLowestShipmentRatesByDeliveryMethodQuery $query)
 {
     $request = $query->getRequest();
     $response = $query->getResponse();
     $shipmentRates = $this->shipmentGateway->getTrimmedRates($request->getToAddressDTO(), $request->getParcelDTO());
     foreach ($shipmentRates as $shipmentRate) {
         $response->addShipmentRateDTOBuilder($this->dtoBuilderFactory->getShipmentRateDTOBuilder($shipmentRate));
     }
 }
 public function __construct(ShipmentTracker $shipmentTracker, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $shipmentTracker;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = new ShipmentTrackerDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->trackingCode = $this->entity->getTrackingCode();
     $this->entityDTO->externalId = $this->entity->getExternalId();
     $this->entityDTO->carrier = $this->dtoBuilderFactory->getShipmentCarrierTypeDTOBuilder($this->entity->getCarrier())->build();
     if ($this->entity->getShipmentRate() !== null) {
         $this->entityDTO->shipmentRate = $this->dtoBuilderFactory->getShipmentRateDTOBuilder($this->entity->getShipmentRate())->build();
     }
     if ($this->entity->getShipmentLabel() !== null) {
         $this->entityDTO->shipmentLabel = $this->dtoBuilderFactory->getShipmentLabelDTOBuilder($this->entity->getShipmentLabel())->build();
     }
 }
Ejemplo n.º 4
0
 public function __construct(Cart $cart, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $cart;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = new CartDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->totalItems = $this->entity->totalItems();
     $this->entityDTO->totalQuantity = $this->entity->totalQuantity();
     $this->entityDTO->shippingWeight = $this->entity->getShippingWeight();
     $this->entityDTO->shippingWeightInPounds = $this->entity->getShippingWeightInPounds();
     if ($cart->getShipmentRate() !== null) {
         $this->entityDTO->shipmentRate = $this->dtoBuilderFactory->getShipmentRateDTOBuilder($cart->getShipmentRate())->build();
     }
     if ($cart->getShippingAddress() !== null) {
         $this->entityDTO->shippingAddress = $this->dtoBuilderFactory->getOrderAddressDTOBuilder($cart->getShippingAddress())->build();
     }
     if ($cart->getTaxRate() !== null) {
         $this->entityDTO->taxRate = $this->dtoBuilderFactory->getTaxRateDTOBuilder($cart->getTaxRate())->build();
     }
     if ($cart->getUser() !== null) {
         $this->entityDTO->user = $this->dtoBuilderFactory->getUserDTOBuilder($cart->getUser())->build();
     }
 }