# coding: utf-8

"""
    VerificationService

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

    The version of the OpenAPI document: 1.0.0
    Contact: info@affinidi.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 typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field, StrictStr, conlist
from affinidi_tdk_credential_verification_client.models.format import Format
from affinidi_tdk_credential_verification_client.models.input_descriptor import InputDescriptor
from affinidi_tdk_credential_verification_client.models.submission_requirement import SubmissionRequirement

class PresentationDefinition(BaseModel):
    """
    Presentation definition  # noqa: E501
    """
    id: StrictStr = Field(default=..., description="Definition id")
    name: Optional[StrictStr] = Field(default=None, description="Definition name")
    purpose: Optional[StrictStr] = Field(default=None, description="Definition purpose")
    format: Optional[Format] = None
    submission_requirements: Optional[conlist(SubmissionRequirement)] = None
    input_descriptors: conlist(InputDescriptor) = Field(...)
    frame: Optional[Dict[str, Any]] = Field(default=None, description="Dynamic model")
    __properties = ["id", "name", "purpose", "format", "submission_requirements", "input_descriptors", "frame"]

    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) -> PresentationDefinition:
        """Create an instance of PresentationDefinition 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={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of format
        if self.format:
            _dict['format'] = self.format.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in submission_requirements (list)
        _items = []
        if self.submission_requirements:
            for _item in self.submission_requirements:
                if _item:
                    _items.append(_item.to_dict())
            _dict['submission_requirements'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in input_descriptors (list)
        _items = []
        if self.input_descriptors:
            for _item in self.input_descriptors:
                if _item:
                    _items.append(_item.to_dict())
            _dict['input_descriptors'] = _items
        return _dict

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

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

        _obj = PresentationDefinition.parse_obj({
            "id": obj.get("id"),
            "name": obj.get("name"),
            "purpose": obj.get("purpose"),
            "format": Format.from_dict(obj.get("format")) if obj.get("format") is not None else None,
            "submission_requirements": [SubmissionRequirement.from_dict(_item) for _item in obj.get("submission_requirements")] if obj.get("submission_requirements") is not None else None,
            "input_descriptors": [InputDescriptor.from_dict(_item) for _item in obj.get("input_descriptors")] if obj.get("input_descriptors") is not None else None,
            "frame": obj.get("frame")
        })
        return _obj


