from __future__ import annotations def build_bubble_message( header_text: str | None = None, body_sections: list[dict] | None = None, footer_text: str | None = None, hero_url: str | None = None, alt_text: str = "Flex Message", ) -> dict: contents: dict = {"type": "bubble"} if hero_url: contents["hero"] = { "type": "image", "url": hero_url, "size": "full", "aspectRatio": "20:13", "aspectMode": "cover", } if header_text: contents["header"] = { "type": "box", "layout": "vertical", "contents": [{"type": "text", "text": header_text, "weight": "bold", "size": "lg"}], } if body_sections: contents["body"] = { "type": "box", "layout": "vertical", "contents": list(body_sections), } if footer_text: contents["footer"] = { "type": "box", "layout": "vertical", "contents": [{"type": "text", "text": footer_text, "size": "sm", "color": "#aaaaaa"}], } return { "type": "flex", "altText": alt_text[:400], "contents": contents, } def build_carousel_message(bubbles: list[dict], alt_text: str = "Carousel Message") -> dict: return { "type": "flex", "altText": alt_text[:400], "contents": { "type": "carousel", "contents": bubbles[:12], }, }