fork of indigo with slightly nicer lexgen
at main 7.0 kB view raw
1// Code generated by cmd/lexgen (see Makefile's lexgen); DO NOT EDIT. 2 3package ozone 4 5// schema: tools.ozone.hosting.getAccountHistory 6 7import ( 8 "context" 9 "encoding/json" 10 "fmt" 11 12 "github.com/bluesky-social/indigo/lex/util" 13) 14 15// HostingGetAccountHistory_AccountCreated is a "accountCreated" in the tools.ozone.hosting.getAccountHistory schema. 16// 17// RECORDTYPE: HostingGetAccountHistory_AccountCreated 18type HostingGetAccountHistory_AccountCreated struct { 19 LexiconTypeID string `json:"$type,const=tools.ozone.hosting.getAccountHistory#accountCreated" cborgen:"$type,const=tools.ozone.hosting.getAccountHistory#accountCreated"` 20 Email *string `json:"email,omitempty" cborgen:"email,omitempty"` 21 Handle *string `json:"handle,omitempty" cborgen:"handle,omitempty"` 22} 23 24// HostingGetAccountHistory_EmailConfirmed is a "emailConfirmed" in the tools.ozone.hosting.getAccountHistory schema. 25// 26// RECORDTYPE: HostingGetAccountHistory_EmailConfirmed 27type HostingGetAccountHistory_EmailConfirmed struct { 28 LexiconTypeID string `json:"$type,const=tools.ozone.hosting.getAccountHistory#emailConfirmed" cborgen:"$type,const=tools.ozone.hosting.getAccountHistory#emailConfirmed"` 29 Email string `json:"email" cborgen:"email"` 30} 31 32// HostingGetAccountHistory_EmailUpdated is a "emailUpdated" in the tools.ozone.hosting.getAccountHistory schema. 33// 34// RECORDTYPE: HostingGetAccountHistory_EmailUpdated 35type HostingGetAccountHistory_EmailUpdated struct { 36 LexiconTypeID string `json:"$type,const=tools.ozone.hosting.getAccountHistory#emailUpdated" cborgen:"$type,const=tools.ozone.hosting.getAccountHistory#emailUpdated"` 37 Email string `json:"email" cborgen:"email"` 38} 39 40// HostingGetAccountHistory_Event is a "event" in the tools.ozone.hosting.getAccountHistory schema. 41type HostingGetAccountHistory_Event struct { 42 CreatedAt string `json:"createdAt" cborgen:"createdAt"` 43 CreatedBy string `json:"createdBy" cborgen:"createdBy"` 44 Details *HostingGetAccountHistory_Event_Details `json:"details" cborgen:"details"` 45} 46 47type HostingGetAccountHistory_Event_Details struct { 48 HostingGetAccountHistory_AccountCreated *HostingGetAccountHistory_AccountCreated 49 HostingGetAccountHistory_EmailUpdated *HostingGetAccountHistory_EmailUpdated 50 HostingGetAccountHistory_EmailConfirmed *HostingGetAccountHistory_EmailConfirmed 51 HostingGetAccountHistory_PasswordUpdated *HostingGetAccountHistory_PasswordUpdated 52 HostingGetAccountHistory_HandleUpdated *HostingGetAccountHistory_HandleUpdated 53} 54 55func (t *HostingGetAccountHistory_Event_Details) MarshalJSON() ([]byte, error) { 56 if t.HostingGetAccountHistory_AccountCreated != nil { 57 t.HostingGetAccountHistory_AccountCreated.LexiconTypeID = "tools.ozone.hosting.getAccountHistory#accountCreated" 58 return json.Marshal(t.HostingGetAccountHistory_AccountCreated) 59 } 60 if t.HostingGetAccountHistory_EmailUpdated != nil { 61 t.HostingGetAccountHistory_EmailUpdated.LexiconTypeID = "tools.ozone.hosting.getAccountHistory#emailUpdated" 62 return json.Marshal(t.HostingGetAccountHistory_EmailUpdated) 63 } 64 if t.HostingGetAccountHistory_EmailConfirmed != nil { 65 t.HostingGetAccountHistory_EmailConfirmed.LexiconTypeID = "tools.ozone.hosting.getAccountHistory#emailConfirmed" 66 return json.Marshal(t.HostingGetAccountHistory_EmailConfirmed) 67 } 68 if t.HostingGetAccountHistory_PasswordUpdated != nil { 69 t.HostingGetAccountHistory_PasswordUpdated.LexiconTypeID = "tools.ozone.hosting.getAccountHistory#passwordUpdated" 70 return json.Marshal(t.HostingGetAccountHistory_PasswordUpdated) 71 } 72 if t.HostingGetAccountHistory_HandleUpdated != nil { 73 t.HostingGetAccountHistory_HandleUpdated.LexiconTypeID = "tools.ozone.hosting.getAccountHistory#handleUpdated" 74 return json.Marshal(t.HostingGetAccountHistory_HandleUpdated) 75 } 76 return nil, fmt.Errorf("cannot marshal empty enum") 77} 78func (t *HostingGetAccountHistory_Event_Details) UnmarshalJSON(b []byte) error { 79 typ, err := util.TypeExtract(b) 80 if err != nil { 81 return err 82 } 83 84 switch typ { 85 case "tools.ozone.hosting.getAccountHistory#accountCreated": 86 t.HostingGetAccountHistory_AccountCreated = new(HostingGetAccountHistory_AccountCreated) 87 return json.Unmarshal(b, t.HostingGetAccountHistory_AccountCreated) 88 case "tools.ozone.hosting.getAccountHistory#emailUpdated": 89 t.HostingGetAccountHistory_EmailUpdated = new(HostingGetAccountHistory_EmailUpdated) 90 return json.Unmarshal(b, t.HostingGetAccountHistory_EmailUpdated) 91 case "tools.ozone.hosting.getAccountHistory#emailConfirmed": 92 t.HostingGetAccountHistory_EmailConfirmed = new(HostingGetAccountHistory_EmailConfirmed) 93 return json.Unmarshal(b, t.HostingGetAccountHistory_EmailConfirmed) 94 case "tools.ozone.hosting.getAccountHistory#passwordUpdated": 95 t.HostingGetAccountHistory_PasswordUpdated = new(HostingGetAccountHistory_PasswordUpdated) 96 return json.Unmarshal(b, t.HostingGetAccountHistory_PasswordUpdated) 97 case "tools.ozone.hosting.getAccountHistory#handleUpdated": 98 t.HostingGetAccountHistory_HandleUpdated = new(HostingGetAccountHistory_HandleUpdated) 99 return json.Unmarshal(b, t.HostingGetAccountHistory_HandleUpdated) 100 101 default: 102 return nil 103 } 104} 105 106// HostingGetAccountHistory_HandleUpdated is a "handleUpdated" in the tools.ozone.hosting.getAccountHistory schema. 107// 108// RECORDTYPE: HostingGetAccountHistory_HandleUpdated 109type HostingGetAccountHistory_HandleUpdated struct { 110 LexiconTypeID string `json:"$type,const=tools.ozone.hosting.getAccountHistory#handleUpdated" cborgen:"$type,const=tools.ozone.hosting.getAccountHistory#handleUpdated"` 111 Handle string `json:"handle" cborgen:"handle"` 112} 113 114// HostingGetAccountHistory_Output is the output of a tools.ozone.hosting.getAccountHistory call. 115type HostingGetAccountHistory_Output struct { 116 Cursor *string `json:"cursor,omitempty" cborgen:"cursor,omitempty"` 117 Events []*HostingGetAccountHistory_Event `json:"events" cborgen:"events"` 118} 119 120// HostingGetAccountHistory_PasswordUpdated is a "passwordUpdated" in the tools.ozone.hosting.getAccountHistory schema. 121// 122// RECORDTYPE: HostingGetAccountHistory_PasswordUpdated 123type HostingGetAccountHistory_PasswordUpdated struct { 124 LexiconTypeID string `json:"$type,const=tools.ozone.hosting.getAccountHistory#passwordUpdated" cborgen:"$type,const=tools.ozone.hosting.getAccountHistory#passwordUpdated"` 125} 126 127// HostingGetAccountHistory calls the XRPC method "tools.ozone.hosting.getAccountHistory". 128func HostingGetAccountHistory(ctx context.Context, c util.LexClient, cursor string, did string, events []string, limit int64) (*HostingGetAccountHistory_Output, error) { 129 var out HostingGetAccountHistory_Output 130 131 params := map[string]interface{}{} 132 if cursor != "" { 133 params["cursor"] = cursor 134 } 135 params["did"] = did 136 if len(events) != 0 { 137 params["events"] = events 138 } 139 if limit != 0 { 140 params["limit"] = limit 141 } 142 if err := c.LexDo(ctx, util.Query, "", "tools.ozone.hosting.getAccountHistory", params, nil, &out); err != nil { 143 return nil, err 144 } 145 146 return &out, nil 147}