-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel_channel_event_detail.go
355 lines (301 loc) · 9.73 KB
/
model_channel_event_detail.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
traQ v3
traQ v3 API
API version: 3.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package traq
import (
"encoding/json"
"fmt"
)
// ChannelEventDetail - イベント内容
type ChannelEventDetail struct {
ChildCreatedEvent *ChildCreatedEvent
ForcedNotificationChangedEvent *ForcedNotificationChangedEvent
NameChangedEvent *NameChangedEvent
ParentChangedEvent *ParentChangedEvent
PinAddedEvent *PinAddedEvent
PinRemovedEvent *PinRemovedEvent
SubscribersChangedEvent *SubscribersChangedEvent
TopicChangedEvent *TopicChangedEvent
VisibilityChangedEvent *VisibilityChangedEvent
}
// ChildCreatedEventAsChannelEventDetail is a convenience function that returns ChildCreatedEvent wrapped in ChannelEventDetail
func ChildCreatedEventAsChannelEventDetail(v *ChildCreatedEvent) ChannelEventDetail {
return ChannelEventDetail{
ChildCreatedEvent: v,
}
}
// ForcedNotificationChangedEventAsChannelEventDetail is a convenience function that returns ForcedNotificationChangedEvent wrapped in ChannelEventDetail
func ForcedNotificationChangedEventAsChannelEventDetail(v *ForcedNotificationChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
ForcedNotificationChangedEvent: v,
}
}
// NameChangedEventAsChannelEventDetail is a convenience function that returns NameChangedEvent wrapped in ChannelEventDetail
func NameChangedEventAsChannelEventDetail(v *NameChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
NameChangedEvent: v,
}
}
// ParentChangedEventAsChannelEventDetail is a convenience function that returns ParentChangedEvent wrapped in ChannelEventDetail
func ParentChangedEventAsChannelEventDetail(v *ParentChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
ParentChangedEvent: v,
}
}
// PinAddedEventAsChannelEventDetail is a convenience function that returns PinAddedEvent wrapped in ChannelEventDetail
func PinAddedEventAsChannelEventDetail(v *PinAddedEvent) ChannelEventDetail {
return ChannelEventDetail{
PinAddedEvent: v,
}
}
// PinRemovedEventAsChannelEventDetail is a convenience function that returns PinRemovedEvent wrapped in ChannelEventDetail
func PinRemovedEventAsChannelEventDetail(v *PinRemovedEvent) ChannelEventDetail {
return ChannelEventDetail{
PinRemovedEvent: v,
}
}
// SubscribersChangedEventAsChannelEventDetail is a convenience function that returns SubscribersChangedEvent wrapped in ChannelEventDetail
func SubscribersChangedEventAsChannelEventDetail(v *SubscribersChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
SubscribersChangedEvent: v,
}
}
// TopicChangedEventAsChannelEventDetail is a convenience function that returns TopicChangedEvent wrapped in ChannelEventDetail
func TopicChangedEventAsChannelEventDetail(v *TopicChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
TopicChangedEvent: v,
}
}
// VisibilityChangedEventAsChannelEventDetail is a convenience function that returns VisibilityChangedEvent wrapped in ChannelEventDetail
func VisibilityChangedEventAsChannelEventDetail(v *VisibilityChangedEvent) ChannelEventDetail {
return ChannelEventDetail{
VisibilityChangedEvent: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *ChannelEventDetail) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into ChildCreatedEvent
err = newStrictDecoder(data).Decode(&dst.ChildCreatedEvent)
if err == nil {
jsonChildCreatedEvent, _ := json.Marshal(dst.ChildCreatedEvent)
if string(jsonChildCreatedEvent) == "{}" { // empty struct
dst.ChildCreatedEvent = nil
} else {
match++
}
} else {
dst.ChildCreatedEvent = nil
}
// try to unmarshal data into ForcedNotificationChangedEvent
err = newStrictDecoder(data).Decode(&dst.ForcedNotificationChangedEvent)
if err == nil {
jsonForcedNotificationChangedEvent, _ := json.Marshal(dst.ForcedNotificationChangedEvent)
if string(jsonForcedNotificationChangedEvent) == "{}" { // empty struct
dst.ForcedNotificationChangedEvent = nil
} else {
match++
}
} else {
dst.ForcedNotificationChangedEvent = nil
}
// try to unmarshal data into NameChangedEvent
err = newStrictDecoder(data).Decode(&dst.NameChangedEvent)
if err == nil {
jsonNameChangedEvent, _ := json.Marshal(dst.NameChangedEvent)
if string(jsonNameChangedEvent) == "{}" { // empty struct
dst.NameChangedEvent = nil
} else {
match++
}
} else {
dst.NameChangedEvent = nil
}
// try to unmarshal data into ParentChangedEvent
err = newStrictDecoder(data).Decode(&dst.ParentChangedEvent)
if err == nil {
jsonParentChangedEvent, _ := json.Marshal(dst.ParentChangedEvent)
if string(jsonParentChangedEvent) == "{}" { // empty struct
dst.ParentChangedEvent = nil
} else {
match++
}
} else {
dst.ParentChangedEvent = nil
}
// try to unmarshal data into PinAddedEvent
err = newStrictDecoder(data).Decode(&dst.PinAddedEvent)
if err == nil {
jsonPinAddedEvent, _ := json.Marshal(dst.PinAddedEvent)
if string(jsonPinAddedEvent) == "{}" { // empty struct
dst.PinAddedEvent = nil
} else {
match++
}
} else {
dst.PinAddedEvent = nil
}
// try to unmarshal data into PinRemovedEvent
err = newStrictDecoder(data).Decode(&dst.PinRemovedEvent)
if err == nil {
jsonPinRemovedEvent, _ := json.Marshal(dst.PinRemovedEvent)
if string(jsonPinRemovedEvent) == "{}" { // empty struct
dst.PinRemovedEvent = nil
} else {
match++
}
} else {
dst.PinRemovedEvent = nil
}
// try to unmarshal data into SubscribersChangedEvent
err = newStrictDecoder(data).Decode(&dst.SubscribersChangedEvent)
if err == nil {
jsonSubscribersChangedEvent, _ := json.Marshal(dst.SubscribersChangedEvent)
if string(jsonSubscribersChangedEvent) == "{}" { // empty struct
dst.SubscribersChangedEvent = nil
} else {
match++
}
} else {
dst.SubscribersChangedEvent = nil
}
// try to unmarshal data into TopicChangedEvent
err = newStrictDecoder(data).Decode(&dst.TopicChangedEvent)
if err == nil {
jsonTopicChangedEvent, _ := json.Marshal(dst.TopicChangedEvent)
if string(jsonTopicChangedEvent) == "{}" { // empty struct
dst.TopicChangedEvent = nil
} else {
match++
}
} else {
dst.TopicChangedEvent = nil
}
// try to unmarshal data into VisibilityChangedEvent
err = newStrictDecoder(data).Decode(&dst.VisibilityChangedEvent)
if err == nil {
jsonVisibilityChangedEvent, _ := json.Marshal(dst.VisibilityChangedEvent)
if string(jsonVisibilityChangedEvent) == "{}" { // empty struct
dst.VisibilityChangedEvent = nil
} else {
match++
}
} else {
dst.VisibilityChangedEvent = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.ChildCreatedEvent = nil
dst.ForcedNotificationChangedEvent = nil
dst.NameChangedEvent = nil
dst.ParentChangedEvent = nil
dst.PinAddedEvent = nil
dst.PinRemovedEvent = nil
dst.SubscribersChangedEvent = nil
dst.TopicChangedEvent = nil
dst.VisibilityChangedEvent = nil
return fmt.Errorf("data matches more than one schema in oneOf(ChannelEventDetail)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(ChannelEventDetail)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src ChannelEventDetail) MarshalJSON() ([]byte, error) {
if src.ChildCreatedEvent != nil {
return json.Marshal(&src.ChildCreatedEvent)
}
if src.ForcedNotificationChangedEvent != nil {
return json.Marshal(&src.ForcedNotificationChangedEvent)
}
if src.NameChangedEvent != nil {
return json.Marshal(&src.NameChangedEvent)
}
if src.ParentChangedEvent != nil {
return json.Marshal(&src.ParentChangedEvent)
}
if src.PinAddedEvent != nil {
return json.Marshal(&src.PinAddedEvent)
}
if src.PinRemovedEvent != nil {
return json.Marshal(&src.PinRemovedEvent)
}
if src.SubscribersChangedEvent != nil {
return json.Marshal(&src.SubscribersChangedEvent)
}
if src.TopicChangedEvent != nil {
return json.Marshal(&src.TopicChangedEvent)
}
if src.VisibilityChangedEvent != nil {
return json.Marshal(&src.VisibilityChangedEvent)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *ChannelEventDetail) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.ChildCreatedEvent != nil {
return obj.ChildCreatedEvent
}
if obj.ForcedNotificationChangedEvent != nil {
return obj.ForcedNotificationChangedEvent
}
if obj.NameChangedEvent != nil {
return obj.NameChangedEvent
}
if obj.ParentChangedEvent != nil {
return obj.ParentChangedEvent
}
if obj.PinAddedEvent != nil {
return obj.PinAddedEvent
}
if obj.PinRemovedEvent != nil {
return obj.PinRemovedEvent
}
if obj.SubscribersChangedEvent != nil {
return obj.SubscribersChangedEvent
}
if obj.TopicChangedEvent != nil {
return obj.TopicChangedEvent
}
if obj.VisibilityChangedEvent != nil {
return obj.VisibilityChangedEvent
}
// all schemas are nil
return nil
}
type NullableChannelEventDetail struct {
value *ChannelEventDetail
isSet bool
}
func (v NullableChannelEventDetail) Get() *ChannelEventDetail {
return v.value
}
func (v *NullableChannelEventDetail) Set(val *ChannelEventDetail) {
v.value = val
v.isSet = true
}
func (v NullableChannelEventDetail) IsSet() bool {
return v.isSet
}
func (v *NullableChannelEventDetail) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableChannelEventDetail(val *ChannelEventDetail) *NullableChannelEventDetail {
return &NullableChannelEventDetail{value: val, isSet: true}
}
func (v NullableChannelEventDetail) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableChannelEventDetail) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}