Skip to content

statuspro_public_api_client.domain.base

statuspro_public_api_client.domain.base

Base domain model for StatusPro entities.

This module provides the foundation for Pydantic domain models that represent business entities from the StatusPro Manufacturing ERP system.

Domain models are separate from the generated API request/response models and are optimized for: - ETL and data processing - Business logic - Data validation - JSON schema generation - Clean, ergonomic APIs

Classes

StatusProBaseModel

Bases: BaseModel

Base class for all Pydantic domain models.

Provides: - Immutability by default (frozen=True) - Automatic validation - JSON schema generation - Easy serialization for ETL - Common timestamp fields

Example
class OrderDomain(StatusProBaseModel):
    id: int
    name: str
    order_number: str | None = None

    @computed_field
    @property
    def display_name(self) -> str:
        return f"Order {self.name} (#{self.order_number})"
Functions
model_dump_for_etl()

Export to ETL-friendly format.

Removes None values and uses field aliases for cleaner output.

Returns:

  • dict[str, Any]

    Dictionary with all non-None fields

Example
order = Order(id=123, name="#1188", order_number="1188")
data = order.model_dump_for_etl()
# {"id": 123, "name": "#1188", "order_number": "1188"}
Source code in statuspro_public_api_client/domain/base.py
def model_dump_for_etl(self) -> dict[str, Any]:
    """Export to ETL-friendly format.

    Removes None values and uses field aliases for cleaner output.

    Returns:
        Dictionary with all non-None fields

    Example:
        ```python
        order = Order(id=123, name="#1188", order_number="1188")
        data = order.model_dump_for_etl()
        # {"id": 123, "name": "#1188", "order_number": "1188"}
        ```
    """
    return self.model_dump(exclude_none=True, by_alias=True)
to_dict_with_computed()

Export including computed fields.

Unlike model_dump(), this includes @computed_field properties.

Returns:

  • dict[str, Any]

    Dictionary with all fields including computed ones

Source code in statuspro_public_api_client/domain/base.py
def to_dict_with_computed(self) -> dict[str, Any]:
    """Export including computed fields.

    Unlike model_dump(), this includes @computed_field properties.

    Returns:
        Dictionary with all fields including computed ones
    """
    # Pydantic v2 automatically includes computed fields in model_dump
    return self.model_dump(mode="python", exclude_none=True)
to_warehouse_json()

Export as JSON for data warehouse.

Returns:

  • str

    JSON string with all non-None fields

Example
order = Order(id=123, name="#1188")
json_str = order.to_warehouse_json()
# '{"id":123,"name":"#1188"}'
Source code in statuspro_public_api_client/domain/base.py
def to_warehouse_json(self) -> str:
    """Export as JSON for data warehouse.

    Returns:
        JSON string with all non-None fields

    Example:
        ```python
        order = Order(id=123, name="#1188")
        json_str = order.to_warehouse_json()
        # '{"id":123,"name":"#1188"}'
        ```
    """
    return self.model_dump_json(exclude_none=True, by_alias=True)