fulfillment

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inventory

type Inventory struct {
	ID                string         `gorm:"primaryKey" json:"id"`
	ProductID         string         `gorm:"uniqueIndex;not null" json:"product_id"`
	AvailableQuantity int            `gorm:"not null" json:"available_quantity"`
	CreatedAt         time.Time      `json:"created_at"`
	UpdatedAt         time.Time      `json:"updated_at"`
	DeletedAt         gorm.DeletedAt `gorm:"index" json:"-"`
}

Inventory represents the available stock for a product.

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements the mdk.Module interface for Fulfillment.

func NewModule

func NewModule() *Module

func (*Module) CreateShipment

func (m *Module) CreateShipment(ctx context.Context, input any) (any, error)

func (*Module) CreateShipmentStep

func (m *Module) CreateShipmentStep(sCtx mdk.StepContext) mdk.StepResult

CreateShipmentStep wraps CreateShipment to mdk.StepHandler.

func (*Module) FieldResolvers

func (m *Module) FieldResolvers() map[string]any

func (*Module) GetInventory

func (m *Module) GetInventory(ctx context.Context, productID string) (*Inventory, error)

func (*Module) GetShipment

func (m *Module) GetShipment(ctx context.Context, id string) (*Shipment, error)

func (*Module) GetShipmentByOrder

func (m *Module) GetShipmentByOrder(ctx context.Context, orderID string) (*Shipment, error)

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init(ctx context.Context, rt mdk.Runtime) error

func (*Module) Models

func (m *Module) Models() []any

func (*Module) Mutations

func (m *Module) Mutations() map[string]any

func (*Module) Queries

func (m *Module) Queries() map[string]any

func (*Module) ReleaseInventory

func (m *Module) ReleaseInventory(ctx context.Context, input any) (any, error)

func (*Module) ReleaseInventoryStep

func (m *Module) ReleaseInventoryStep(sCtx mdk.StepContext) mdk.StepResult

ReleaseInventoryStep wraps ReleaseInventory to mdk.StepHandler.

func (*Module) Repo

func (m *Module) Repo() *Repository

func (*Module) ReserveInventory

func (m *Module) ReserveInventory(ctx context.Context, input any) (any, error)

func (*Module) ReserveInventoryStep

func (m *Module) ReserveInventoryStep(sCtx mdk.StepContext) mdk.StepResult

ReserveInventoryStep wraps ReserveInventory to mdk.StepHandler.

func (*Module) Routes

func (m *Module) Routes() []mdk.Route

func (*Module) ShipOrder

func (m *Module) ShipOrder(ctx context.Context, input any) (any, error)

ShipOrder simulates shipping the order (updates status to SHIPPED and adds tracking number).

func (*Module) ShipOrderStep

func (m *Module) ShipOrderStep(sCtx mdk.StepContext) mdk.StepResult

ShipOrderStep wraps ShipOrder to mdk.StepHandler.

func (*Module) Shutdown

func (m *Module) Shutdown(ctx context.Context) error

func (*Module) UpdateShipmentStatus

func (m *Module) UpdateShipmentStatus(ctx context.Context, shipmentID string, trackingNumber *string, carrier *string) (*Shipment, error)

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(database *gorm.DB) *Repository

func (*Repository) GetInventoryByProductID

func (r *Repository) GetInventoryByProductID(ctx context.Context, productID string) (*Inventory, error)

GetInventoryByProductID retrieves inventory for a product.

func (*Repository) GetShipment

func (r *Repository) GetShipment(ctx context.Context, id string) (*Shipment, error)

GetShipment retrieves a shipment by ID.

func (*Repository) GetShipmentByOrderID

func (r *Repository) GetShipmentByOrderID(ctx context.Context, orderID string) (*Shipment, error)

GetShipmentByOrderID retrieves a shipment by its order ID.

func (*Repository) SaveInventory

func (r *Repository) SaveInventory(ctx context.Context, inv *Inventory) error

SaveInventory saves an inventory record.

func (*Repository) SaveShipment

func (r *Repository) SaveShipment(ctx context.Context, s *Shipment) error

SaveShipment saves a shipment record.

type Shipment

type Shipment struct {
	ID             string         `gorm:"primaryKey" json:"id"`
	OrderID        string         `gorm:"uniqueIndex;not null" json:"order_id"`
	Status         ShipmentStatus `gorm:"not null" json:"status"`
	TrackingNumber string         `json:"tracking_number"`
	Carrier        string         `json:"carrier"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	DeletedAt      gorm.DeletedAt `gorm:"index" json:"-"`
}

Shipment represents the logistics fulfillment of an order.

type ShipmentStatus

type ShipmentStatus string
const (
	ShipmentPending   ShipmentStatus = "PENDING"
	ShipmentShipped   ShipmentStatus = "SHIPPED"
	ShipmentDelivered ShipmentStatus = "DELIVERED"
	ShipmentCancelled ShipmentStatus = "CANCELLED"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL