# coding: utf-8

"""
    CATAPA API

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

    The version of the OpenAPI document: 1.0.0
    Contact: support@catapa.com
    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 openapi_client.models.bpjs_healthcare_membership_additional_family_membership import BpjsHealthcareMembershipAdditionalFamilyMembership
from typing import Optional, Set
from typing_extensions import Self

class BpjsHealthcareMembershipRequest(BaseModel):
    """
    BpjsHealthcareMembershipRequest
    """ # noqa: E501
    additional_family_memberships: List[BpjsHealthcareMembershipAdditionalFamilyMembership] = Field(alias="additionalFamilyMemberships")
    bpjs_healthcare_provider_id: StrictStr = Field(alias="bpjsHealthcareProviderId")
    bpjs_healthcare_template_id: StrictStr = Field(alias="bpjsHealthcareTemplateId")
    bpjs_healthcare_treatment_class_id: Optional[StrictStr] = Field(default=None, alias="bpjsHealthcareTreatmentClassId")
    dental_healthcare_facility: Optional[StrictStr] = Field(default=None, alias="dentalHealthcareFacility")
    first_level_healthcare_facility: Optional[StrictStr] = Field(default=None, alias="firstLevelHealthcareFacility")
    membership_number: StrictStr = Field(alias="membershipNumber")
    start_date: StrictStr = Field(alias="startDate")
    effective_date: Optional[StrictStr] = Field(default=None, description="Effective Date of the BPJS Healthcare Membership default to start date", alias="effectiveDate")
    __properties: ClassVar[List[str]] = ["additionalFamilyMemberships", "bpjsHealthcareProviderId", "bpjsHealthcareTemplateId", "bpjsHealthcareTreatmentClassId", "dentalHealthcareFacility", "firstLevelHealthcareFacility", "membershipNumber", "startDate", "effectiveDate"]

    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 BpjsHealthcareMembershipRequest 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 each item in additional_family_memberships (list)
        _items = []
        if self.additional_family_memberships:
            for _item_additional_family_memberships in self.additional_family_memberships:
                if _item_additional_family_memberships:
                    _items.append(_item_additional_family_memberships.to_dict())
            _dict['additionalFamilyMemberships'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "additionalFamilyMemberships": [BpjsHealthcareMembershipAdditionalFamilyMembership.from_dict(_item) for _item in obj["additionalFamilyMemberships"]] if obj.get("additionalFamilyMemberships") is not None else None,
            "bpjsHealthcareProviderId": obj.get("bpjsHealthcareProviderId"),
            "bpjsHealthcareTemplateId": obj.get("bpjsHealthcareTemplateId"),
            "bpjsHealthcareTreatmentClassId": obj.get("bpjsHealthcareTreatmentClassId"),
            "dentalHealthcareFacility": obj.get("dentalHealthcareFacility"),
            "firstLevelHealthcareFacility": obj.get("firstLevelHealthcareFacility"),
            "membershipNumber": obj.get("membershipNumber"),
            "startDate": obj.get("startDate"),
            "effectiveDate": obj.get("effectiveDate")
        })
        return _obj


