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

from __future__ import annotations
import httpx
from ship24.errors import Ship24Error
from ship24.models import (
    bulk_create_trackers_response as models_bulk_create_trackers_response,
)
from ship24.types import BaseModel, OptionalNullable, UNSET
from typing import List, Optional


class BulkCreateTrackersResponseErrorData(BaseModel):
    status: models_bulk_create_trackers_response.Status
    r"""Status of the bulk creation.

    `success`: All trackers were created successfully or already existed. (Status code 200)

    `partial`: Operation contains both successes and errors. (Status code 207)

    `error`: All creations failed or error on request level. (Status codes 400, 403)
    """

    summary: OptionalNullable[models_bulk_create_trackers_response.Summary] = UNSET
    r"""Summary of the bulk creation. Null if status is `error`."""

    data: OptionalNullable[
        List[models_bulk_create_trackers_response.BulkCreateTrackersResponseData]
    ] = UNSET
    r"""Detailed information about each tracker creation. Null if status is `error`."""

    error: OptionalNullable[
        models_bulk_create_trackers_response.BulkCreateTrackersResponseError
    ] = UNSET
    r"""[Error details](https://docs.ship24.com/errors#error-response-format) of the request. Null if `status` is not `error`."""


class BulkCreateTrackersResponseError(Ship24Error):
    data: BulkCreateTrackersResponseErrorData

    def __init__(
        self,
        data: BulkCreateTrackersResponseErrorData,
        raw_response: httpx.Response,
        body: Optional[str] = None,
    ):
        fallback = body or raw_response.text
        message = str(data.error.message) if data.error else fallback
        super().__init__(message, raw_response, body)
        self.data = data
