Passed
Push — main ( 7f92a7...2ef5e3 )
by Jochen
07:43
created

UserDetail.full_name()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
"""
2
byceps.services.user.transfer.models
3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5
:Copyright: 2006-2021 Jochen Kupperschmidt
6
:License: Revised BSD (see `LICENSE` file for details)
7
"""
8
9 1
from __future__ import annotations
10 1
from dataclasses import dataclass
11 1
from datetime import date
12 1
from typing import Any, Optional
13
14 1
from ....typing import UserID
15
16
17 1
@dataclass(frozen=True)
18
class User:
19 1
    id: UserID
20 1
    screen_name: Optional[str]
21 1
    suspended: bool
22 1
    deleted: bool
23 1
    locale: Optional[str]
24 1
    avatar_url: Optional[str]
25 1
    is_orga: bool
26
27
28 1
@dataclass(frozen=True)
29
class UserDetail:
30 1
    first_names: Optional[str]
31 1
    last_name: Optional[str]
32 1
    date_of_birth: Optional[date]
33 1
    country: Optional[str]
34 1
    zip_code: Optional[str]
35 1
    city: Optional[str]
36 1
    street: Optional[str]
37 1
    phone_number: Optional[str]
38 1
    internal_comment: Optional[str]
39 1
    extras: dict[str, Any]
40
41 1
    @property
42
    def full_name(self) -> Optional[str]:
43 1
        names = [self.first_names, self.last_name]
44 1
        return ' '.join(filter(None, names)) or None
45
46
47 1
@dataclass(frozen=True)
48 1
class UserWithDetail(User):
49
    detail: UserDetail
50