Coverage for apps/kwai-api/src/kwai_api/v1/club/schemas/person.py: 100%
13 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for defining the JSON:API resource for a person."""
3from typing import Annotated
5from kwai_core.json_api import Relationship, ResourceMeta
6from pydantic import BaseModel, Field
8from kwai_api.v1.club.schemas.contact import ContactResource
9from kwai_api.v1.club.schemas.resources import (
10 ContactResourceIdentifier,
11 PersonResourceIdentifier,
12)
13from kwai_api.v1.schemas import (
14 CountryResource,
15 CountryResourceIdentifier,
16)
19class PersonAttributes(BaseModel):
20 """Attributes for the person JSON:API resource."""
22 first_name: str
23 last_name: str
24 gender: int
25 birthdate: str
26 remark: str
29class PersonRelationships(BaseModel):
30 """Relationships of a person JSON:API resource."""
32 contact: Relationship[ContactResourceIdentifier]
33 nationality: Relationship[CountryResourceIdentifier]
36class PersonResource(PersonResourceIdentifier):
37 """A JSON:API resource for a person."""
39 meta: ResourceMeta | None = None
40 attributes: PersonAttributes
41 relationships: PersonRelationships
44PersonInclude = Annotated[
45 ContactResource | CountryResource, Field(discriminator="type")
46]
49class PersonDocument(BaseModel):
50 """A JSON:API document for one person."""
52 data: PersonResource
53 included: set[PersonInclude] = Field(default_factory=set)