# coding: utf-8
"""
GameBrain API
GameBrain API
The version of the OpenAPI document: 1.0.1
Contact: mail@gamebrain.co
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 datetime import date
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from gamebrain.models.game_response_offers_inner import GameResponseOffersInner
from gamebrain.models.game_response_official_stores_inner import GameResponseOfficialStoresInner
from gamebrain.models.game_response_platforms_inner import GameResponsePlatformsInner
from gamebrain.models.game_response_playtime import GameResponsePlaytime
from gamebrain.models.game_response_rating import GameResponseRating
from typing import Optional, Set
from typing_extensions import Self
class GameResponse(BaseModel):
"""
GameResponse
""" # noqa: E501
id: Optional[StrictInt] = None
name: Optional[StrictStr] = None
image: Optional[StrictStr] = None
gameplay: Optional[StrictStr] = None
link: Optional[StrictStr] = None
x_url: Optional[StrictStr] = None
rating: Optional[GameResponseRating] = None
description: Optional[StrictStr] = None
short_description: Optional[StrictStr] = None
release_date: Optional[date] = None
developer: Optional[StrictStr] = None
playtime: Optional[GameResponsePlaytime] = None
platforms: Optional[Annotated[List[GameResponsePlatformsInner], Field(max_length=100)]] = None
tags: Optional[Annotated[List[StrictStr], Field(max_length=100)]] = None
genres: Optional[Annotated[List[GameResponsePlatformsInner], Field(max_length=100)]] = None
genre: Optional[StrictStr] = None
themes: Optional[Annotated[List[GameResponsePlatformsInner], Field(max_length=100)]] = None
adult_only: Optional[StrictBool] = None
play_modes: Optional[Annotated[List[GameResponsePlatformsInner], Field(max_length=100)]] = None
screenshots: Optional[Annotated[List[StrictStr], Field(max_length=100)]] = None
videos: Optional[Annotated[List[StrictStr], Field(max_length=100)]] = None
offers: Optional[Annotated[List[GameResponseOffersInner], Field(max_length=100)]] = None
official_stores: Optional[Annotated[List[GameResponseOfficialStoresInner], Field(max_length=100)]] = None
micro_trailer: Optional[StrictStr] = None
__properties: ClassVar[List[str]] = ["id", "name", "image", "gameplay", "link", "x_url", "rating", "description", "short_description", "release_date", "developer", "playtime", "platforms", "tags", "genres", "genre", "themes", "adult_only", "play_modes", "screenshots", "videos", "offers", "official_stores", "micro_trailer"]
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 GameResponse 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 rating
if self.rating:
_dict['rating'] = self.rating.to_dict()
# override the default output from pydantic by calling `to_dict()` of playtime
if self.playtime:
_dict['playtime'] = self.playtime.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in platforms (list)
_items = []
if self.platforms:
for _item in self.platforms:
if _item:
_items.append(_item.to_dict())
_dict['platforms'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in genres (list)
_items = []
if self.genres:
for _item in self.genres:
if _item:
_items.append(_item.to_dict())
_dict['genres'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in themes (list)
_items = []
if self.themes:
for _item in self.themes:
if _item:
_items.append(_item.to_dict())
_dict['themes'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in play_modes (list)
_items = []
if self.play_modes:
for _item in self.play_modes:
if _item:
_items.append(_item.to_dict())
_dict['play_modes'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in offers (list)
_items = []
if self.offers:
for _item in self.offers:
if _item:
_items.append(_item.to_dict())
_dict['offers'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in official_stores (list)
_items = []
if self.official_stores:
for _item in self.official_stores:
if _item:
_items.append(_item.to_dict())
_dict['official_stores'] = _items
return _dict
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of GameResponse from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return cls.model_validate(obj)
_obj = cls.model_validate({
"id": obj.get("id"),
"name": obj.get("name"),
"image": obj.get("image"),
"gameplay": obj.get("gameplay"),
"link": obj.get("link"),
"x_url": obj.get("x_url"),
"rating": GameResponseRating.from_dict(obj["rating"]) if obj.get("rating") is not None else None,
"description": obj.get("description"),
"short_description": obj.get("short_description"),
"release_date": obj.get("release_date"),
"developer": obj.get("developer"),
"playtime": GameResponsePlaytime.from_dict(obj["playtime"]) if obj.get("playtime") is not None else None,
"platforms": [GameResponsePlatformsInner.from_dict(_item) for _item in obj["platforms"]] if obj.get("platforms") is not None else None,
"tags": obj.get("tags"),
"genres": [GameResponsePlatformsInner.from_dict(_item) for _item in obj["genres"]] if obj.get("genres") is not None else None,
"genre": obj.get("genre"),
"themes": [GameResponsePlatformsInner.from_dict(_item) for _item in obj["themes"]] if obj.get("themes") is not None else None,
"adult_only": obj.get("adult_only"),
"play_modes": [GameResponsePlatformsInner.from_dict(_item) for _item in obj["play_modes"]] if obj.get("play_modes") is not None else None,
"screenshots": obj.get("screenshots"),
"videos": obj.get("videos"),
"offers": [GameResponseOffersInner.from_dict(_item) for _item in obj["offers"]] if obj.get("offers") is not None else None,
"official_stores": [GameResponseOfficialStoresInner.from_dict(_item) for _item in obj["official_stores"]] if obj.get("official_stores") is not None else None,
"micro_trailer": obj.get("micro_trailer")
})
return _obj