class ChannelSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField("Unique identifier of channels", read_only=True) name = ZopsStringField("Name of channel") description = ZopsStringField("Short description of channel") channelType = ZopsStringField( "Type of channel e.g. `public`, `private`, `invisible`, `public-announcement`, " "`private-announcement`, and `invisible-announcement`", validators=[channel_type_validator], source="type") subscribers = ZopsListOfAlphaNumericStringsField( "List of subscribers of channel", read_only=True) lastMessage = ZopsJsonObjectField("Last message string text, sender, date", read_only=True, source="last_message") owners = ZopsListOfAlphaNumericStringsField( "Subscriber(s) who owns channel", read_only=True, source="owner") managers = ZopsListOfAlphaNumericStringsField( "Subscriber(s) who can manage channel", read_only=True) invitees = ZopsListOfAlphaNumericStringsField( "Subscribers who are invited to join to channel", read_only=True) joinRequests = ZopsListOfAlphaNumericStringsField( "The requests sent by candidate subscribers of channel", read_only=True, source="join_requests") bannedSubscribers = ZopsListOfAlphaNumericStringsField( "Subscribers who are banned from channel", read_only=True, source='banned_subscribers')
class UserTagSerializer(ZopsBaseDBSerializer): userId = ZopsAlphaNumericStringField( "Unique identifier of the user which is desired to be tagged with given key and its value", source='user_id', write_only=True) key = ZopsStringField("Unique name of the tag in the set of tags of user") valueWrite = ZopsStringField( "Value of the tag which is specified with name `key`. It can be diversified " "by the type of the tag. If its type is `key`, value to write must be `null`. " "If its type is `key-value`, value can vary by the `valueType`. " "It can be a string, an integer and a float. If its type is `multi`, " "just as in the `key-value`, it can consist of strings, integers or " "floats, but mixed types are not supported. So, for instance, a tag " "that have `multi` as `tagType` and `str` as `valueType` can only " "include strings as values of itself.", write_only=True, source='value_write') valueRead = ZopsJsonObjectField( "Value of the tag which is specified with name `key`. Previously written values can be read" " from this field. For `tagType`s `key`, `key-value` and `multi`, `valueRead` can be an " "empty array, an array including only one value and an array including more than one values" " respectively.", read_only=True, source='value_read')
class MessageSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField("Unique identifier of message", read_only=True) title = ZopsStringField("Generally null, it can be used rarely in more complex scenarios") body = ZopsStringField("Message content, max 1K string.") sender = ZopsAlphaNumericStringField("Subscriber id of message sender", read_only=True) receiver = ZopsAlphaNumericStringField("Subscriber id of message receiver") # e.g 2017-08-20T08:54:56.750Z00:00 sentTime = ZopsDatetimeField("Time of client device") channel = ZopsAlphaNumericStringField("Channel id of which channel the message is sent to.")
class TagSerializer(ZopsBaseDBSerializer): name = ZopsAlphaNumericStringField("Alphanumeric key of tag") tagType = ZopsStringField( "Type of tag indicating the tag is in type key, key-value or multi", validators=[tag_type_validator], source="tag_type") valueType = ZopsStringField( "Type of value of tag which can be int, str or float", validators=[tag_value_type_validator], source="value_type")
class StatusSerializer(ZopsBaseDBSerializer): subscriberId = ZopsAlphaNumericStringField("Unique identifier of subscriber whose status being " "retrieved", read_only=True, source='subscriber_id') lastActivityTime = ZopsDatetimeField("Time that subscriber last status update sent", source='last_activity_time') statusMessage = ZopsStringField("Status message, user defined status description " "e.g. **I am busy right now**", source='status_message') behavioralStatus = ZopsStringField("Status defines the subscriber is `online`, `idle`, or " "`offline`.", source='behavioral_status', validators=[behavioral_status_validator]) statusIntentional = ZopsStringField( "Intentional status defined by subscriber itself. e.g. Busy", source='status_intentional')
class ContactRequestSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField("Unique identifier of contact request", read_only=True) inviter = ZopsAlphaNumericStringField( "User id of subscriber who sends the contact request", read_only=True) invitee = ZopsAlphaNumericStringField( "User id of subscriber to be a contact") contactRequestMessage = ZopsStringField("Contact request message", source='message') approve = ZopsStringField("approved, rejected, not_evaluated", validators=[invite_approve_validator], write_only=True)
class InviteSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField("Unique identifier of invites", read_only=True) inviter = ZopsAlphaNumericStringField( "Subscriber id of who send invitation", read_only=True) invitee = ZopsAlphaNumericStringField( "Subscriber id of whose intended to be sent invitation") channel = ZopsAlphaNumericStringField( "Channel to which subscriber is invited or made join " "request") inviteMessage = ZopsStringField("Invitation message", source="invite_message") approve = ZopsStringField("approved, rejected, not_evaluated", validators=[invite_approve_validator])
class AdminChannelSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField("Unique identifier of channels", read_only=True) name = ZopsStringField("Name of channel") description = ZopsStringField("Short description of channel") channelType = ZopsStringField( "Type of channel e.g. `public`, `private`, `invisible`, `public-announcement`, " "`private-announcement`, and `invisible-announcement`", validators=[channel_type_validator], source="type") subscribers = ZopsListOfAlphaNumericStringsField( "List of subscribers of channel") managers = ZopsListOfAlphaNumericStringsField( "Subscriber(s) who can manage channel", validators=[manager_length_validator])
class UserTokenSerializer(ZopsBaseSerializer): refreshToken = ZopsStringField( "Token which is taken from SaaS or this resource previously. It " "does not expire unless updated.", source='refresh_token', validators=[validate_is_not_null]) accessToken = ZopsStringField( "Token which is taken from this resource by POST request. Its expire time specified with " "the expiresIn field.", read_only=True, source='access_token', validators=[validate_is_not_null]) expiresIn = ZopsIntegerField("Access token's expires time", read_only=True, source='expires_in', validators=[validate_is_not_null])
class SegmentSerializer(ZopsBaseDBSerializer): segmentId = ZopsAlphaNumericStringField("Unique identifier of the segment", source='id', read_only=True) name = ZopsStringField("Name of the segment.") residents = ZopsJsonObjectField( "Object representation of the expressions which define the " "target audience of the push message", validators=[residents_validator])
class ClientSerializer(ZopsBaseDBSerializer): clientId = ZopsStringField("Unique identifier of a client", source='id', read_only=True) token = ZopsStringField( "Token obtained from client's notification service such as APNs, FCM etc.", write_only=True) appVersion = ZopsStringField("Version of client application", source='app_version') deviceType = ZopsStringField( "Device type of client(android or ios for now).", source='device_type', validators=[device_type_validator]) language = ZopsStringField("Language of client") country = ZopsStringField("Country") osVersion = ZopsStringField("Operating System Version", source='os_version')
class MeSerializer(ZopsBaseDBSerializer): id = ZopsAlphaNumericStringField( "Unique identifier of the subscriber itself", read_only=True) contacts = ZopsListOfAlphaNumericStringsField( "List of contacts of subscriber", read_only=True) channels = ZopsJsonObjectField("List of channels of subscriber", read_only=True) bannedChannels = ZopsListOfAlphaNumericStringsField( "List of channels banned by subscriber", read_only=True, source='banned_channels') bannedSubscribers = ZopsListOfAlphaNumericStringsField( "List of subscribers banned by " "subscriber", read_only=True, source='banned_subscribers') lastStatusMessage = ZopsStringField("Last status message of subscriber", read_only=True, source='last_status_message') channelInvites = ZopsListOfAlphaNumericStringsField( "List of channel invitations of subscriber", read_only=True, source='channel_invites') channelJoinRequests = ZopsListOfAlphaNumericStringsField( "List of channel join requests of subscriber", read_only=True, source='channel_join_requests') contactRequestsIn = ZopsListOfAlphaNumericStringsField( "List of contact requests to subscriber", read_only=True, source='contact_requests_in') contactRequestsOut = ZopsListOfAlphaNumericStringsField( "List of contact requests from subscriber", read_only=True, source='contact_requests_out')
class MessageSerializer(ZopsBaseDBSerializer): messageId = ZopsAlphaNumericStringField("Unique identifier of the push message", read_only=True, source='id') sender = ZopsAlphaNumericStringField("Sender of the message", read_only=True, source="target_id") title = ZopsStringField("Title of the push message. Optional.") body = ZopsStringField("Body of the push message.") type = ZopsAlphaNumericStringField( "Type of the push message. It can be automated, scheduled, ordinary") language = ZopsStringField("Language") icon = ZopsStringField("Icon url") image = ZopsStringField("Image url") badge = ZopsStringField("Badge of your app icon.") consumers = ZopsListOfStringsField("List of consumers", validators=[list_of_consumer_validator]) audience = ZopsAlphaNumericStringField( "Id of a previously created segment to send push message") #todo: if message type ordinary scheduletime must be null scheduleTime = ZopsDatetimeField( "Time of message will be pushed if message type is scheduled, else it must be null.", source="schedule_time") extra = ZopsJsonObjectField("Extra data for Apple Devices")