// Code generated by glex; DO NOT EDIT. // Lexicon schema: place.stream.like package placestream import ( "encoding/json" "io" glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen" ) func init() { glex.RegisterType("place.stream.like", &Like{}) } // Record indicating a like on some other record (e.g. a video or a comment). type Like struct { LexiconTypeID string `json:"$type,omitempty"` // createdAt: Client-declared timestamp when this like was created. CreatedAt string `json:"createdAt"` // subject: AT-URI of the record being liked (e.g. a place.stream.video or place.stream.vod.comment). Subject string `json:"subject"` } // RecordTypeID implements glex.Record. func (t *Like) RecordTypeID() string { return "place.stream.like" } // MarshalJSON stamps the $type field, like MarshalCBOR does. The value // receiver operates on a copy, so the record is never mutated and both // Like and *Like marshal with $type. func (t Like) MarshalJSON() ([]byte, error) { t.LexiconTypeID = "place.stream.like" type alias Like return json.Marshal((alias)(t)) } func (t *Like) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) return err } // stamp $type on a copy so marshal never mutates the record cp := *t cp.LexiconTypeID = "place.stream.like" return glex.MarshalCBOR(w, &cp) } func (t *Like) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t) }