Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
6.2 kB · 166 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167// Code generated by glex; DO NOT EDIT.
// Lexicon schema: place.stream.live.getRecommendations
package placestream
import ( "context" "encoding/json" "fmt" "io"
glex "github.com/streamplace/glex/runtime" cbg "github.com/whyrusleeping/cbor-gen")
type LiveGetRecommendations_Output struct { LexiconTypeID string `json:"$type,omitempty"` // recommendations: Ordered list of recommendations Recommendations []LiveGetRecommendations_Output_Recommendations_Elem `json:"recommendations"` // userDID: The user DID this recommendation is for UserDID *string `json:"userDID,omitempty"`}
// RecordTypeID implements glex.Record.func (t *LiveGetRecommendations_Output) RecordTypeID() string { return "place.stream.live.getRecommendations"}
func (t *LiveGetRecommendations_Output) 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.live.getRecommendations" return glex.MarshalCBOR(w, &cp)}
func (t *LiveGetRecommendations_Output) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}
type LiveGetRecommendations_Output_Recommendations_Elem struct { LiveGetRecommendations_LivestreamRecommendation *LiveGetRecommendations_LivestreamRecommendation // Raw preserves a variant whose $type is not in this union's generated // set, so unrecognized variants still round-trip losslessly through // decode/re-encode. Nil when a known variant is set. Raw *glex.RawRecord}
// MarshalJSON emits the set variant, stamped with its $type, per the atproto// union wire format. The value receiver stamps a copy, so the variant is// never mutated and both LiveGetRecommendations_Output_Recommendations_Elem and *LiveGetRecommendations_Output_Recommendations_Elem marshal correctly.func (t LiveGetRecommendations_Output_Recommendations_Elem) MarshalJSON() ([]byte, error) { if t.LiveGetRecommendations_LivestreamRecommendation != nil { cp := *t.LiveGetRecommendations_LivestreamRecommendation cp.LexiconTypeID = "place.stream.live.getRecommendations#livestreamRecommendation" return json.Marshal(&cp) } if t.Raw != nil { if t.Raw.Encoding != "json" { return nil, fmt.Errorf("cannot marshal raw %s record as JSON in union LiveGetRecommendations_Output_Recommendations_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union LiveGetRecommendations_Output_Recommendations_Elem as JSON")}
func (t *LiveGetRecommendations_Output_Recommendations_Elem) UnmarshalJSON(b []byte) error { typ, err := glex.TypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.live.getRecommendations#livestreamRecommendation": t.LiveGetRecommendations_LivestreamRecommendation = new(LiveGetRecommendations_LivestreamRecommendation) return json.Unmarshal(b, t.LiveGetRecommendations_LivestreamRecommendation) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "json", Bytes: append([]byte(nil), b...)} return nil }}
// MarshalCBOR implements drisl.Marshaler, emitting the set variant (stamped// with its $type) per the atproto union wire format. go-dasl invokes this// when the union appears inside another record, so nested unions serialize// correctly.func (t LiveGetRecommendations_Output_Recommendations_Elem) MarshalCBOR() ([]byte, error) { if t.LiveGetRecommendations_LivestreamRecommendation != nil { cp := *t.LiveGetRecommendations_LivestreamRecommendation cp.LexiconTypeID = "place.stream.live.getRecommendations#livestreamRecommendation" return glex.MarshalCBORBytes(&cp) } if t.Raw != nil { if t.Raw.Encoding != "cbor" { return nil, fmt.Errorf("cannot marshal raw %s record as CBOR in union LiveGetRecommendations_Output_Recommendations_Elem", t.Raw.Encoding) } return t.Raw.Bytes, nil } return nil, fmt.Errorf("cannot marshal empty union LiveGetRecommendations_Output_Recommendations_Elem as CBOR")}
func (t *LiveGetRecommendations_Output_Recommendations_Elem) UnmarshalCBOR(b []byte) error { typ, err := glex.CborTypeExtract(b) if err != nil { return err }
switch typ { case "place.stream.live.getRecommendations#livestreamRecommendation": t.LiveGetRecommendations_LivestreamRecommendation = new(LiveGetRecommendations_LivestreamRecommendation) return glex.UnmarshalCBORBytes(b, t.LiveGetRecommendations_LivestreamRecommendation) default: t.Raw = &glex.RawRecord{Type: typ, Encoding: "cbor", Bytes: append([]byte(nil), b...)} return nil }}
// LiveGetRecommendations calls the XRPC method "place.stream.live.getRecommendations".//// # Get the list of streamers recommended by a user//// userDID: The DID of the user whose recommendations to fetchfunc LiveGetRecommendations(ctx context.Context, c glex.LexClient, userDID string) (*LiveGetRecommendations_Output, error) { var out LiveGetRecommendations_Output
params := map[string]interface{}{} params["userDID"] = userDID
if err := c.LexDo(ctx, glex.Query, "", "place.stream.live.getRecommendations", params, nil, &out); err != nil { return nil, err } return &out, nil}
// LiveGetRecommendations_LivestreamRecommendation is a "livestreamRecommendation" in the place.stream.live.getRecommendations schema.type LiveGetRecommendations_LivestreamRecommendation struct { LexiconTypeID string `json:"$type,omitempty"` // did: The DID of the recommended streamer Did string `json:"did"` // source: Source of the recommendation Source string `json:"source"`}
// RecordTypeID implements glex.Record.func (t *LiveGetRecommendations_LivestreamRecommendation) RecordTypeID() string { return "place.stream.live.getRecommendations#livestreamRecommendation"}
func (t *LiveGetRecommendations_LivestreamRecommendation) 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.live.getRecommendations#livestreamRecommendation" return glex.MarshalCBOR(w, &cp)}
func (t *LiveGetRecommendations_LivestreamRecommendation) UnmarshalCBOR(r io.Reader) error { return glex.UnmarshalCBOR(r, t)}