// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
package org_tangled
// schema: org.tangled.feed.getTimeline
import (
"context"
"encoding/json"
"fmt"
"github.com/bluesky-social/indigo/lex/util"
)
const (
FeedGetTimelineNSID = "org.tangled.feed.getTimeline"
)
// FeedGetTimeline_FollowEvent is a "followEvent" in the org.tangled.feed.getTimeline schema.
//
// A user followed another user.
//
// RECORDTYPE: FeedGetTimeline_FollowEvent
type FeedGetTimeline_FollowEvent struct {
LexiconTypeID string `json:"$type,const=org.tangled.feed.getTimeline#followEvent" cborgen:"$type,const=org.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 org.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 org.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=org.tangled.feed.getTimeline#repoEvent" cborgen:"$type,const=org.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 org.tangled.feed.getTimeline schema.
//
// A repository was starred.
//
// RECORDTYPE: FeedGetTimeline_StarEvent
type FeedGetTimeline_StarEvent struct {
LexiconTypeID string `json:"$type,const=org.tangled.feed.getTimeline#starEvent" cborgen:"$type,const=org.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 org.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 = "org.tangled.feed.getTimeline#repoEvent"
return json.Marshal(t.FeedGetTimeline_RepoEvent)
}
if t.FeedGetTimeline_StarEvent != nil {
t.FeedGetTimeline_StarEvent.LexiconTypeID = "org.tangled.feed.getTimeline#starEvent"
return json.Marshal(t.FeedGetTimeline_StarEvent)
}
if t.FeedGetTimeline_FollowEvent != nil {
t.FeedGetTimeline_FollowEvent.LexiconTypeID = "org.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 "org.tangled.feed.getTimeline#repoEvent":
t.FeedGetTimeline_RepoEvent = new(FeedGetTimeline_RepoEvent)
return json.Unmarshal(b, t.FeedGetTimeline_RepoEvent)
case "org.tangled.feed.getTimeline#starEvent":
t.FeedGetTimeline_StarEvent = new(FeedGetTimeline_StarEvent)
return json.Unmarshal(b, t.FeedGetTimeline_StarEvent)
case "org.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 "org.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, "", "org.tangled.feed.getTimeline", params, nil, &out); err != nil {
return nil, err
}
return &out, nil
}