opennetwork / logistics

MIT License
1 stars 1 forks source link

Shipment #2

Open fabiancook opened 1 year ago

fabiancook commented 1 year ago

A shipment includes any movement of inventory external to where the inventory is normally kept.

It could also just be pickup or delivery information

It might have identifier information like a tracking code.

A shipment would have a status

type ShipmentStatus = "pending" | "processing" | "sent" | "delivered";

interface Shipment {
  shipmentId: string;
  status: ShipmentStatus;
  fromLocationId?: string;
  toLocationId?: string;
}
fabiancook commented 1 year ago

Ended up using:

import {Identifier} from "../identifier";

export type ShipmentStatus = "pending" | "processing" | "sent" | "delivered";

export interface ShipmentLocation {
  locationId?: string; // Optional fixed location
  address?: string[]; // Human-readable address
  countryCode?: string;
}

export interface ShipmentIdentifiers {
  identifiers?: Identifier[];
}

export interface ShipmentFrom extends ShipmentLocation, ShipmentIdentifiers {

}

export interface ShipmentTo extends ShipmentLocation, ShipmentIdentifiers {

}

export interface ShipmentData extends Record<string, unknown> {
  status: ShipmentStatus;
  // from is optional as you might receive with no info
  from?: ShipmentFrom;
  // A shipment would always have a destination
  to: ShipmentTo;
}

export interface Shipment extends ShipmentData {
  shipmentId: string;
  createdAt: string;
  updatedAt: string;
}