A fork of https://github.com/teal-fm/piper
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT.
2
3package atproto
4
5// schema: com.atproto.moderation.createReport
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// ModerationCreateReport_Input is the input argument to a com.atproto.moderation.createReport call.
17type ModerationCreateReport_Input struct {
18 // reason: Additional context about the content and violation.
19 Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
20 // reasonType: Indicates the broad category of violation the report is for.
21 ReasonType *string `json:"reasonType" cborgen:"reasonType"`
22 Subject *ModerationCreateReport_Input_Subject `json:"subject" cborgen:"subject"`
23}
24
25type ModerationCreateReport_Input_Subject struct {
26 AdminDefs_RepoRef *AdminDefs_RepoRef
27 RepoStrongRef *RepoStrongRef
28}
29
30func (t *ModerationCreateReport_Input_Subject) MarshalJSON() ([]byte, error) {
31 if t.AdminDefs_RepoRef != nil {
32 t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
33 return json.Marshal(t.AdminDefs_RepoRef)
34 }
35 if t.RepoStrongRef != nil {
36 t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
37 return json.Marshal(t.RepoStrongRef)
38 }
39 return nil, fmt.Errorf("cannot marshal empty enum")
40}
41func (t *ModerationCreateReport_Input_Subject) UnmarshalJSON(b []byte) error {
42 typ, err := util.TypeExtract(b)
43 if err != nil {
44 return err
45 }
46
47 switch typ {
48 case "com.atproto.admin.defs#repoRef":
49 t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
50 return json.Unmarshal(b, t.AdminDefs_RepoRef)
51 case "com.atproto.repo.strongRef":
52 t.RepoStrongRef = new(RepoStrongRef)
53 return json.Unmarshal(b, t.RepoStrongRef)
54
55 default:
56 return nil
57 }
58}
59
60// ModerationCreateReport_Output is the output of a com.atproto.moderation.createReport call.
61type ModerationCreateReport_Output struct {
62 CreatedAt string `json:"createdAt" cborgen:"createdAt"`
63 Id int64 `json:"id" cborgen:"id"`
64 Reason *string `json:"reason,omitempty" cborgen:"reason,omitempty"`
65 ReasonType *string `json:"reasonType" cborgen:"reasonType"`
66 ReportedBy string `json:"reportedBy" cborgen:"reportedBy"`
67 Subject *ModerationCreateReport_Output_Subject `json:"subject" cborgen:"subject"`
68}
69
70type ModerationCreateReport_Output_Subject struct {
71 AdminDefs_RepoRef *AdminDefs_RepoRef
72 RepoStrongRef *RepoStrongRef
73}
74
75func (t *ModerationCreateReport_Output_Subject) MarshalJSON() ([]byte, error) {
76 if t.AdminDefs_RepoRef != nil {
77 t.AdminDefs_RepoRef.LexiconTypeID = "com.atproto.admin.defs#repoRef"
78 return json.Marshal(t.AdminDefs_RepoRef)
79 }
80 if t.RepoStrongRef != nil {
81 t.RepoStrongRef.LexiconTypeID = "com.atproto.repo.strongRef"
82 return json.Marshal(t.RepoStrongRef)
83 }
84 return nil, fmt.Errorf("cannot marshal empty enum")
85}
86func (t *ModerationCreateReport_Output_Subject) UnmarshalJSON(b []byte) error {
87 typ, err := util.TypeExtract(b)
88 if err != nil {
89 return err
90 }
91
92 switch typ {
93 case "com.atproto.admin.defs#repoRef":
94 t.AdminDefs_RepoRef = new(AdminDefs_RepoRef)
95 return json.Unmarshal(b, t.AdminDefs_RepoRef)
96 case "com.atproto.repo.strongRef":
97 t.RepoStrongRef = new(RepoStrongRef)
98 return json.Unmarshal(b, t.RepoStrongRef)
99
100 default:
101 return nil
102 }
103}
104
105// ModerationCreateReport calls the XRPC method "com.atproto.moderation.createReport".
106func ModerationCreateReport(ctx context.Context, c *xrpc.Client, input *ModerationCreateReport_Input) (*ModerationCreateReport_Output, error) {
107 var out ModerationCreateReport_Output
108 if err := c.Do(ctx, xrpc.Procedure, "application/json", "com.atproto.moderation.createReport", nil, input, &out); err != nil {
109 return nil, err
110 }
111
112 return &out, nil
113}