pub struct Shipments { /* private fields */ }Expand description
Shipment operations for order fulfillment and delivery tracking
Implementations§
Source§impl Shipments
impl Shipments
Sourcepub fn create(&self, input: CreateShipment) -> Result<Shipment>
pub fn create(&self, input: CreateShipment) -> Result<Shipment>
Create a new shipment for an order
§Example
use stateset_embedded::{Commerce, CreateShipment, CreateShipmentItem, OrderId, ShippingCarrier};
let commerce = Commerce::new("./store.db")?;
let shipment = commerce.shipments().create(CreateShipment {
order_id: OrderId::new(),
carrier: Some(ShippingCarrier::Ups),
recipient_name: "John Doe".into(),
recipient_email: Some("john@example.com".into()),
shipping_address: "456 Oak Ave, Town, ST 67890".into(),
items: Some(vec![CreateShipmentItem {
sku: "PROD-001".into(),
name: "Product A".into(),
quantity: 1,
..Default::default()
}]),
..Default::default()
})?;Sourcepub fn get_by_number(&self, shipment_number: &str) -> Result<Option<Shipment>>
pub fn get_by_number(&self, shipment_number: &str) -> Result<Option<Shipment>>
Get a shipment by shipment number
Sourcepub fn get_by_tracking(&self, tracking_number: &str) -> Result<Option<Shipment>>
pub fn get_by_tracking(&self, tracking_number: &str) -> Result<Option<Shipment>>
Find a shipment by tracking number
Sourcepub fn update(&self, id: ShipmentId, input: UpdateShipment) -> Result<Shipment>
pub fn update(&self, id: ShipmentId, input: UpdateShipment) -> Result<Shipment>
Update a shipment
Sourcepub fn list(&self, filter: ShipmentFilter) -> Result<Vec<Shipment>>
pub fn list(&self, filter: ShipmentFilter) -> Result<Vec<Shipment>>
List shipments with optional filtering
Sourcepub fn for_order(&self, order_id: OrderId) -> Result<Vec<Shipment>>
pub fn for_order(&self, order_id: OrderId) -> Result<Vec<Shipment>>
Get all shipments for an order
An order may have multiple shipments for partial fulfillment.
Sourcepub fn mark_processing(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_processing(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as processing (being prepared)
Sourcepub fn mark_ready(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_ready(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as ready to ship
Sourcepub fn ship(
&self,
id: ShipmentId,
tracking_number: Option<String>,
) -> Result<Shipment>
pub fn ship( &self, id: ShipmentId, tracking_number: Option<String>, ) -> Result<Shipment>
Ship the order (hand off to carrier)
§Example
use stateset_embedded::{Commerce, ShipmentId};
let commerce = Commerce::new("./store.db")?;
// Ship with a tracking number
let shipment = commerce.shipments().ship(
ShipmentId::new(),
Some("1Z999AA10123456784".into())
)?;
println!("Tracking URL: {:?}", shipment.tracking_url);Sourcepub fn mark_in_transit(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_in_transit(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as in transit
Sourcepub fn mark_out_for_delivery(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_out_for_delivery(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as out for delivery
Sourcepub fn mark_delivered(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_delivered(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as delivered
This records the delivery timestamp and marks the shipment complete.
Sourcepub fn mark_failed(&self, id: ShipmentId) -> Result<Shipment>
pub fn mark_failed(&self, id: ShipmentId) -> Result<Shipment>
Mark shipment as failed delivery
Sourcepub fn hold(&self, id: ShipmentId) -> Result<Shipment>
pub fn hold(&self, id: ShipmentId) -> Result<Shipment>
Put shipment on hold
Sourcepub fn cancel(&self, id: ShipmentId) -> Result<Shipment>
pub fn cancel(&self, id: ShipmentId) -> Result<Shipment>
Cancel a shipment
Sourcepub fn add_item(
&self,
shipment_id: ShipmentId,
item: CreateShipmentItem,
) -> Result<ShipmentItem>
pub fn add_item( &self, shipment_id: ShipmentId, item: CreateShipmentItem, ) -> Result<ShipmentItem>
Add an item to a shipment
Sourcepub fn remove_item(&self, item_id: Uuid) -> Result<()>
pub fn remove_item(&self, item_id: Uuid) -> Result<()>
Remove an item from a shipment
Sourcepub fn get_items(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentItem>>
pub fn get_items(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentItem>>
Get items in a shipment
Sourcepub fn add_event(
&self,
shipment_id: ShipmentId,
event: AddShipmentEvent,
) -> Result<ShipmentEvent>
pub fn add_event( &self, shipment_id: ShipmentId, event: AddShipmentEvent, ) -> Result<ShipmentEvent>
Add a tracking event to the shipment history
§Example
use stateset_embedded::{Commerce, AddShipmentEvent, ShipmentId};
let commerce = Commerce::new("./store.db")?;
commerce.shipments().add_event(ShipmentId::new(), AddShipmentEvent {
event_type: "departed_facility".into(),
location: Some("Chicago, IL".into()),
description: Some("Package departed sorting facility".into()),
event_time: None, // Uses current time
})?;Sourcepub fn get_events(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentEvent>>
pub fn get_events(&self, shipment_id: ShipmentId) -> Result<Vec<ShipmentEvent>>
Get tracking events for a shipment
Sourcepub fn count(&self, filter: ShipmentFilter) -> Result<u64>
pub fn count(&self, filter: ShipmentFilter) -> Result<u64>
Count shipments matching a filter