Exemple #1
0
    def make_start(sender):
        # Mensaje
        responses = list()
        message = Message(text="Ya no mas filas en el banco")
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        template = ListTemplate(
            style="compact",
            elements=[
                ListElement(
                    title="GENERAR UN TICKET",
                    image_url="https://s14.postimg.org/u9ohxgqsd/obtener.png",
                    subtitle="Ahorra tiempo con tickets electrónicos",
                    buttons=[
                        PostbackButton(title="OBTENER TICKET",
                                       payload="GET_TICKET")
                    ],
                ),
                ListElement(
                    title="MIS TICKETS",
                    image_url=
                    "https://s14.postimg.org/ea5udwuql/mistickets.png",
                    subtitle="Administra los tickets pendientes que tienes",
                    buttons=[
                        PostbackButton(title="VER MIS TICKETS",
                                       payload="MY_TICKETS")
                    ],
                )
            ])
        attachment = TemplateAttachment(template=template)
        message = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))
        return responses
Exemple #2
0
    def make_schedules(sender):
        # Mensaje
        responses = list()
        message = Message(
            text=
            "¿Deseas agendar una cita con un asesor?, (y) Estas son las fechas disponibles"
        )
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        template = ListTemplate(
            style="compact",
            elements=[
                ListElement(
                    title="21 de Diciembre del 2016",
                    image_url="https://s14.postimg.org/hn996fblp/date.jpg",
                    subtitle="15:00 Hrs",
                    buttons=[
                        PostbackButton(title="AGENDAR", payload="AGENDA_1")
                    ],
                ),
                ListElement(
                    title="15 de Enero del 2017",
                    image_url="https://s14.postimg.org/hn996fblp/date.jpg",
                    subtitle="19:00 Hrs.",
                    buttons=[
                        PostbackButton(title="AGENDAR", payload="AGENDA_2")
                    ],
                )
            ])
        attachment = TemplateAttachment(template=template)
        message = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))
        return responses
Exemple #3
0
    def make_promotions(sender):
        """
        Envia la lista de promociones
        """
        promotions = None
        responses = list()
        elements = []

        # Mensaje
        message = Message(
            text="Esta es la lista de promociones esta semana :)", )
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, message))

        # Componente
        for promotion in promotions:
            element = Element(
                title=promotion.name,
                item_url=promotion.url,
                image_url=SERVER_URL + promotion.cover.url,
                subtitle=promotion.description,
                buttons=[URLButton(title="VER", url=promotion.url)])
            elements.append(element)
        template = GenericTemplate(elements=elements)

        attachment = TemplateAttachment(template=template)
        component = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, component))
        return responses
Exemple #4
0
    def make_change(sender):
        responses = list()

        responses.append(Components.typing(responses, sender))
        template = GenericTemplate(elements=[
            Element(
                title="El Dolar Cotiza a 6,929 Bs.",
                subtitle="1 USD = 6,929 Bs.",
                default_action=URLButton(
                    url=
                    "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                ),
                buttons=[
                    URLButton(
                        title="VER OTRAS MONEDAS",
                        url=
                        "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                    )
                ])
        ])
        attachment = TemplateAttachment(template=template)
        component = Message(attachment=attachment)
        responses.append(Components.typing(responses, sender))
        responses.append(MessageRequest(sender, component))
        return responses
Exemple #5
0
 def insufficient_balance(sender):
     responses = list()
     responses.append(Components.typing(responses, sender))
     template = GenericTemplate(elements=[
         Element(
             title="Saldo insuficiente para recargar",
             subtitle="Advertencia",
             buttons=[
                 URLButton(
                     title="OTRA RECARGA",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 ),
                 URLButton(
                     title="CANCELAR",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 )
             ])
     ])
     attachment = TemplateAttachment(template=template)
     component = Message(attachment=attachment)
     responses.append(Components.typing(responses, sender))
     responses.append(MessageRequest(sender, component))
     return responses
Exemple #6
0
 def make_recharge(sender):
     responses = list()
     responses.append(Components.typing(responses, sender))
     template = GenericTemplate(elements=[
         Element(
             title="Se Recargo con exito 50 Bs al 73053045",
             subtitle="Gracias por usar el servicio",
             buttons=[
                 URLButton(
                     title="INICIO",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 ),
                 URLButton(
                     title="HACER OTRA RECARGA",
                     url=
                     "https://www.bcb.gob.bo/librerias/indicadores/otras/ultimo.php"
                 )
             ])
     ])
     attachment = TemplateAttachment(template=template)
     component = Message(attachment=attachment)
     responses.append(Components.typing(responses, sender))
     responses.append(MessageRequest(sender, component))
     return responses
Exemple #7
0
    def make_own_tickets(sender):
        # tickets = Ticket.objects.all()
        tickets = list()
        responses = list()
        elements = []
        if tickets.count() > 0:
            # Mensaje
            message = Message(text="Estos son tus tickets", )
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))

            # Componente
            for ticket in tickets:
                lat, lng = Components.get_position(ticket.branch)
                if ticket.type == "CASH":
                    tty = "CAJA"
                else:
                    tty = "PLATAFORMA"

                element = Element(
                    title="%s: %s" % (tty, ticket.code),
                    subtitle="%s: %s" % (ticket.branch.bank.name, ticket.branch.name),
                    default_action=URLButton(
                        url=Components.get_map_url(lat, lng)
                    ),
                    buttons=[
                        PostbackButton(
                            title="CANCELAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "CANCEL_TICKET",
                                "id": ticket.id
                            }
                        ),
                        PostbackButton(
                            title="RENOVAR",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "REGENERATE_TICKET",
                                "id": ticket.id
                            }
                        )
                    ]
                )
                elements.append(element)
            template = GenericTemplate(
                elements=elements
            )

            attachment = TemplateAttachment(template=template)
            component = Message(attachment=attachment)
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, component))

        else:
            message = Message(text="No tienes tickets")
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))
        return responses
Exemple #8
0
def get_receipt_template(sender):

    template = ReceiptTemplate(
        recipient_name="Stephane Crozatier",
        order_number="12345678902",
        currency="USD",
        payment_method="Visa 2345",
        order_url="http://petersapparel.parseapp.com/order?order_id=123456",
        timestamp="1428444852",
        elements=[
            ReceiptElement(
                title="Classic White T-Shirt",
                subtitle="100% Soft and Luxurious Cotton",
                quantity=2,
                price=50,
                currency="USD",
                image_url="http://petersapparel.parseapp.com/img/whiteshirt.png"
            ),
            ReceiptElement(
                title="Classic Gray T-Shirt",
                subtitle="100% Soft and Luxurious Cotton",
                quantity=1,
                price=25,
                currency="USD",
                image_url="http://petersapparel.parseapp.com/img/grayshirt.png"
            )
        ],
        address=ReceiptAddress(
            street_1="1 Hacker Way",
            street_2="",
            city="Menlo Park",
            postal_code="94025",
            state="CA",
            country="US",
        ),
        summary=Summary(
            subtotal=75.00,
            shipping_cost=4.95,
            total_tax=6.19,
            total_cost=56.14,
        ),
        adjustments=[
            Adjustment(
                name="New Customer Discount",
                amount=20,
            ),
            Adjustment(
                name="$10 Off Coupon",
                amount=10,
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #9
0
def get_call_button(sender):
    template = ButtonTemplate(
        text="Necesitas llamar al representante?",
        buttons=[
            CallButton(
                title="Llamar al representante",
                payload="+591 73053045"
            )
        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #10
0
def get_logout_button(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Cerrar Sesión",
                image_url="https://goo.gl/Lg2CHu",
                buttons=[
                    LogoutButton()
                ]
            )
        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #11
0
def get_share_button(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Asi deben saber los humanos",
                subtitle="Mientras tanto en otro universo",
                image_url="https://goo.gl/Lg2CHu",
                buttons=[
                    ShareButton()
                ]
            )
        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #12
0
    def make_atms(sender):
        """
        Envia la lista de Suscripciones de un usuario o la peticion para registrar una suscripción
        """
        branches = None
        responses = list()
        elements = []
        if branches.count() > 0:
            # Mensaje
            message = Message(text="Esta es la lista de Cajeros cerca :)", )
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))

            # Componente
            for branch in branches:
                lat, lng = Components.get_position(branch)
                element = Element(
                    title=branch.name,
                    item_url=Components.get_map_url(lat, lng),
                    image_url=Components.get_map_screen(lat, lng),
                    subtitle=branch.address,
                    buttons=[
                        PostbackButton(
                            title="VER",
                            payload="%(payload)s:%(id)s" % {
                                "payload": "SELECT_BRANCH",
                                "id": branch.id
                            }
                        )
                    ]
                )
                elements.append(element)
            template = GenericTemplate(
                elements=elements
            )

            attachment = TemplateAttachment(template=template)
            component = Message(attachment=attachment)
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, component))

        else:
            message = Message(text="No hay cajeros registrados :(")
            responses.append(Components.typing(responses, sender))
            responses.append(MessageRequest(sender, message))
        return responses
Exemple #13
0
def get_login_button(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Iniciar Sesión en Chuspita",
                image_url="https://goo.gl/Lg2CHu",
                buttons=[
                    LoginButton(
                        url="https://oepbolivia.xya/login"
                    )
                ]
            )
        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #14
0
def get_button_template(sender):

    template = ButtonTemplate(
        text='Que quieres hacer?',
        buttons=[
            URLButton(
                title='Show website',
                url='https://oepbolivia.xyz/'
            ),
            PostbackButton(
                title='Start chatting',
                payload='USER_DEFINED_PAYLOAD'
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #15
0
def get_generic_template(sender):
    template = GenericTemplate(
        elements=[
            Element(
                title="Welcome to Peter\'s Hats",
                item_url="https://oepbolivia.xyz/",
                image_url="https://upload.wikimedia.org/wikipedia/en/5/5e/Avatar(Neytiri).jpg",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                    PostbackButton(
                        title="Start Chatting",
                        payload="PAYLOAD"
                    )
                ]
            ),
            Element(
                title="HOLA MUNDO",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
                buttons=[
                    URLButton(
                        url="https://oepbolivia.xyz/",
                        title="View Website"
                    ),
                ]
            ),
            Element(
                title="TERCERA PARTE",
                item_url="https://oepbolivia.xyz/",
                image_url="https://goo.gl/wODF4W",
                subtitle="Weve got the right hat for everyone.",
            )

        ]
    )

    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)
Exemple #16
0
def get_list_template(sender):
    template = ListTemplate(
        style="large",
        elements=[
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/tqQNHV",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/shop_collection",
                    webview_height_ratio=URLButton.RATIO_TALL,
                ),
                buttons=[
                    URLButton(
                        title="View",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic T-Shirt Collection",
                image_url="https://goo.gl/JYkzoW",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=100",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/shop?item=100",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Blue T-Shirt",
                image_url="https://goo.gl/tqQNHV",
                subtitle="100% Cotton, 200% Comfortable",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=101",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
            ListElement(
                title="Classic Black T-Shirt",
                image_url="https://goo.gl/W2J5rE",
                subtitle="See all our colors",
                default_action=URLButton(
                    url="https://peterssendreceiveapp.ngrok.io/view?item=102",
                    webview_height_ratio=URLButton.RATIO_TALL
                ),
                buttons=[
                    URLButton(
                        title="Shop Now",
                        url="https://peterssendreceiveapp.ngrok.io/collection",
                        webview_height_ratio=URLButton.RATIO_TALL
                    )
                ],
            ),
        ],
        buttons=[
            PostbackButton(
                title="Ver mas",
                payload="UNDEFINED_PAYLOAD"
            )
        ]
    )
    attachment = TemplateAttachment(template=template)
    message = Message(attachment=attachment)
    return MessageRequest(sender, message)