1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.feed.getPostThread
6
7import (
8 "context"
9 "encoding/json"
10 "fmt"
11
12 "github.com/bluesky-social/indigo/lex/util"
13 "github.com/bluesky-social/indigo/xrpc"
14)
15
16// FeedGetPostThread_Output is the output of a app.bsky.feed.getPostThread call.
17type FeedGetPostThread_Output struct {
18 Thread *FeedGetPostThread_Output_Thread `json:"thread" cborgen:"thread"`
19 Threadgate *FeedDefs_ThreadgateView `json:"threadgate,omitempty" cborgen:"threadgate,omitempty"`
20}
21
22type FeedGetPostThread_Output_Thread struct {
23 FeedDefs_ThreadViewPost *FeedDefs_ThreadViewPost
24 FeedDefs_NotFoundPost *FeedDefs_NotFoundPost
25 FeedDefs_BlockedPost *FeedDefs_BlockedPost
26}
27
28func (t *FeedGetPostThread_Output_Thread) MarshalJSON() ([]byte, error) {
29 if t.FeedDefs_ThreadViewPost != nil {
30 t.FeedDefs_ThreadViewPost.LexiconTypeID = "app.bsky.feed.defs#threadViewPost"
31 return json.Marshal(t.FeedDefs_ThreadViewPost)
32 }
33 if t.FeedDefs_NotFoundPost != nil {
34 t.FeedDefs_NotFoundPost.LexiconTypeID = "app.bsky.feed.defs#notFoundPost"
35 return json.Marshal(t.FeedDefs_NotFoundPost)
36 }
37 if t.FeedDefs_BlockedPost != nil {
38 t.FeedDefs_BlockedPost.LexiconTypeID = "app.bsky.feed.defs#blockedPost"
39 return json.Marshal(t.FeedDefs_BlockedPost)
40 }
41 return nil, fmt.Errorf("cannot marshal empty enum")
42}
43func (t *FeedGetPostThread_Output_Thread) UnmarshalJSON(b []byte) error {
44 typ, err := util.TypeExtract(b)
45 if err != nil {
46 return err
47 }
48
49 switch typ {
50 case "app.bsky.feed.defs#threadViewPost":
51 t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost)
52 return json.Unmarshal(b, t.FeedDefs_ThreadViewPost)
53 case "app.bsky.feed.defs#notFoundPost":
54 t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost)
55 return json.Unmarshal(b, t.FeedDefs_NotFoundPost)
56 case "app.bsky.feed.defs#blockedPost":
57 t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost)
58 return json.Unmarshal(b, t.FeedDefs_BlockedPost)
59
60 default:
61 return nil
62 }
63}
64
65// FeedGetPostThread calls the XRPC method "app.bsky.feed.getPostThread".
66//
67// depth: How many levels of reply depth should be included in response.
68// parentHeight: How many levels of parent (and grandparent, etc) post to include.
69// uri: Reference (AT-URI) to post record.
70func FeedGetPostThread(ctx context.Context, c *xrpc.Client, depth int64, parentHeight int64, uri string) (*FeedGetPostThread_Output, error) {
71 var out FeedGetPostThread_Output
72
73 params := map[string]interface{}{
74 "depth": depth,
75 "parentHeight": parentHeight,
76 "uri": uri,
77 }
78 if err := c.Do(ctx, xrpc.Query, "", "app.bsky.feed.getPostThread", params, nil, &out); err != nil {
79 return nil, err
80 }
81
82 return &out, nil
83}