# coding: utf-8

"""
    Conekta API

    Conekta sdk  # noqa: E501

    The version of the OpenAPI document: 2.1.0
    Contact: engineering@conekta.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 Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr

class ApiKeyResponse(BaseModel):
    """
    api keys model
    """
    active: Optional[StrictBool] = Field(None, description="Indicates if the api key is active")
    created_at: Optional[StrictInt] = Field(None, description="Unix timestamp in seconds of when the api key was created")
    updated_at: Optional[StrictInt] = Field(None, description="Unix timestamp in seconds of when the api key was last updated")
    deactivated_at: Optional[StrictInt] = Field(None, description="Unix timestamp in seconds of when the api key was deleted")
    description: Optional[StrictStr] = Field(None, description="A name or brief explanation of what this api key is used for")
    id: Optional[StrictStr] = Field(None, description="Unique identifier of the api key")
    livemode: Optional[StrictBool] = Field(None, description="Indicates if the api key is in production")
    deleted: Optional[StrictBool] = Field(None, description="Indicates if the api key was deleted")
    object: Optional[StrictStr] = Field(None, description="Object name, value is 'api_key'")
    prefix: Optional[StrictStr] = Field(None, description="The first few characters of the authentication_token")
    role: Optional[StrictStr] = Field(None, description="Indicates if the api key is private or public")
    __properties = ["active", "created_at", "updated_at", "deactivated_at", "description", "id", "livemode", "deleted", "object", "prefix", "role"]

    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) -> ApiKeyResponse:
        """Create an instance of ApiKeyResponse 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)
        # set to None if deactivated_at (nullable) is None
        # and __fields_set__ contains the field
        if self.deactivated_at is None and "deactivated_at" in self.__fields_set__:
            _dict['deactivated_at'] = None

        return _dict

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

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

        _obj = ApiKeyResponse.parse_obj({
            "active": obj.get("active"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at"),
            "deactivated_at": obj.get("deactivated_at"),
            "description": obj.get("description"),
            "id": obj.get("id"),
            "livemode": obj.get("livemode"),
            "deleted": obj.get("deleted"),
            "object": obj.get("object"),
            "prefix": obj.get("prefix"),
            "role": obj.get("role")
        })
        return _obj

