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

from __future__ import annotations
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from typing import List, Literal, Optional
from typing_extensions import NotRequired, TypedDict


V3WorkflowsSqMakeHTTPCallUpdateName = Literal["sq_make_http_call",]


V3WorkflowsSqMakeHTTPCallUpdateMethod = Literal[
    "GET",
    "POST",
    "PUT",
    "PATCH",
    "DELETE",
]


class V3WorkflowsSqMakeHTTPCallUpdateHeaderTypedDict(TypedDict):
    key: str
    value: str


class V3WorkflowsSqMakeHTTPCallUpdateHeader(BaseModel):
    key: str

    value: str


class V3WorkflowsSqMakeHTTPCallUpdateDataTypedDict(TypedDict):
    method: NotRequired[V3WorkflowsSqMakeHTTPCallUpdateMethod]
    url: NotRequired[str]
    headers: NotRequired[List[V3WorkflowsSqMakeHTTPCallUpdateHeaderTypedDict]]
    body: NotRequired[str]


class V3WorkflowsSqMakeHTTPCallUpdateData(BaseModel):
    method: Optional[V3WorkflowsSqMakeHTTPCallUpdateMethod] = None

    url: Optional[str] = None

    headers: Optional[List[V3WorkflowsSqMakeHTTPCallUpdateHeader]] = None

    body: Optional[str] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["method", "url", "headers", "body"])
        serialized = handler(self)
        m = {}

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

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

        return m


class V3WorkflowsSqMakeHTTPCallUpdateTypedDict(TypedDict):
    name: V3WorkflowsSqMakeHTTPCallUpdateName
    data: NotRequired[V3WorkflowsSqMakeHTTPCallUpdateDataTypedDict]


class V3WorkflowsSqMakeHTTPCallUpdate(BaseModel):
    name: V3WorkflowsSqMakeHTTPCallUpdateName

    data: Optional[V3WorkflowsSqMakeHTTPCallUpdateData] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["data"])
        serialized = handler(self)
        m = {}

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

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

        return m
