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