externalId = $externalId; } /** * @return null|string */ public function getShipmentConfirmationTransactionId(): ?string { return $this->shipmentConfirmationTransactionId; } /** * @param string $shipmentConfirmationTransactionId */ public function setShipmentConfirmationTransactionId(string $shipmentConfirmationTransactionId): void { $this->shipmentConfirmationTransactionId = $shipmentConfirmationTransactionId; } /** * @return bool */ public function wasShipmentConfirmationSent(): bool { return $this->shipmentConfirmationTransactionId !== null; } /** * @return string */ public function getStatus(): ?string { return $this->status; } /** * @param string $status */ public function setStatus(string $status): void { $this->status = $status; } public function canFetchShippingLabels(): bool { return $this->status === self::STATUS_SHIPPING_LABEL_ACCEPTED || (empty($this->shippingLabelData) && $this->status === self::STATUS_SHIPMENT_CONFIRMATION_SENT); } public function hasShippingLabel(): bool { return $this->shippingLabelData !== null; } public function getPurchaseOrderNumber(): string { return $this->externalId; } public function getRawJson(): ?string { return $this->raw; } public function getOrderId(): ?int { return $this->orderId; } /** * @param int|null $orderId */ public function setOrderId(?int $orderId): void { $this->orderId = $orderId; } public function isAcknowledged(): bool { return $this->acknowledged; } /** * @param bool $acknowledged */ public function setAcknowledged(bool $acknowledged): void { $this->acknowledged = $acknowledged; } public function getAcknowledgementTransactionId(): ?string { return $this->acknowledgementTransactionId; } /** * @param string|null $acknowledgementTransactionId */ public function setAcknowledgementTransactionId(?string $acknowledgementTransactionId): void { $this->acknowledgementTransactionId = $acknowledgementTransactionId; } public function isShippingLabelRequested(): bool { return $this->shippingLabelRequested; } /** * @param bool $shippingLabelRequested */ public function setShippingLabelRequested(bool $shippingLabelRequested): void { $this->shippingLabelRequested = $shippingLabelRequested; } /** * @return string */ public function getExternalId(): string { return $this->externalId; } /** * @return string|null */ public function getShippingLabelRequestTransactionId(): ?string { return $this->shippingLabelRequestTransactionId; } /** * @param string|null $shippingLabelRequestTransactionId */ public function setShippingLabelRequestTransactionId(?string $shippingLabelRequestTransactionId): void { $this->shippingLabelRequestTransactionId = $shippingLabelRequestTransactionId; } /** * @return ShippingLabel[] */ public function getShippingLabels(): array { $decodedShippingLabels = json_decode($this->shippingLabelData, true); return array_map( function (array $data) { $shippingLabel = new ShippingLabel( $data['purchase_order_number'], $data['encodedLabelData'] ); $shippingLabel->setTrackingNumber($data['tracking_number']); return $shippingLabel; }, $decodedShippingLabels ); } public function setShippingLabels(array $shippingLabels): void { $this->shippingLabelData = json_encode($shippingLabels); } public function getShippingLabelData(): ?string { return $this->shippingLabelData; } public function setShippingLabelData(string $shippingLabelData): void { $this->shippingLabelData = $shippingLabelData; } public function setRaw(string $raw): void { $this->raw = $raw; } public function getPurchaseOrder(): PurchaseOrder { return PurchaseOrder::fromPurchaseOrderResponse(json_decode($this->raw, true)); } public function getCreatedAt(): ?DateTime { return $this->createdAt; } /** * @param DateTime $createdAt */ public function setCreatedAt(DateTime $createdAt): void { $this->createdAt = $createdAt; } public function getUpdatedAt(): ?DateTime { return $this->updatedAt; } /** * @param Datetime $updatedAt */ public function setUpdatedAt(Datetime $updatedAt): void { $this->updatedAt = $updatedAt; } }