From 3e3f4e431a2e3910378a2423b916b326460d0aef Mon Sep 17 00:00:00 2001 From: Amirsalar Safaei Date: Wed, 2 Oct 2024 20:34:59 +0330 Subject: [PATCH] [Widgets] feat: add image carousel row --- kenar/widgets/image_carousel_row.py | 28 ++++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 kenar/widgets/image_carousel_row.py diff --git a/kenar/widgets/image_carousel_row.py b/kenar/widgets/image_carousel_row.py new file mode 100644 index 0000000..cc7e0b2 --- /dev/null +++ b/kenar/widgets/image_carousel_row.py @@ -0,0 +1,28 @@ + +from typing import List, Dict + +from pydantic import BaseModel + +from kenar.widgets.base import BaseWidget + + +class ImageCarouselRow(BaseModel, BaseWidget): + class ImageCarouselRowItem(BaseModel): + image_url: str + description: str + + items: List[ImageCarouselRowItem] + has_divider: bool = False + + + def serialize_model(self) -> dict: + return { + "widget_type": "IMAGE_CAROUSEL_ROW", + "data": {"@type": "type.googleapis.com/widgets.ImageCarouselRowData"} | self.dict(), + } + + @classmethod + def deserialize_model(cls, data: Dict): + widget_data = data.get("data", {}) + widget_data.pop("@type", None) + return cls.parse_obj(widget_data) diff --git a/setup.py b/setup.py index 1f7aafc..e778354 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='Kenar', - version='0.5.7', + version='0.5.8', author='Nastaran Alipour', author_email='nastaran.alipour78@gmail.com', description='facilitate using kenar divar APIs',