-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from smkent/dev
Add tests, organize methods and models
- Loading branch information
Showing
27 changed files
with
776 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,53 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from datetime import datetime | ||
from typing import List, Optional, Union | ||
from typing import List, Optional | ||
|
||
from dataclasses_json import config | ||
|
||
from .. import constants | ||
from ..models import Email, Operator | ||
from ..serializer import ( | ||
ListOrRef, | ||
Model, | ||
StrOrRef, | ||
datetime_decode, | ||
datetime_encode, | ||
) | ||
from .methods import Get, GetResponse, Query, QueryResponse | ||
from ..models import Email, EmailQueryFilter, ListOrRef | ||
from .base import Get, GetResponse, Query, QueryResponse | ||
|
||
|
||
@dataclass | ||
class EmailQuery(Query): | ||
class EmailGet(Get): | ||
@classmethod | ||
def name(cls) -> str: | ||
return "Email/query" | ||
return "Email/get" | ||
|
||
@classmethod | ||
def using(cls) -> set[str]: | ||
return set([constants.JMAP_URN_MAIL]) | ||
|
||
filter: Optional[EmailQueryFilter] = None | ||
collapse_threads: Optional[bool] = None | ||
|
||
|
||
@dataclass | ||
class EmailQueryResponse(QueryResponse): | ||
ids: ListOrRef[str] | ||
|
||
|
||
@dataclass | ||
class EmailQueryFilterCondition(Model): | ||
in_mailbox: Optional[StrOrRef] = None | ||
in_mailbox_other_than: Optional[ListOrRef] = None | ||
before: Optional[datetime] = field( | ||
default=None, | ||
metadata=config(encoder=datetime_encode, decoder=datetime_decode), | ||
) | ||
after: Optional[datetime] = field( | ||
default=None, | ||
metadata=config(encoder=datetime_encode, decoder=datetime_decode), | ||
) | ||
min_size: Optional[int] = None | ||
max_size: Optional[int] = None | ||
all_in_thread_have_keyword: Optional[StrOrRef] = None | ||
some_in_thread_have_keyword: Optional[StrOrRef] = None | ||
none_in_thread_have_keyword: Optional[StrOrRef] = None | ||
has_keyword: Optional[StrOrRef] = None | ||
not_keyword: Optional[StrOrRef] = None | ||
has_attachment: Optional[bool] = None | ||
text: Optional[StrOrRef] = None | ||
mail_from: Optional[str] = field( | ||
metadata=config(field_name="from"), default=None | ||
body_properties: Optional[List[str]] = None | ||
fetch_text_body_values: Optional[bool] = None | ||
fetch_html_body_values: Optional[bool] = field( | ||
metadata=config(field_name="fetchHTMLBodyValues"), default=None | ||
) | ||
to: Optional[StrOrRef] = None | ||
cc: Optional[StrOrRef] = None | ||
bcc: Optional[StrOrRef] = None | ||
body: Optional[StrOrRef] = None | ||
header: Optional[ListOrRef] = None | ||
fetch_all_body_values: Optional[bool] = None | ||
max_body_value_bytes: Optional[int] = None | ||
|
||
|
||
@dataclass | ||
class EmailQueryFilterOperator(Model): | ||
operator: Operator | ||
conditions: List[EmailQueryFilter] | ||
|
||
|
||
EmailQueryFilter = Union[EmailQueryFilterCondition, EmailQueryFilterOperator] | ||
class EmailGetResponse(GetResponse): | ||
data: List[Email] = field(metadata=config(field_name="list")) | ||
|
||
|
||
@dataclass | ||
class EmailGet(Get): | ||
class EmailQuery(Query): | ||
@classmethod | ||
def name(cls) -> str: | ||
return "Email/get" | ||
return "Email/query" | ||
|
||
@classmethod | ||
def using(cls) -> set[str]: | ||
return set([constants.JMAP_URN_MAIL]) | ||
|
||
body_properties: Optional[List[str]] = None | ||
fetch_text_body_values: Optional[bool] = None | ||
fetch_html_body_values: Optional[bool] = None | ||
fetch_all_body_values: Optional[bool] = None | ||
max_body_value_bytes: Optional[int] = None | ||
filter: Optional[EmailQueryFilter] = None | ||
collapse_threads: Optional[bool] = None | ||
|
||
|
||
@dataclass | ||
class EmailGetResponse(GetResponse): | ||
data: List[Email] = field(metadata=config(field_name="list")) | ||
class EmailQueryResponse(QueryResponse): | ||
ids: ListOrRef[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,44 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from typing import List, Optional, Union | ||
from typing import List, Optional | ||
|
||
from dataclasses_json import config | ||
|
||
from .. import constants | ||
from ..models import Mailbox, Operator | ||
from ..serializer import ListOrRef, Model, StrOrRef | ||
from .methods import Get, GetResponse, Query, QueryResponse | ||
from ..models import ListOrRef, Mailbox, MailboxQueryFilter | ||
from .base import Get, GetResponse, Query, QueryResponse | ||
|
||
|
||
@dataclass | ||
class MailboxQuery(Query): | ||
class MailboxGet(Get): | ||
@classmethod | ||
def name(cls) -> str: | ||
return "Mailbox/query" | ||
return "Mailbox/get" | ||
|
||
@classmethod | ||
def using(cls) -> set[str]: | ||
return set([constants.JMAP_URN_MAIL]) | ||
|
||
filter: Optional[MailboxQueryFilter] = None | ||
|
||
|
||
@dataclass | ||
class MailboxQueryResponse(QueryResponse): | ||
ids: ListOrRef[str] | ||
|
||
|
||
@dataclass | ||
class MailboxQueryFilterCondition(Model): | ||
name: Optional[StrOrRef] = None | ||
role: Optional[StrOrRef] = None | ||
parent_id: Optional[StrOrRef] = None | ||
|
||
|
||
@dataclass | ||
class MailboxQueryFilterOperator(Model): | ||
operator: Operator | ||
conditions: List[MailboxQueryFilter] | ||
|
||
|
||
MailboxQueryFilter = Union[ | ||
MailboxQueryFilterCondition, MailboxQueryFilterOperator | ||
] | ||
class MailboxGetResponse(GetResponse): | ||
data: List[Mailbox] = field(metadata=config(field_name="list")) | ||
|
||
|
||
@dataclass | ||
class MailboxGet(Get): | ||
class MailboxQuery(Query): | ||
@classmethod | ||
def name(cls) -> str: | ||
return "Mailbox/get" | ||
return "Mailbox/query" | ||
|
||
@classmethod | ||
def using(cls) -> set[str]: | ||
return set([constants.JMAP_URN_MAIL]) | ||
|
||
filter: Optional[MailboxQueryFilter] = None | ||
|
||
|
||
@dataclass | ||
class MailboxGetResponse(GetResponse): | ||
data: List[Mailbox] = field(metadata=config(field_name="list")) | ||
class MailboxQueryResponse(QueryResponse): | ||
ids: ListOrRef[str] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.