# coding: utf-8

"""
    Platform API

    _OpenAPI specification for the **Platform API** of **Helix**, the nomination platform of ElecLink_  ---  Additional documentation available in the API's [GitHub repository](https://github.com/eleclink-helix/platform-api) 

    The version of the OpenAPI document: 0.0.125
    Contact: team.eleclink@eleclink.co.uk
    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 List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from helix_platform_api_public_client.models.attachment import Attachment
from helix_platform_api_public_client.models.business_process_step_attempt import BusinessProcessStepAttempt
from helix_platform_api_public_client.models.business_process_step_logic_type import BusinessProcessStepLogicType
from helix_platform_api_public_client.models.business_process_step_type import BusinessProcessStepType
from helix_platform_api_public_client.models.data_flow_direction import DataFlowDirection
from helix_platform_api_public_client.models.interface import Interface

class BusinessProcessStepBlock(BaseModel):
    """
    BusinessProcessStepBlock
    """
    block_type: StrictStr = Field(..., alias="blockType")
    step_type: BusinessProcessStepType = Field(..., alias="stepType")
    logic_type: BusinessProcessStepLogicType = Field(..., alias="logicType")
    data_flow_direction: Optional[DataFlowDirection] = Field(None, alias="dataFlowDirection")
    interface: Optional[Interface] = None
    id: Optional[StrictStr] = Field(None, description="Unique identifier for the record in UUID4 format")
    resolvable: StrictBool = Field(...)
    rerunnable: StrictBool = Field(...)
    attempts: conlist(BusinessProcessStepAttempt) = Field(...)
    file: Optional[Attachment] = None
    __properties = ["blockType", "stepType", "logicType", "dataFlowDirection", "interface", "id", "resolvable", "rerunnable", "attempts", "file"]

    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) -> BusinessProcessStepBlock:
        """Create an instance of BusinessProcessStepBlock 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 step_type
        if self.step_type:
            _dict['stepType'] = self.step_type.to_dict()
        # override the default output from pydantic by calling `to_dict()` of interface
        if self.interface:
            _dict['interface'] = self.interface.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in attempts (list)
        _items = []
        if self.attempts:
            for _item in self.attempts:
                if _item:
                    _items.append(_item.to_dict())
            _dict['attempts'] = _items
        # override the default output from pydantic by calling `to_dict()` of file
        if self.file:
            _dict['file'] = self.file.to_dict()
        return _dict

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

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

        _obj = BusinessProcessStepBlock.parse_obj({
            "block_type": obj.get("blockType"),
            "step_type": BusinessProcessStepType.from_dict(obj.get("stepType")) if obj.get("stepType") is not None else None,
            "logic_type": obj.get("logicType"),
            "data_flow_direction": obj.get("dataFlowDirection"),
            "interface": Interface.from_dict(obj.get("interface")) if obj.get("interface") is not None else None,
            "id": obj.get("id"),
            "resolvable": obj.get("resolvable"),
            "rerunnable": obj.get("rerunnable"),
            "attempts": [BusinessProcessStepAttempt.from_dict(_item) for _item in obj.get("attempts")] if obj.get("attempts") is not None else None,
            "file": Attachment.from_dict(obj.get("file")) if obj.get("file") is not None else None
        })
        return _obj


