Guest User

Untitled

a guest
Jan 14th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 1.26 KB | None | 0 0
  1. # I'm using httpclient to access a API, and unmarshall responses to different types
  2. # Below are examples of some of the types I am using.
  3. # I have a specific response that returns a ScheduleData object, however, the type of the broadcast field of it
  4. # varies, it will either end up being nil or a Broadcast object.
  5. # I'm not sure how to handle this properly in Nim. In golang, I know you would use like an interface.
  6.  
  7. type
  8.     Broadcast* = object
  9.         broadcastId*: int
  10.         userId*: int
  11.         title*: string
  12.         status*: int
  13.         state*: string
  14.         channelId*: int
  15.         created*: string
  16.         started*: string
  17.         ended*: string
  18.         permalink*: string
  19.         thumbnailData*: string
  20.         tags*: seq[string]
  21.         socketUrl*: string
  22.         streams*: Streams
  23.         streamUrl*: string
  24.         streamKey*: string
  25.         relativeTimestamp*: int
  26.         links*: Links
  27.  
  28.     ScheduleData* = object
  29.         active*: bool
  30.         atCapacity*: bool
  31.         showId*: string
  32.         showType*: string
  33.         startTime*: string
  34.         nextShowTime*: string
  35.         upcoming*: seq[Upcoming]
  36.         broadcast*: Broadcast
  37.         nextGameType*: string
  38.         gameType*: string
  39.         media*: string
  40.         broadcastFull*: bool
Advertisement
Add Comment
Please, Sign In to add comment