# coding: utf-8

"""
    LUSID API

    FINBOURNE Technology  # noqa: E501

    Contact: info@finbourne.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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

from datetime import datetime
from typing import Any, Dict, Optional, Union
from pydantic.v1 import Field, StrictBool, StrictFloat, StrictInt, StrictStr, validator
from lusid.models.instrument_event import InstrumentEvent

class FxForwardSettlementEvent(InstrumentEvent):
    """
    Settlement for FX Forward, including NDF and deliverable.  # noqa: E501
    """
    maturity_date: datetime = Field(..., alias="maturityDate", description="Maturity date of the forward")
    dom_amount_per_unit: Union[StrictFloat, StrictInt] = Field(..., alias="domAmountPerUnit", description="Amount per unit in the DomCcy (domestic currency)")
    dom_ccy: StrictStr = Field(..., alias="domCcy", description="The domestic currency of the forward")
    fgn_amount_per_unit: Union[StrictFloat, StrictInt] = Field(..., alias="fgnAmountPerUnit", description="Amount per unit in the FgnCcy (foreign currency)")
    fgn_ccy: StrictStr = Field(..., alias="fgnCcy", description="The foreign currency of the forward.")
    is_ndf: StrictBool = Field(..., alias="isNdf", description="Is this settlement corresponding to a deliverable forward, or an NDF")
    fixing_date: Optional[datetime] = Field(None, alias="fixingDate", description="Optional.  Required if the event is an NDF (i.e. if IsNdf = true).  Date of the FxRate fixings.")
    settlement_ccy: Optional[StrictStr] = Field(None, alias="settlementCcy", description="Optional.  Required if the event is an NDF (i.e. if IsNdf = true).  May be set to either DomCcy or FgnCcy, or a third currency.")
    cash_flow_per_unit: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="cashFlowPerUnit", description="Optional.  Required if the event is an NDF (i.e. if IsNdf = true).  CashFlow per unit.  Paid in the SettlementCcy.")
    domestic_to_foreign_rate: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="domesticToForeignRate", description="Domestic currency to foreign currency FX rate.  Not required, only used to override quotes.")
    domestic_to_settlement_rate: Optional[Union[StrictFloat, StrictInt]] = Field(None, alias="domesticToSettlementRate", description="Domestic currency to settlement currency FX rate  Not required, only used to override quotes.")
    instrument_event_type: StrictStr = Field(..., alias="instrumentEventType", description="The Type of Event. The available values are: TransitionEvent, InformationalEvent, OpenEvent, CloseEvent, StockSplitEvent, BondDefaultEvent, CashDividendEvent, AmortisationEvent, CashFlowEvent, ExerciseEvent, ResetEvent, TriggerEvent, RawVendorEvent, InformationalErrorEvent, BondCouponEvent, DividendReinvestmentEvent, AccumulationEvent, BondPrincipalEvent, DividendOptionEvent, MaturityEvent, FxForwardSettlementEvent, ExpiryEvent, ScripDividendEvent, StockDividendEvent, ReverseStockSplitEvent")
    additional_properties: Dict[str, Any] = {}
    __properties = ["instrumentEventType", "maturityDate", "domAmountPerUnit", "domCcy", "fgnAmountPerUnit", "fgnCcy", "isNdf", "fixingDate", "settlementCcy", "cashFlowPerUnit", "domesticToForeignRate", "domesticToSettlementRate"]

    @validator('instrument_event_type')
    def instrument_event_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in ('TransitionEvent', 'InformationalEvent', 'OpenEvent', 'CloseEvent', 'StockSplitEvent', 'BondDefaultEvent', 'CashDividendEvent', 'AmortisationEvent', 'CashFlowEvent', 'ExerciseEvent', 'ResetEvent', 'TriggerEvent', 'RawVendorEvent', 'InformationalErrorEvent', 'BondCouponEvent', 'DividendReinvestmentEvent', 'AccumulationEvent', 'BondPrincipalEvent', 'DividendOptionEvent', 'MaturityEvent', 'FxForwardSettlementEvent', 'ExpiryEvent', 'ScripDividendEvent', 'StockDividendEvent', 'ReverseStockSplitEvent'):
            raise ValueError("must be one of enum values ('TransitionEvent', 'InformationalEvent', 'OpenEvent', 'CloseEvent', 'StockSplitEvent', 'BondDefaultEvent', 'CashDividendEvent', 'AmortisationEvent', 'CashFlowEvent', 'ExerciseEvent', 'ResetEvent', 'TriggerEvent', 'RawVendorEvent', 'InformationalErrorEvent', 'BondCouponEvent', 'DividendReinvestmentEvent', 'AccumulationEvent', 'BondPrincipalEvent', 'DividendOptionEvent', 'MaturityEvent', 'FxForwardSettlementEvent', 'ExpiryEvent', 'ScripDividendEvent', 'StockDividendEvent', 'ReverseStockSplitEvent')")
        return value

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                            "additional_properties"
                          },
                          exclude_none=True)
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        # set to None if fixing_date (nullable) is None
        # and __fields_set__ contains the field
        if self.fixing_date is None and "fixing_date" in self.__fields_set__:
            _dict['fixingDate'] = None

        # set to None if settlement_ccy (nullable) is None
        # and __fields_set__ contains the field
        if self.settlement_ccy is None and "settlement_ccy" in self.__fields_set__:
            _dict['settlementCcy'] = None

        # set to None if cash_flow_per_unit (nullable) is None
        # and __fields_set__ contains the field
        if self.cash_flow_per_unit is None and "cash_flow_per_unit" in self.__fields_set__:
            _dict['cashFlowPerUnit'] = None

        # set to None if domestic_to_foreign_rate (nullable) is None
        # and __fields_set__ contains the field
        if self.domestic_to_foreign_rate is None and "domestic_to_foreign_rate" in self.__fields_set__:
            _dict['domesticToForeignRate'] = None

        # set to None if domestic_to_settlement_rate (nullable) is None
        # and __fields_set__ contains the field
        if self.domestic_to_settlement_rate is None and "domestic_to_settlement_rate" in self.__fields_set__:
            _dict['domesticToSettlementRate'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> FxForwardSettlementEvent:
        """Create an instance of FxForwardSettlementEvent from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return FxForwardSettlementEvent.parse_obj(obj)

        _obj = FxForwardSettlementEvent.parse_obj({
            "instrument_event_type": obj.get("instrumentEventType"),
            "maturity_date": obj.get("maturityDate"),
            "dom_amount_per_unit": obj.get("domAmountPerUnit"),
            "dom_ccy": obj.get("domCcy"),
            "fgn_amount_per_unit": obj.get("fgnAmountPerUnit"),
            "fgn_ccy": obj.get("fgnCcy"),
            "is_ndf": obj.get("isNdf"),
            "fixing_date": obj.get("fixingDate"),
            "settlement_ccy": obj.get("settlementCcy"),
            "cash_flow_per_unit": obj.get("cashFlowPerUnit"),
            "domestic_to_foreign_rate": obj.get("domesticToForeignRate"),
            "domestic_to_settlement_rate": obj.get("domesticToSettlementRate")
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj
