New models for quick replies

This commit is contained in:
Kacper Ziubryniewicz
2018-12-09 00:32:44 +01:00
parent 492465a525
commit be968e0caa

View File

@@ -445,21 +445,18 @@ class Mention(object):
return '<Mention {}: offset={} length={}>'.format(self.thread_id, self.offset, self.length) return '<Mention {}: offset={} length={}>'.format(self.thread_id, self.offset, self.length)
class QuickReply(object): class QuickReply(object):
#: Title of the quick reply #: Type of the quick reply
title = None type = None
#: URL of the quick reply image (optional) #: Payload of the quick reply
image_url = None
#: Custom identifier of the quick reply
payload = None payload = None
#: Additional data #: Additional data
data = None data = None
#: Whether it's a response for a quick reply #: Whether it's a response for a quick reply
is_response = None is_response = None
def __init__(self, title, image_url=None, payload=None, data=None, is_response=False): def __init__(self, _type=None, payload=None, data=None, is_response=False):
"""Represents a quick reply""" """Represents a quick reply"""
self.title = title self.type = _type
self.image_url = image_url
self.payload = payload self.payload = payload
self.data = data self.data = data
self.is_response = is_response self.is_response = is_response
@@ -468,7 +465,44 @@ class QuickReply(object):
return self.__unicode__() return self.__unicode__()
def __unicode__(self): def __unicode__(self):
return '<QuickReply: title={!r} payload={!r}>'.format(self.title, self.payload) return '<QuickReply: type={!r} payload={!r}>'.format(self.type, self.payload)
class QuickReplyText(QuickReply):
#: Title of the quick reply
title = None
#: URL of the quick reply image (optional)
image_url = None
def __init__(self, title=None, image_url=None, **kwargs):
"""Represents a text quick reply"""
super(QuickReplyText, self).__init__(_type=QuickReplyType.TEXT, **kwargs)
self.title = title
self.image_url = image_url
class QuickReplyLocation(QuickReply):
def __init__(self, **kwargs):
"""Represents a location quick reply"""
super(QuickReplyLocation, self).__init__(_type=QuickReplyType.LOCATION, **kwargs)
self.is_response = False
class QuickReplyPhoneNumber(QuickReply):
#: URL of the quick reply image (optional)
image_url = None
def __init__(self, image_url=None, **kwargs):
"""Represents a phone number quick reply"""
super(QuickReplyPhoneNumber, self).__init__(_type=QuickReplyType.PHONE_NUMBER, **kwargs)
self.image_url = image_url
class QuickReplyEmail(QuickReply):
#: URL of the quick reply image (optional)
image_url = None
def __init__(self, image_url=None, **kwargs):
"""Represents an email quick reply"""
super(QuickReplyEmail, self).__init__(_type=QuickReplyType.EMAIL, **kwargs)
self.image_url = image_url
class Poll(object): class Poll(object):
#: ID of the poll #: ID of the poll
@@ -557,6 +591,12 @@ class Enum(enum.Enum):
# For documentation: # For documentation:
return '{}.{}'.format(type(self).__name__, self.name) return '{}.{}'.format(type(self).__name__, self.name)
class QuickReplyType(Enum):
TEXT = 'TEXT'
LOCATION = 'LOCATION'
PHONE_NUMBER = 'USER_PHONE_NUMBER'
EMAIL = 'USER_EMAIL'
class ThreadType(Enum): class ThreadType(Enum):
"""Used to specify what type of Facebook thread is being used. See :ref:`intro_threads` for more info""" """Used to specify what type of Facebook thread is being used. See :ref:`intro_threads` for more info"""
USER = 1 USER = 1