Skip to content

Commit

Permalink
[Widgets] feat: add image carousel row
Browse files Browse the repository at this point in the history
  • Loading branch information
amirsalarsafaei committed Oct 2, 2024
1 parent 39fdb2d commit 3e3f4e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions kenar/widgets/image_carousel_row.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='Kenar',
version='0.5.7',
version='0.5.8',
author='Nastaran Alipour',
author_email='[email protected]',
description='facilitate using kenar divar APIs',
Expand Down

0 comments on commit 3e3f4e4

Please sign in to comment.