# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Union, Iterable
from typing_extensions import Literal, Required, TypeAlias, TypedDict

__all__ = [
    "InvoiceUpdateParams",
    "LineItems",
    "LineItemsCreate",
    "LineItemsCreateUser",
    "LineItemsCreateUserID",
    "LineItemsCreateUserExternalID",
    "LineItemsCreatePrice",
    "LineItemsCreateTag",
    "LineItemsDelete",
    "LineItemsUpdate",
    "LineItemsUpdatePrice",
    "LineItemsUpdateTags",
    "LineItemsUpdateTagsCreate",
    "LineItemsUpdateTagsDelete",
    "LineItemsUpdateTagsUpdate",
    "Tags",
    "TagsCreate",
    "TagsDelete",
    "TagsUpdate",
]


class InvoiceUpdateParams(TypedDict, total=False):
    current_invoice_version: Required[float]
    """The current version of the invoice.

    Must match the stored version for the update to succeed (optimistic
    concurrency).
    """

    line_items: LineItems

    tags: Tags


class LineItemsCreateUserID(TypedDict, total=False):
    id: Required[str]
    """FRAGMENT generated ID of the user"""


class LineItemsCreateUserExternalID(TypedDict, total=False):
    external_id: Required[str]
    """External ID of the user"""


LineItemsCreateUser: TypeAlias = Union[LineItemsCreateUserID, LineItemsCreateUserExternalID]


class LineItemsCreatePrice(TypedDict, total=False):
    """Price breakdown. Provide amount, or unit_price + quantity, or all three."""

    amount: str
    """Total amount in smallest currency unit.

    Required if unit_price and quantity are not provided.
    """

    quantity: int
    """Number of units for this line item."""

    unit_price: str
    """Price per unit in smallest currency unit."""


class LineItemsCreateTag(TypedDict, total=False):
    """A key-value tag pair for metadata"""

    key: Required[str]
    """Tag key.

    Must be a valid safe string (no special characters like #, /, :). Max 50
    characters.
    """

    value: Required[str]
    """Tag value.

    Must be a valid safe string (no special characters like #, /, :). Max 200
    characters.
    """


class LineItemsCreate(TypedDict, total=False):
    """Data to create a line item."""

    description: Required[str]
    """Description of the line item"""

    product_id: Required[str]
    """ID of the product/catalog item"""

    type: Required[Literal["payin", "payout"]]
    """The type of the line item"""

    user: Required[LineItemsCreateUser]
    """Identifies a user by Fragment-generated id or external_id (request body)."""

    amount: str
    """Deprecated: use price instead. Total amount in smallest currency unit."""

    currency_code: Literal[
        "ADA",
        "BTC",
        "DAI",
        "ETH",
        "SOL",
        "USDC",
        "USDT",
        "USDG",
        "EURC",
        "CADC",
        "CADT",
        "XLM",
        "UNI",
        "BCH",
        "LTC",
        "AAVE",
        "LINK",
        "MATIC",
        "PTS",
        "AED",
        "AFN",
        "ALL",
        "AMD",
        "ANG",
        "AOA",
        "ARS",
        "AUD",
        "AWG",
        "AZN",
        "BAM",
        "BBD",
        "BDT",
        "BGN",
        "BHD",
        "BIF",
        "BMD",
        "BND",
        "BOB",
        "BRL",
        "BSD",
        "BTN",
        "BWP",
        "BYR",
        "BZD",
        "CAD",
        "CDF",
        "CHF",
        "CLP",
        "CNY",
        "COP",
        "CRC",
        "CUC",
        "CUP",
        "CVE",
        "CZK",
        "DJF",
        "DKK",
        "DOP",
        "DZD",
        "EGP",
        "ERN",
        "ETB",
        "EUR",
        "FJD",
        "FKP",
        "GBP",
        "GEL",
        "GGP",
        "GHS",
        "GIP",
        "GMD",
        "GNF",
        "GTQ",
        "GYD",
        "HKD",
        "HNL",
        "HRK",
        "HTG",
        "HUF",
        "IDR",
        "ILS",
        "IMP",
        "INR",
        "IQD",
        "IRR",
        "ISK",
        "JMD",
        "JOD",
        "JPY",
        "KES",
        "KGS",
        "KHR",
        "KMF",
        "KPW",
        "KRW",
        "KWD",
        "KYD",
        "KZT",
        "LAK",
        "LBP",
        "LKR",
        "LRD",
        "LSL",
        "LYD",
        "MAD",
        "MDL",
        "MGA",
        "MKD",
        "MMK",
        "MNT",
        "MOP",
        "MUR",
        "MVR",
        "MWK",
        "MXN",
        "MYR",
        "MZN",
        "NAD",
        "NGN",
        "NIO",
        "NOK",
        "NPR",
        "NZD",
        "OMR",
        "PAB",
        "PEN",
        "PGK",
        "PHP",
        "PKR",
        "PLN",
        "PYG",
        "QAR",
        "RON",
        "RSD",
        "RUB",
        "RWF",
        "SAR",
        "SBD",
        "SCR",
        "SDG",
        "SEK",
        "SGD",
        "SHP",
        "SLL",
        "SOS",
        "SPL",
        "SRD",
        "SVC",
        "SYP",
        "STN",
        "SZL",
        "THB",
        "TJS",
        "TMT",
        "TND",
        "TOP",
        "TRY",
        "TTD",
        "TVD",
        "TWD",
        "TZS",
        "UAH",
        "UGX",
        "USD",
        "UYU",
        "UZS",
        "VEF",
        "VND",
        "VUV",
        "WST",
        "XAF",
        "XCD",
        "XOF",
        "XPF",
        "YER",
        "ZAR",
        "ZMW",
        "LOGICAL",
        "CUSTOM",
    ]
    """Currency code (ISO 4217 or crypto)"""

    price: LineItemsCreatePrice
    """Price breakdown. Provide amount, or unit_price + quantity, or all three."""

    tags: Iterable[LineItemsCreateTag]
    """Optional metadata tags for this line item"""


class LineItemsDelete(TypedDict, total=False):
    id: Required[str]
    """ID of the line item to delete"""


class LineItemsUpdatePrice(TypedDict, total=False):
    quantity: Required[int]
    """Number of units for this line item."""

    unit_price: Required[str]
    """Price per unit in smallest currency unit."""

    amount: str
    """Total amount in smallest currency unit."""


class LineItemsUpdateTagsCreate(TypedDict, total=False):
    """A key-value tag pair for metadata"""

    key: Required[str]
    """Tag key.

    Must be a valid safe string (no special characters like #, /, :). Max 50
    characters.
    """

    value: Required[str]
    """Tag value.

    Must be a valid safe string (no special characters like #, /, :). Max 200
    characters.
    """


class LineItemsUpdateTagsDelete(TypedDict, total=False):
    key: Required[str]
    """Tag key to delete"""


class LineItemsUpdateTagsUpdate(TypedDict, total=False):
    """A key-value tag pair for metadata"""

    key: Required[str]
    """Tag key.

    Must be a valid safe string (no special characters like #, /, :). Max 50
    characters.
    """

    value: Required[str]
    """Tag value.

    Must be a valid safe string (no special characters like #, /, :). Max 200
    characters.
    """


class LineItemsUpdateTags(TypedDict, total=False):
    create: Iterable[LineItemsUpdateTagsCreate]
    """Tags to add"""

    delete: Iterable[LineItemsUpdateTagsDelete]
    """Tags to remove by key"""

    update: Iterable[LineItemsUpdateTagsUpdate]
    """Tags to update.

    The key identifies the existing tag; the value is the new value.
    """


class LineItemsUpdate(TypedDict, total=False):
    """Partial update for an existing line item. All fields except id are optional."""

    id: Required[str]
    """ID of the line item to update"""

    description: str

    price: LineItemsUpdatePrice

    tags: LineItemsUpdateTags


class LineItems(TypedDict, total=False):
    create: Iterable[LineItemsCreate]
    """Line items to add to the invoice"""

    delete: Iterable[LineItemsDelete]
    """Line items to remove from the invoice"""

    update: Iterable[LineItemsUpdate]
    """Existing line items to update"""


class TagsCreate(TypedDict, total=False):
    """A key-value tag pair for metadata"""

    key: Required[str]
    """Tag key.

    Must be a valid safe string (no special characters like #, /, :). Max 50
    characters.
    """

    value: Required[str]
    """Tag value.

    Must be a valid safe string (no special characters like #, /, :). Max 200
    characters.
    """


class TagsDelete(TypedDict, total=False):
    key: Required[str]
    """Tag key to delete"""


class TagsUpdate(TypedDict, total=False):
    """A key-value tag pair for metadata"""

    key: Required[str]
    """Tag key.

    Must be a valid safe string (no special characters like #, /, :). Max 50
    characters.
    """

    value: Required[str]
    """Tag value.

    Must be a valid safe string (no special characters like #, /, :). Max 200
    characters.
    """


class Tags(TypedDict, total=False):
    create: Iterable[TagsCreate]
    """Tags to add"""

    delete: Iterable[TagsDelete]
    """Tags to remove by key"""

    update: Iterable[TagsUpdate]
    """Tags to update.

    The key identifies the existing tag; the value is the new value.
    """
