"""Marshmallow schema for the foundation_accounts pipeline. Mirrors ows-account `V2CreateVendorSchema`: coerces int/bool fields so the request body matches server types. Empty CSV cells become JSON null (server-side fields default to None). `genre` renders into the `primary_genre` body field; `closer` renders into the `closers` list. Both are kept as plain int columns here so the runner sends real integers (not quoted strings) to ows-account. Use via: --schema pipelines.foundation_accounts.schemas:CreateVendorSchema """ from typing import Any from marshmallow import Schema, fields, pre_load class CreateVendorSchema(Schema): # type: ignore[misc] name = fields.String(required=True) owner = fields.String(required=True) company_brand = fields.String(required=True) service_tier_uuid = fields.String(required=True) payment_currency = fields.String(required=True) is_distributor = fields.Boolean(load_default=False) country = fields.String(allow_none=True, load_default=None) genre = fields.Integer(allow_none=True, load_default=None) label_summary = fields.String(allow_none=True, load_default=None) assigned_to = fields.Integer(allow_none=True, load_default=None) assigned_reviewer = fields.Integer(allow_none=True, load_default=None) product_manager = fields.Integer(allow_none=True, load_default=None) closer = fields.Integer(allow_none=True, load_default=None) @pre_load # type: ignore[misc] def _blank_to_none(self, data: dict[str, Any], **kwargs: Any) -> dict[str, Any]: return {k: (None if isinstance(v, str) and v == '' else v) for k, v in data.items()}