Source code for sdk.lusid.models.cash_election

# 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 typing import List, Dict, Optional, Any, Union, TYPE_CHECKING
from typing_extensions import Annotated
from pydantic.v1 import BaseModel, StrictStr, StrictInt, StrictBool, StrictFloat, StrictBytes, Field, validator, ValidationError, conlist, constr
from datetime import datetime

[docs] class CashElection(BaseModel): """ Cash election for Events that result in a cash payment. # noqa: E501 """ election_key: StrictStr = Field(...,alias="electionKey", description="Unique key used to identify this election.") exchange_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The exchange rate if this is not the declared CashElection. Defaults to 1 if Election is Declared.", alias="exchangeRate") dividend_rate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The payment rate for this CashElection.", alias="dividendRate") is_chosen: Optional[StrictBool] = Field(default=None, description="Has this election been chosen. Only one Election may be Chosen per Event.", alias="isChosen") is_declared: Optional[StrictBool] = Field(default=None, description="Is this the declared CashElection. Only one Election may be Declared per Event.", alias="isDeclared") is_default: Optional[StrictBool] = Field(default=None, description="Is this election the default. Only one Election may be Default per Event", alias="isDefault") dividend_currency: StrictStr = Field(...,alias="dividendCurrency", description="The payment currency for this CashElection.") __properties = ["electionKey", "exchangeRate", "dividendRate", "isChosen", "isDeclared", "isDefault", "dividendCurrency"]
[docs] class Config: """Pydantic configuration""" allow_population_by_field_name = True validate_assignment = True
def __str__(self): """For `print` and `pprint`""" return pprint.pformat(self.dict(by_alias=False)) def __repr__(self): """For `print` and `pprint`""" return self.to_str()
[docs] def to_str(self) -> str: """Returns the string representation of the model using alias""" return pprint.pformat(self.dict(by_alias=True))
[docs] def to_json(self) -> str: """Returns the JSON representation of the model using alias""" return json.dumps(self.to_dict())
[docs] @classmethod def from_json(cls, json_str: str) -> CashElection: """Create an instance of CashElection from a JSON string""" return cls.from_dict(json.loads(json_str))
[docs] def to_dict(self): """Returns the dictionary representation of the model using alias""" _dict = self.dict(by_alias=True, exclude={ }, exclude_none=True) # set to None if exchange_rate (nullable) is None # and __fields_set__ contains the field if self.exchange_rate is None and "exchange_rate" in self.__fields_set__: _dict['exchangeRate'] = None # set to None if dividend_rate (nullable) is None # and __fields_set__ contains the field if self.dividend_rate is None and "dividend_rate" in self.__fields_set__: _dict['dividendRate'] = None return _dict
[docs] @classmethod def from_dict(cls, obj: dict) -> CashElection: """Create an instance of CashElection from a dict""" if obj is None: return None if not isinstance(obj, dict): return CashElection.parse_obj(obj) _obj = CashElection.parse_obj({ "election_key": obj.get("electionKey"), "exchange_rate": obj.get("exchangeRate"), "dividend_rate": obj.get("dividendRate"), "is_chosen": obj.get("isChosen"), "is_declared": obj.get("isDeclared"), "is_default": obj.get("isDefault"), "dividend_currency": obj.get("dividendCurrency") }) return _obj
CashElection.update_forward_refs()