# coding: utf-8

"""
    Wink Payment API

    A programmatic way to create bookings, receive payment and disburse funds globally.  ## APIs Not every integrator needs every APIs. For that reason, we have separated APIs into context.  - [Affiliate](/affiliate): All APIs related to selling travel inventory as an affiliate. - [Analytics](/analytics): All APIs related to tracking metrics across a wide variety of data source segments including, more entertaining, leaderboard metrics. - [Booking](/booking): All APIs related to creating platform bookings. - [Channel Manager](/channel-manager): All APIs related to channel managers who want to integrate with our platform. - [Extranet](/extranet): All APIs related to managing travel inventory and suppliers. - [Inventory](/inventory): All APIs related to retrieve known travel inventory as it was found using the Lookup API.. - [Lookup](/lookup): All APIs related to locating inventory by region, locale and property flags. - [Reference](/reference): All APIs related to retrieving platform-supported taxonomies. - [TripPay](/payment): All APIs related to TripPay account management, booking, mapping and integration features.  ## SDKs We are actively working on supporting the most used languages out there. If you don't see your language here, reach out to us with a request to officially add your language. In the meantime, if you want to roll your own SDK, you can do so by downloading the OpenAPI spec and using one of the many available OpenAPI generators available: [https://openapi-generator.tech/docs/generators](https://openapi-generator.tech/docs/generators).  - Java SDK [https://github.com/wink-travel/trip-pay-sdk-java](https://github.com/wink-travel/trip-pay-sdk-java)  # Usage These features are made available to you via a [REST API](https://en.wikipedia.org/wiki/Representational_state_transfer). This API is language agnostic. We will link to SDKs for the most popular programming languages on this page as they become available.  ## Versioning We chose to version our endpoints in a way that we hope affects your integration with us the least. You request the version of our API you wish to work with via the `Wink-Version` header. When it's time for you to upgrade, you only have to change the version number to get access to our updated endpoints.  ## Release history - Follow updates on Github: https://github.com/wink-travel/wink-sdk-java/blob/master/CHANGELOG.md 

    The version of the OpenAPI document: 30.18.0
    Contact: bjorn@wink.travel
    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 pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from trip_pay_payment.models.custom_monetary_amount import CustomMonetaryAmount
from typing import Optional, Set
from typing_extensions import Self

class PayableContractResponse(BaseModel):
    """
    Details of the booking entries that went in for one particular supplier directly.
    """ # noqa: E501
    id: StrictStr = Field(description="TripPay supplierContractIdentifier for payment widget")
    trace_id: Optional[StrictStr] = Field(default=None, description="Groups all booking contracts submitted at the same time", alias="traceId")
    supplier_contract_identifier: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Unique supplierContractIdentifier used to track the contract. Create a UUID for this purpose.", alias="supplierContractIdentifier")
    supplier_identifier: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Supplier supplierContractIdentifier", alias="supplierIdentifier")
    supplier_name: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Supplier name", alias="supplierName")
    external_supplier_identifier: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Track supplier with its external supplier supplierContractIdentifier", alias="externalSupplierIdentifier")
    external_supplier_booking_code: Annotated[str, Field(min_length=1, strict=True)] = Field(description="External booking code generated by the affiliate", alias="externalSupplierBookingCode")
    external_transaction_identifier: Optional[StrictStr] = Field(default=None, description="External transaction supplierContractIdentifier populated when agent responsible for acquiring", alias="externalTransactionIdentifier")
    total_price: CustomMonetaryAmount = Field(alias="totalPrice")
    total_display_price: CustomMonetaryAmount = Field(alias="totalDisplayPrice")
    total_supplier_price: CustomMonetaryAmount = Field(alias="totalSupplierPrice")
    total_internal_price: CustomMonetaryAmount = Field(alias="totalInternalPrice")
    total_capture_price: CustomMonetaryAmount = Field(alias="totalCapturePrice")
    __properties: ClassVar[List[str]] = ["id", "traceId", "supplierContractIdentifier", "supplierIdentifier", "supplierName", "externalSupplierIdentifier", "externalSupplierBookingCode", "externalTransactionIdentifier", "totalPrice", "totalDisplayPrice", "totalSupplierPrice", "totalInternalPrice", "totalCapturePrice"]

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


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of PayableContractResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    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 total_price
        if self.total_price:
            _dict['totalPrice'] = self.total_price.to_dict()
        # override the default output from pydantic by calling `to_dict()` of total_display_price
        if self.total_display_price:
            _dict['totalDisplayPrice'] = self.total_display_price.to_dict()
        # override the default output from pydantic by calling `to_dict()` of total_supplier_price
        if self.total_supplier_price:
            _dict['totalSupplierPrice'] = self.total_supplier_price.to_dict()
        # override the default output from pydantic by calling `to_dict()` of total_internal_price
        if self.total_internal_price:
            _dict['totalInternalPrice'] = self.total_internal_price.to_dict()
        # override the default output from pydantic by calling `to_dict()` of total_capture_price
        if self.total_capture_price:
            _dict['totalCapturePrice'] = self.total_capture_price.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "traceId": obj.get("traceId"),
            "supplierContractIdentifier": obj.get("supplierContractIdentifier"),
            "supplierIdentifier": obj.get("supplierIdentifier"),
            "supplierName": obj.get("supplierName"),
            "externalSupplierIdentifier": obj.get("externalSupplierIdentifier"),
            "externalSupplierBookingCode": obj.get("externalSupplierBookingCode"),
            "externalTransactionIdentifier": obj.get("externalTransactionIdentifier"),
            "totalPrice": CustomMonetaryAmount.from_dict(obj["totalPrice"]) if obj.get("totalPrice") is not None else None,
            "totalDisplayPrice": CustomMonetaryAmount.from_dict(obj["totalDisplayPrice"]) if obj.get("totalDisplayPrice") is not None else None,
            "totalSupplierPrice": CustomMonetaryAmount.from_dict(obj["totalSupplierPrice"]) if obj.get("totalSupplierPrice") is not None else None,
            "totalInternalPrice": CustomMonetaryAmount.from_dict(obj["totalInternalPrice"]) if obj.get("totalInternalPrice") is not None else None,
            "totalCapturePrice": CustomMonetaryAmount.from_dict(obj["totalCapturePrice"]) if obj.get("totalCapturePrice") is not None else None
        })
        return _obj


