import datetime
import typing


class CustomAlert:
    def __init__(self,
                 id: int,
                 external_id: typing.Union[str, None],
                 header: typing.Union[str, None],
                 message: typing.Union[str, None],
                 image_url: typing.Union[str, None],
                 sound_url: typing.Union[str, None],
                 is_shown: int,
                 created_at: str,
                 shown_at: typing.Union[str, None],
                 **kwargs):
        """
        Custom alerts are the fully content-customizable alerts that allow the developer to create uniquely designed alerts and send it to the streamer's broadcast. It is required for the streamer to have a variation for the Alerts widget with "Custom alerts" type for custom alerts to display. Send Custom Alerts

        :param id: The unique custom alert identifier
        :param external_id: Unique alert ID generated by the application developer. Or null if ID was not provided
        :param header: Text that will be displayed as a header. Or null if text was not provided
        :param message: Text that will be displayed inside the message box. Or null if text was not provided
        :param image_url: URL to the image file that will displayed along with the custom alert. Or null if URL was not provided
        :param sound_url: URL to the sound file that will played when displaying the custom alert. Or null if URL was not provided
        :param is_shown: A flag indicating whether the alert was shown in the streamer's widget required
        :param created_at: The date and time (YYYY-MM-DD HH.MM.SS formatted) when custom alert was created
        :param shown_at: Date and time indicating when the alert was shown (YYYY-MM-DD HH.MM.SS formatted). Or null if the alert is not shown yet
        """

        self.id = id
        self.external_id = external_id
        self.header = header,
        self.message = message
        self.image_url = image_url
        self.sound_url = sound_url
        self.is_shown = is_shown
        date_format = "%Y-%m-%d %H:%M:%S"  # YYYY-MM-DD HH.MM.SS
        self.created_at = datetime.datetime.strptime(created_at, date_format)
        self.shown_at = datetime.datetime.strptime(shown_at, date_format) if shown_at else None

    def __repr__(self):
        return str(self.__dict__)
