-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: autoformatter changes * fix: make the `body` attribute of `Reply` event optional * fix: add attachments meta models to `Reply` event * docs: add release changes
- Loading branch information
Showing
6 changed files
with
108 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
"""Module with attachments meta for botx.""" | ||
|
||
from typing import Optional, Union | ||
|
||
from pydantic import Field | ||
|
||
from botx.models.base import BotXBaseModel | ||
from botx.models.enums import AttachmentsTypes | ||
|
||
try: | ||
from typing import Literal # noqa: WPS433 | ||
except ImportError: | ||
from typing_extensions import Literal # type: ignore # noqa: WPS433, WPS440, F401 | ||
|
||
|
||
class FileAttachmentMeta(BotXBaseModel): | ||
"""Common metadata of file.""" | ||
|
||
#: type of attachment | ||
type: str | ||
|
||
#: name of file. | ||
file_name: str | ||
|
||
#: mime type of file | ||
file_mime_type: Optional[str] | ||
|
||
#: file preview in RFC 2397 format. | ||
file_preview_base64: Optional[str] | ||
|
||
|
||
class ImageAttachmentMeta(FileAttachmentMeta): | ||
"""BotX API image attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.image] = Field(default=AttachmentsTypes.image) | ||
|
||
|
||
class VideoAttachmentMeta(FileAttachmentMeta): | ||
"""BotX API video attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.video] = Field(default=AttachmentsTypes.video) | ||
|
||
|
||
class DocumentAttachmentMeta(FileAttachmentMeta): | ||
"""BotX API document attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.document] = Field(default=AttachmentsTypes.document) | ||
|
||
|
||
class VoiceAttachmentMeta(FileAttachmentMeta): | ||
"""BotX API voice attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.voice] = Field(default=AttachmentsTypes.voice) | ||
|
||
|
||
class ContactAttachmentMeta(BotXBaseModel): | ||
"""BotX API contact attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.contact] = Field(default=AttachmentsTypes.contact) | ||
|
||
#: name of contact | ||
contact_name: str | ||
|
||
|
||
class LocationAttachmentMeta(BotXBaseModel): | ||
"""BotX API location attachment meta container.""" | ||
|
||
#: type of attachment | ||
type: Literal[AttachmentsTypes.location] = Field(default=AttachmentsTypes.location) | ||
|
||
#: address of location | ||
location_address: str | ||
|
||
|
||
AttachmentMeta = Union[ | ||
ImageAttachmentMeta, | ||
VideoAttachmentMeta, | ||
DocumentAttachmentMeta, | ||
VoiceAttachmentMeta, | ||
ContactAttachmentMeta, | ||
LocationAttachmentMeta, | ||
] |
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
71eedab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://pybotx.netlify.app as production
🚀 Deployed on https://6101246d342f24ad2388ac2c--pybotx.netlify.app