// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. package tangled // schema: sh.tangled.feed.getTimeline import ( "context" "encoding/json" "fmt" "github.com/bluesky-social/indigo/lex/util" ) const ( FeedGetTimelineNSID = "sh.tangled.feed.getTimeline" ) // FeedGetTimeline_FollowEvent is a "followEvent" in the sh.tangled.feed.getTimeline schema. // // A user followed another user. // // RECORDTYPE: FeedGetTimeline_FollowEvent type FeedGetTimeline_FollowEvent struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.getTimeline#followEvent" cborgen:"$type,const=sh.tangled.feed.getTimeline#followEvent"` Actor *ActorDefs_ProfileViewBasic `json:"actor" cborgen:"actor"` Cid string `json:"cid" cborgen:"cid"` Subject *ActorDefs_ProfileViewDetailed `json:"subject" cborgen:"subject"` Uri string `json:"uri" cborgen:"uri"` } // FeedGetTimeline_Output is the output of a sh.tangled.feed.getTimeline call. type FeedGetTimeline_Output struct { Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` Feed []*FeedGetTimeline_TimelineItem `json:"feed" cborgen:"feed"` } // FeedGetTimeline_RepoEvent is a "repoEvent" in the sh.tangled.feed.getTimeline schema. // // A repository was created (or forked). The actor is repo.owner. // // RECORDTYPE: FeedGetTimeline_RepoEvent type FeedGetTimeline_RepoEvent struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.getTimeline#repoEvent" cborgen:"$type,const=sh.tangled.feed.getTimeline#repoEvent"` Cid string `json:"cid" cborgen:"cid"` Repo *RepoDefs_RepoViewBasic `json:"repo" cborgen:"repo"` // source: Fork parent, present only if this repo is a fork. Source *RepoDefs_RepoViewBasic `json:"source,omitempty" cborgen:"source,omitempty"` Uri string `json:"uri" cborgen:"uri"` } // FeedGetTimeline_StarEvent is a "starEvent" in the sh.tangled.feed.getTimeline schema. // // A repository was starred. // // RECORDTYPE: FeedGetTimeline_StarEvent type FeedGetTimeline_StarEvent struct { LexiconTypeID string `json:"$type,const=sh.tangled.feed.getTimeline#starEvent" cborgen:"$type,const=sh.tangled.feed.getTimeline#starEvent"` // actor: Who starred. Actor *ActorDefs_ProfileViewBasic `json:"actor" cborgen:"actor"` Cid string `json:"cid" cborgen:"cid"` // repo: The starred repo. Repo *RepoDefs_RepoViewBasic `json:"repo" cborgen:"repo"` Uri string `json:"uri" cborgen:"uri"` } // FeedGetTimeline_TimelineItem is a "timelineItem" in the sh.tangled.feed.getTimeline schema. type FeedGetTimeline_TimelineItem struct { Event *FeedGetTimeline_TimelineItem_Event `json:"event" cborgen:"event"` EventAt string `json:"eventAt" cborgen:"eventAt"` } type FeedGetTimeline_TimelineItem_Event struct { FeedGetTimeline_RepoEvent *FeedGetTimeline_RepoEvent FeedGetTimeline_StarEvent *FeedGetTimeline_StarEvent FeedGetTimeline_FollowEvent *FeedGetTimeline_FollowEvent } func (t *FeedGetTimeline_TimelineItem_Event) MarshalJSON() ([]byte, error) { if t.FeedGetTimeline_RepoEvent != nil { t.FeedGetTimeline_RepoEvent.LexiconTypeID = "sh.tangled.feed.getTimeline#repoEvent" return json.Marshal(t.FeedGetTimeline_RepoEvent) } if t.FeedGetTimeline_StarEvent != nil { t.FeedGetTimeline_StarEvent.LexiconTypeID = "sh.tangled.feed.getTimeline#starEvent" return json.Marshal(t.FeedGetTimeline_StarEvent) } if t.FeedGetTimeline_FollowEvent != nil { t.FeedGetTimeline_FollowEvent.LexiconTypeID = "sh.tangled.feed.getTimeline#followEvent" return json.Marshal(t.FeedGetTimeline_FollowEvent) } return nil, fmt.Errorf("cannot marshal empty enum") } func (t *FeedGetTimeline_TimelineItem_Event) UnmarshalJSON(b []byte) error { typ, err := util.TypeExtract(b) if err != nil { return err } switch typ { case "sh.tangled.feed.getTimeline#repoEvent": t.FeedGetTimeline_RepoEvent = new(FeedGetTimeline_RepoEvent) return json.Unmarshal(b, t.FeedGetTimeline_RepoEvent) case "sh.tangled.feed.getTimeline#starEvent": t.FeedGetTimeline_StarEvent = new(FeedGetTimeline_StarEvent) return json.Unmarshal(b, t.FeedGetTimeline_StarEvent) case "sh.tangled.feed.getTimeline#followEvent": t.FeedGetTimeline_FollowEvent = new(FeedGetTimeline_FollowEvent) return json.Unmarshal(b, t.FeedGetTimeline_FollowEvent) default: return nil } } // FeedGetTimeline calls the XRPC method "sh.tangled.feed.getTimeline". // // viewer: TODO: deprecate this and use auth instead. func FeedGetTimeline(ctx context.Context, c util.LexClient, cursor string, followingOnly bool, limit int64, viewer string) (*FeedGetTimeline_Output, error) { var out FeedGetTimeline_Output params := map[string]interface{}{} if cursor != "" { params["cursor"] = cursor } if followingOnly { params["followingOnly"] = followingOnly } if limit != 0 { params["limit"] = limit } if viewer != "" { params["viewer"] = viewer } if err := c.LexDo(ctx, util.Query, "", "sh.tangled.feed.getTimeline", params, nil, &out); err != nil { return nil, err } return &out, nil }