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