"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from dub.types import BaseModel, Nullable, UNSET_SENTINEL
from dub.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from enum import Enum
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListBountySubmissionsQueryParamStatus(str, Enum):
    r"""The status of the submissions to list."""

    DRAFT = "draft"
    SUBMITTED = "submitted"
    APPROVED = "approved"
    REJECTED = "rejected"


class ListBountySubmissionsQueryParamSortBy(str, Enum):
    r"""The field to sort the submissions by."""

    COMPLETED_AT = "completedAt"
    PERFORMANCE_COUNT = "performanceCount"


class ListBountySubmissionsQueryParamSortOrder(str, Enum):
    r"""The order to sort the submissions by."""

    ASC = "asc"
    DESC = "desc"


class ListBountySubmissionsRequestTypedDict(TypedDict):
    bounty_id: str
    r"""The unique ID of the bounty on Dub. Can be found in the URL of the bounty page, prefixed with `bnty_`."""
    status: NotRequired[ListBountySubmissionsQueryParamStatus]
    r"""The status of the submissions to list."""
    group_id: NotRequired[str]
    r"""The ID of the group to list submissions for."""
    partner_id: NotRequired[str]
    r"""The ID of the partner to list submissions for."""
    sort_by: NotRequired[ListBountySubmissionsQueryParamSortBy]
    r"""The field to sort the submissions by."""
    sort_order: NotRequired[ListBountySubmissionsQueryParamSortOrder]
    r"""The order to sort the submissions by."""
    page: NotRequired[float]
    r"""The page number for pagination."""
    page_size: NotRequired[float]
    r"""The number of items per page."""


class ListBountySubmissionsRequest(BaseModel):
    bounty_id: Annotated[
        str,
        pydantic.Field(alias="bountyId"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]
    r"""The unique ID of the bounty on Dub. Can be found in the URL of the bounty page, prefixed with `bnty_`."""

    status: Annotated[
        Optional[ListBountySubmissionsQueryParamStatus],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The status of the submissions to list."""

    group_id: Annotated[
        Optional[str],
        pydantic.Field(alias="groupId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The ID of the group to list submissions for."""

    partner_id: Annotated[
        Optional[str],
        pydantic.Field(alias="partnerId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""The ID of the partner to list submissions for."""

    sort_by: Annotated[
        Optional[ListBountySubmissionsQueryParamSortBy],
        pydantic.Field(alias="sortBy"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = ListBountySubmissionsQueryParamSortBy.COMPLETED_AT
    r"""The field to sort the submissions by."""

    sort_order: Annotated[
        Optional[ListBountySubmissionsQueryParamSortOrder],
        pydantic.Field(alias="sortOrder"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = ListBountySubmissionsQueryParamSortOrder.ASC
    r"""The order to sort the submissions by."""

    page: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 1
    r"""The page number for pagination."""

    page_size: Annotated[
        Optional[float],
        pydantic.Field(alias="pageSize"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 100
    r"""The number of items per page."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "status",
                "groupId",
                "partnerId",
                "sortBy",
                "sortOrder",
                "page",
                "pageSize",
            ]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


class FilesTypedDict(TypedDict):
    url: str
    r"""The URL of the uploaded file."""
    file_name: str
    r"""The original file name."""
    size: float
    r"""The file size in bytes."""


class Files(BaseModel):
    url: str
    r"""The URL of the uploaded file."""

    file_name: Annotated[str, pydantic.Field(alias="fileName")]
    r"""The original file name."""

    size: float
    r"""The file size in bytes."""


class ListBountySubmissionsStatus(str, Enum):
    r"""The status of the submission"""

    DRAFT = "draft"
    SUBMITTED = "submitted"
    APPROVED = "approved"
    REJECTED = "rejected"


class ListBountySubmissionsResponseBodyTypedDict(TypedDict):
    id: str
    r"""The ID of the bounty submission"""
    bounty_id: str
    r"""The ID of the bounty"""
    partner_id: str
    r"""The ID of the partner"""
    description: Nullable[str]
    r"""The description of the submission"""
    urls: Nullable[List[str]]
    r"""The URLs submitted for the submission"""
    files: Nullable[List[FilesTypedDict]]
    r"""The files uploaded for the submission"""
    status: ListBountySubmissionsStatus
    r"""The status of the submission"""
    performance_count: Nullable[float]
    r"""The performance count of the submission"""
    created_at: str
    r"""The date and time the submission was created"""
    completed_at: Nullable[str]
    r"""The date and time the submission was completed"""
    reviewed_at: Nullable[str]
    r"""The date and time the submission was reviewed"""
    rejection_reason: Nullable[str]
    r"""The reason for rejecting the submission"""
    rejection_note: Nullable[str]
    r"""The note for rejecting the submission"""


class ListBountySubmissionsResponseBody(BaseModel):
    id: str
    r"""The ID of the bounty submission"""

    bounty_id: Annotated[str, pydantic.Field(alias="bountyId")]
    r"""The ID of the bounty"""

    partner_id: Annotated[str, pydantic.Field(alias="partnerId")]
    r"""The ID of the partner"""

    description: Nullable[str]
    r"""The description of the submission"""

    urls: Nullable[List[str]]
    r"""The URLs submitted for the submission"""

    files: Nullable[List[Files]]
    r"""The files uploaded for the submission"""

    status: ListBountySubmissionsStatus
    r"""The status of the submission"""

    performance_count: Annotated[
        Nullable[float], pydantic.Field(alias="performanceCount")
    ]
    r"""The performance count of the submission"""

    created_at: Annotated[str, pydantic.Field(alias="createdAt")]
    r"""The date and time the submission was created"""

    completed_at: Annotated[Nullable[str], pydantic.Field(alias="completedAt")]
    r"""The date and time the submission was completed"""

    reviewed_at: Annotated[Nullable[str], pydantic.Field(alias="reviewedAt")]
    r"""The date and time the submission was reviewed"""

    rejection_reason: Annotated[Nullable[str], pydantic.Field(alias="rejectionReason")]
    r"""The reason for rejecting the submission"""

    rejection_note: Annotated[Nullable[str], pydantic.Field(alias="rejectionNote")]
    r"""The note for rejecting the submission"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)

            if val != UNSET_SENTINEL:
                m[k] = val

        return m
