Ejemplo n.º 1
0
 public function testCreate()
 {
     $carrier = $this->dummyData->getShipmentCarrierType();
     $shipmentRate = $this->dummyData->getShipmentRate();
     $shipmentLabel = $this->dummyData->getShipmentLabel();
     $shipmentTracking = new ShipmentTracker($carrier, '1Z9999999999999999');
     $shipmentTracking->setExternalId('trk_84ec7e2c5a224222a6e129ce927b936x');
     $shipmentTracking->setShipmentRate($shipmentRate);
     $shipmentTracking->setShipmentLabel($shipmentLabel);
     $this->assertEntityValid($shipmentTracking);
     $this->assertSame($carrier, $shipmentTracking->getCarrier());
     $this->assertSame('1Z9999999999999999', $shipmentTracking->getTrackingCode());
     $this->assertSame($shipmentRate, $shipmentTracking->getShipmentRate());
     $this->assertSame($shipmentLabel, $shipmentTracking->getShipmentLabel());
 }
 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.º 3
0
 public function getShipmentTracker()
 {
     $shipmentTracker = new ShipmentTracker($this->getShipmentCarrierType(), '1Z9999999999999999');
     $shipmentTracker->setExternalId('trk_' . $this->getRandomToken());
     $shipmentTracker->setShipmentRate($this->getShipmentRate(595));
     $shipmentTracker->setShipmentLabel($this->getShipmentLabel());
     return $shipmentTracker;
 }
Ejemplo n.º 4
0
 /**
  * @param string $comment
  * @param \inklabs\kommerce\EntityDTO\OrderItemQtyDTO $orderItemQtyDTO
  * @param ShipmentTracker $shipmentTracker
  * @param Order $order
  */
 private function addShipment($comment, OrderItemQtyDTO $orderItemQtyDTO, ShipmentTracker $shipmentTracker, Order $order)
 {
     $shipment = new Shipment();
     $shipmentTracker->setShipment($shipment);
     if ($comment !== '') {
         new ShipmentComment($shipment, $comment);
     }
     $this->addShipmentItemsFromOrderItems($orderItemQtyDTO, $shipment);
     $order->addShipment($shipment);
     $this->update($order);
 }
Ejemplo n.º 5
0
 private function getShipmentTrackerFromEasyPostShipment($shipment)
 {
     switch (strtolower($shipment->tracker->carrier)) {
         case 'ups':
             $carrier = ShipmentCarrierType::ups();
             break;
         case 'usps':
             $carrier = ShipmentCarrierType::usps();
             break;
         case 'fedex':
             $carrier = ShipmentCarrierType::fedex();
             break;
         default:
             $carrier = ShipmentCarrierType::unknown();
     }
     $shipmentTracker = new ShipmentTracker($carrier, $shipment->tracking_code);
     $shipmentTracker->setExternalId($shipment->id);
     $shipmentTracker->setShipmentLabel($this->getShipmentLabelFromEasyPostShipment($shipment));
     $shipmentTracker->setShipmentRate($this->getShipmentRateFromEasyPostRate($shipment->selected_rate));
     return $shipmentTracker;
 }