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)
14
15// FeedGetPostThread_Output is the output of a app.bsky.feed.getPostThread call.
16type FeedGetPostThread_Output struct {
17 Thread *FeedGetPostThread_Output_Thread `json:"thread" cborgen:"thread"`
18 Threadgate *FeedDefs_ThreadgateView `json:"threadgate,omitempty" cborgen:"threadgate,omitempty"`
19}
20
21type FeedGetPostThread_Output_Thread struct {
22 FeedDefs_ThreadViewPost *FeedDefs_ThreadViewPost
23 FeedDefs_NotFoundPost *FeedDefs_NotFoundPost
24 FeedDefs_BlockedPost *FeedDefs_BlockedPost
25}
26
27func (t *FeedGetPostThread_Output_Thread) MarshalJSON() ([]byte, error) {
28 if t.FeedDefs_ThreadViewPost != nil {
29 t.FeedDefs_ThreadViewPost.LexiconTypeID = "app.bsky.feed.defs#threadViewPost"
30 return json.Marshal(t.FeedDefs_ThreadViewPost)
31 }
32 if t.FeedDefs_NotFoundPost != nil {
33 t.FeedDefs_NotFoundPost.LexiconTypeID = "app.bsky.feed.defs#notFoundPost"
34 return json.Marshal(t.FeedDefs_NotFoundPost)
35 }
36 if t.FeedDefs_BlockedPost != nil {
37 t.FeedDefs_BlockedPost.LexiconTypeID = "app.bsky.feed.defs#blockedPost"
38 return json.Marshal(t.FeedDefs_BlockedPost)
39 }
40 return nil, fmt.Errorf("cannot marshal empty enum")
41}
42func (t *FeedGetPostThread_Output_Thread) UnmarshalJSON(b []byte) error {
43 typ, err := util.TypeExtract(b)
44 if err != nil {
45 return err
46 }
47
48 switch typ {
49 case "app.bsky.feed.defs#threadViewPost":
50 t.FeedDefs_ThreadViewPost = new(FeedDefs_ThreadViewPost)
51 return json.Unmarshal(b, t.FeedDefs_ThreadViewPost)
52 case "app.bsky.feed.defs#notFoundPost":
53 t.FeedDefs_NotFoundPost = new(FeedDefs_NotFoundPost)
54 return json.Unmarshal(b, t.FeedDefs_NotFoundPost)
55 case "app.bsky.feed.defs#blockedPost":
56 t.FeedDefs_BlockedPost = new(FeedDefs_BlockedPost)
57 return json.Unmarshal(b, t.FeedDefs_BlockedPost)
58
59 default:
60 return nil
61 }
62}
63
64// FeedGetPostThread calls the XRPC method "app.bsky.feed.getPostThread".
65//
66// depth: How many levels of reply depth should be included in response.
67// parentHeight: How many levels of parent (and grandparent, etc) post to include.
68// uri: Reference (AT-URI) to post record.
69func FeedGetPostThread(ctx context.Context, c util.LexClient, depth int64, parentHeight int64, uri string) (*FeedGetPostThread_Output, error) {
70 var out FeedGetPostThread_Output
71
72 params := map[string]interface{}{}
73 if depth != 0 {
74 params["depth"] = depth
75 }
76 if parentHeight != 0 {
77 params["parentHeight"] = parentHeight
78 }
79 params["uri"] = uri
80 if err := c.LexDo(ctx, util.Query, "", "app.bsky.feed.getPostThread", params, nil, &out); err != nil {
81 return nil, err
82 }
83
84 return &out, nil
85}