Passed
Push — main ( 5a1833...1f94b4 )
by Jochen
05:05
created

NameAndAddress.format()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
"""
2
byceps.services.email.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 email.utils import formataddr
12 1
from typing import Optional
13
14 1
from ....typing import BrandID
15
16
17 1
@dataclass(frozen=True)
18
class NameAndAddress:
19 1
    name: Optional[str]
20 1
    address: str
21
22 1
    def format(self):
23
        """Format the name and address as a string value suitable for an
24
        e-mail header.
25
        """
26 1
        return formataddr((self.name, self.address))
27
28
29 1
@dataclass(frozen=True)
30
class EmailConfig:
31 1
    brand_id: BrandID
32 1
    sender: NameAndAddress
33 1
    contact_address: str
34
35
36 1
@dataclass(frozen=True)
37
class Message:
38 1
    sender: NameAndAddress
39 1
    recipients: list[str]
40 1
    subject: str
41
    body: str
42