Skip to content

Instantly share code, notes, and snippets.

@xsobolx
Created May 30, 2018 20:26
Show Gist options
  • Select an option

  • Save xsobolx/27117b17ac5ea49695372856ec451f03 to your computer and use it in GitHub Desktop.

Select an option

Save xsobolx/27117b17ac5ea49695372856ec451f03 to your computer and use it in GitHub Desktop.
enum class EnvelopeType {
CHAT_MESSAGE, CHAT_NEW, MESSAGE_STATUS, CHAT_UPDATED
}
enum class PayloadType {
TEXT_MESSAGE, IMAGE_MESSAGE
}
enum class MessageStatusType {
FAILED, SENDING, DELIVERED_TO_SERVER, DELIVERED_TO_RECIPIENT, READED, DELETED
}
enum class ChatUpdatedReason {
RECIPIENT_ADDED, RECIPIENT_DELETED
}
interface Envelope
data class ChatMessage (
@SerializedName("message_id") val messageId: String,
@SerializedName("sender_id") val senderId: String,
@SerializedName("sender_name") val senderName: String,
@SerializedName("timestamp") val timestamp: Long,
@SerializedName("chat_id") val chatId: String,
@SerializedName("payload_type") val payloadType: PayloadType,
@SerializedName("payload") val data: Payload
) : Envelope
data class ChatNew (
@SerializedName("chat_id") val chatId: String,
@SerializedName("created_at") val created: Long,
@SerializedName("recipients") val recipients: List<String>
) : Envelope
data class ChatUpdayed (
@SerializedName("chat_id") val chatId: String,
@SerializedName("created_at") val created: Long,
@SerializedName("updated_at") val updated: Long,
@SerializedName("recipients") val recipients: List<String>,
@SerializedName("reason") val reason: ChatUpdatedReason
)
data class MessageStatus (
@SerializedName("chat_id") val chatId: String,
@SerializedName("message_id") val messageId: String,
@SerializedName("status") val status: MessageStatusType
) : Envelope
data class Event (
@SerializedName("event_id") val eventId: String,
@SerializedName("sync_id") val syncId: String,
@SerializedName("envelope_type") val envelopeType: EnvelopeType,
@SerializedName("envelope") val envelope: Envelope
)
interface Payload
data class TextMessage (
@SerializedName("message") val message: String
) : Payload
data class ImageMessage (
@SerializedName("original") val original: String,
@SerializedName("original_size") val originalSize: Long,
@SerializedName("thumbnail") val thumbnail: String,
@SerializedName("thumbnail_size") val thumbnailSize: String,
@SerializedName("media_type") val mediaType: String
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment