# coding: utf-8

"""
    CustomerBillingService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.billing.insertion_order_additional_field import InsertionOrderAdditionalField
from openapi_client.models.billing.order_by import OrderBy
from openapi_client.models.billing.paging import Paging
from openapi_client.models.billing.predicate import Predicate
from typing_extensions import Self

class SearchInsertionOrdersRequest(BaseModel):
    """
    SearchInsertionOrdersRequest
    """ # noqa: E501
    predicates: Optional[List[Optional[Predicate]]] = Field(default=None, alias="Predicates")
    ordering: Optional[List[Optional[OrderBy]]] = Field(default=None, alias="Ordering")
    page_info: Optional[Paging] = Field(default=None, alias="PageInfo")
    return_additional_fields: Optional[InsertionOrderAdditionalField] = Field(default=None, alias="ReturnAdditionalFields")
    __properties: ClassVar[List[str]] = ["Predicates", "Ordering", "PageInfo", "ReturnAdditionalFields"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in predicates (list)
        _items = []
        if self.predicates:
            for _item_predicates in self.predicates:
                if _item_predicates:
                    _items.append(_item_predicates.to_dict())
            _dict['Predicates'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in ordering (list)
        _items = []
        if self.ordering:
            for _item_ordering in self.ordering:
                if _item_ordering:
                    _items.append(_item_ordering.to_dict())
            _dict['Ordering'] = _items
        # override the default output from pydantic by calling `to_dict()` of page_info
        if self.page_info:
            _dict['PageInfo'] = self.page_info.to_dict()
        # set to None if predicates (nullable) is None
        # and model_fields_set contains the field
        if self.predicates is None and "predicates" in self.model_fields_set:
            _dict['Predicates'] = None

        # set to None if ordering (nullable) is None
        # and model_fields_set contains the field
        if self.ordering is None and "ordering" in self.model_fields_set:
            _dict['Ordering'] = None

        # set to None if page_info (nullable) is None
        # and model_fields_set contains the field
        if self.page_info is None and "page_info" in self.model_fields_set:
            _dict['PageInfo'] = None

        # set to None if return_additional_fields (nullable) is None
        # and model_fields_set contains the field
        if self.return_additional_fields is None and "return_additional_fields" in self.model_fields_set:
            _dict['ReturnAdditionalFields'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SearchInsertionOrdersRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "Predicates": [Predicate.from_dict(_item) for _item in obj["Predicates"]] if obj.get("Predicates") is not None else None,
                        "Ordering": [OrderBy.from_dict(_item) for _item in obj["Ordering"]] if obj.get("Ordering") is not None else None,
                        "PageInfo": Paging.from_dict(obj["PageInfo"]) if obj.get("PageInfo") is not None else None,
                        "ReturnAdditionalFields": obj.get("ReturnAdditionalFields") if obj.get("ReturnAdditionalFields") is not None else None
        })
        return _obj
