2021-09-08 18:05:39 +00:00
|
|
|
import json
|
|
|
|
|
|
|
|
import base
|
2021-09-08 20:55:37 +00:00
|
|
|
import signal_type
|
2021-09-08 18:05:39 +00:00
|
|
|
|
|
|
|
type MailserverRequestCompletedSignal* = ref object of Signal
|
|
|
|
requestID*: string
|
|
|
|
lastEnvelopeHash*: string
|
|
|
|
cursor*: string
|
|
|
|
errorMessage*: string
|
|
|
|
error*: bool
|
|
|
|
|
|
|
|
type MailserverRequestExpiredSignal* = ref object of Signal
|
|
|
|
# TODO
|
|
|
|
|
2021-09-08 20:55:37 +00:00
|
|
|
proc fromEvent*(T: type MailserverRequestCompletedSignal, jsonSignal: JsonNode): MailserverRequestCompletedSignal =
|
|
|
|
result = MailserverRequestCompletedSignal()
|
|
|
|
result.signalType = SignalType.MailserverRequestCompleted
|
2021-09-08 18:05:39 +00:00
|
|
|
if jsonSignal["event"].kind != JNull:
|
2021-09-08 20:55:37 +00:00
|
|
|
result.requestID = jsonSignal["event"]{"requestID"}.getStr()
|
|
|
|
result.lastEnvelopeHash = jsonSignal["event"]{"lastEnvelopeHash"}.getStr()
|
|
|
|
result.cursor = jsonSignal["event"]{"cursor"}.getStr()
|
|
|
|
result.errorMessage = jsonSignal["event"]{"errorMessage"}.getStr()
|
|
|
|
result.error = result.errorMessage != ""
|
2021-09-08 18:05:39 +00:00
|
|
|
|
2021-09-08 20:55:37 +00:00
|
|
|
proc fromEvent*(T: type MailserverRequestExpiredSignal, jsonSignal: JsonNode): MailserverRequestExpiredSignal =
|
2021-09-08 18:05:39 +00:00
|
|
|
# TODO: parse signal
|
2021-09-08 20:55:37 +00:00
|
|
|
result = MailserverRequestExpiredSignal()
|
|
|
|
result.signalType = SignalType.MailserverRequestExpired
|