simplex_bot_actor/src/message_types.nim

57 lines
1.4 KiB
Nim

import
preserves, std/tables
type
Resp* {.preservesRecord: "resp".} = ref object
`time`*: RespItem
RespItemKind* {.pure.} = enum
`NewChatItem`, `Attributes`
`RespItem`* {.preservesOr.} = ref object
case orKind*: RespItemKind
of RespItemKind.`NewChatItem`:
`newchatitem`*: NewChatItem
of RespItemKind.`Attributes`:
`attributes`*: Attributes
Attributes* = Table[string, Preserve[void]]
NewChatItemField0* {.preservesDictionary.} = ref object
`"chatItem"`*: ChatItem0
NewChatItem* {.preservesRecord: "newChatItem".} = ref object
`field0`*: NewChatItemField0
ChatInfo* {.preservesDictionary.} = ref object
`"chatInfo"`*: ChatInfo
`"chatItem"`*: ChatItem1
Content* = Attributes
ChatItem0* {.preservesDictionary.} = ref object
`"chatInfo"`*: ChatInfo
`"user"`*: User
User* {.preservesDictionary.} = object
`"activeUser"`*: bool
`"agentUserId"`*: string
`"localDisplayName"`*: string
`"userContactId"`*: BiggestInt
`"userId"`*: BiggestInt
ChatItem1* {.preservesDictionary.} = object
`"content"`*: Content
proc `$`*(x: Resp | RespItem | Attributes | NewChatItem | ChatInfo | Content |
ChatItem0 |
User |
ChatItem1): string =
`$`(toPreserve(x))
proc encode*(x: Resp | RespItem | Attributes | NewChatItem | ChatInfo | Content |
ChatItem0 |
User |
ChatItem1): seq[byte] =
encode(toPreserve(x))