1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package bsky
4
5// schema: app.bsky.graph.getRelationships
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// GraphGetRelationships_Output is the output of a app.bsky.graph.getRelationships call.
17type GraphGetRelationships_Output struct {
18 Actor *string `json:"actor,omitempty" cborgen:"actor,omitempty"`
19 Relationships []*GraphGetRelationships_Output_Relationships_Elem `json:"relationships" cborgen:"relationships"`
20}
21
22type GraphGetRelationships_Output_Relationships_Elem struct {
23 GraphDefs_Relationship *GraphDefs_Relationship
24 GraphDefs_NotFoundActor *GraphDefs_NotFoundActor
25}
26
27func (t *GraphGetRelationships_Output_Relationships_Elem) MarshalJSON() ([]byte, error) {
28 if t.GraphDefs_Relationship != nil {
29 t.GraphDefs_Relationship.LexiconTypeID = "app.bsky.graph.defs#relationship"
30 return json.Marshal(t.GraphDefs_Relationship)
31 }
32 if t.GraphDefs_NotFoundActor != nil {
33 t.GraphDefs_NotFoundActor.LexiconTypeID = "app.bsky.graph.defs#notFoundActor"
34 return json.Marshal(t.GraphDefs_NotFoundActor)
35 }
36 return nil, fmt.Errorf("cannot marshal empty enum")
37}
38func (t *GraphGetRelationships_Output_Relationships_Elem) UnmarshalJSON(b []byte) error {
39 typ, err := util.TypeExtract(b)
40 if err != nil {
41 return err
42 }
43
44 switch typ {
45 case "app.bsky.graph.defs#relationship":
46 t.GraphDefs_Relationship = new(GraphDefs_Relationship)
47 return json.Unmarshal(b, t.GraphDefs_Relationship)
48 case "app.bsky.graph.defs#notFoundActor":
49 t.GraphDefs_NotFoundActor = new(GraphDefs_NotFoundActor)
50 return json.Unmarshal(b, t.GraphDefs_NotFoundActor)
51
52 default:
53 return nil
54 }
55}
56
57// GraphGetRelationships calls the XRPC method "app.bsky.graph.getRelationships".
58//
59// actor: Primary account requesting relationships for.
60// others: List of 'other' accounts to be related back to the primary.
61func GraphGetRelationships(ctx context.Context, c *xrpc.Client, actor string, others []string) (*GraphGetRelationships_Output, error) {
62 var out GraphGetRelationships_Output
63
64 params := map[string]interface{}{
65 "actor": actor,
66 "others": others,
67 }
68 if err := c.Do(ctx, xrpc.Query, "", "app.bsky.graph.getRelationships", params, nil, &out); err != nil {
69 return nil, err
70 }
71
72 return &out, nil
73}