-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel__v2_files_get_200_response_data_inner.go
More file actions
234 lines (199 loc) · 6.21 KB
/
Copy pathmodel__v2_files_get_200_response_data_inner.go
File metadata and controls
234 lines (199 loc) · 6.21 KB
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
/*
Attio API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 2.0.0
Contact: support@attio.com
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package libattio
import (
"encoding/json"
"fmt"
)
// checks if the V2FilesGet200ResponseDataInner type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &V2FilesGet200ResponseDataInner{}
// V2FilesGet200ResponseDataInner struct for V2FilesGet200ResponseDataInner
type V2FilesGet200ResponseDataInner struct {
ConnectedFile *ConnectedFile
ConnectedFolder *ConnectedFolder
File *File
Folder *Folder
}
// Unmarshal JSON data into any of the pointers in the struct
func (dst *V2FilesGet200ResponseDataInner) UnmarshalJSON(data []byte) error {
var err error
// use discriminator value to speed up the lookup
var jsonDict map[string]interface{}
err = json.Unmarshal(data, &jsonDict)
if err != nil {
return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
}
// check if the discriminator value is 'connected-file'
if jsonDict["file_type"] == "connected-file" {
// try to unmarshal JSON data into ConnectedFile
err = json.Unmarshal(data, &dst.ConnectedFile)
if err == nil {
jsonConnectedFile, _ := json.Marshal(dst.ConnectedFile)
if string(jsonConnectedFile) == "{}" { // empty struct
dst.ConnectedFile = nil
} else {
return nil // data stored in dst.ConnectedFile, return on the first match
}
} else {
dst.ConnectedFile = nil
}
}
// check if the discriminator value is 'connected-folder'
if jsonDict["file_type"] == "connected-folder" {
// try to unmarshal JSON data into ConnectedFolder
err = json.Unmarshal(data, &dst.ConnectedFolder)
if err == nil {
jsonConnectedFolder, _ := json.Marshal(dst.ConnectedFolder)
if string(jsonConnectedFolder) == "{}" { // empty struct
dst.ConnectedFolder = nil
} else {
return nil // data stored in dst.ConnectedFolder, return on the first match
}
} else {
dst.ConnectedFolder = nil
}
}
// check if the discriminator value is 'file'
if jsonDict["file_type"] == "file" {
// try to unmarshal JSON data into File
err = json.Unmarshal(data, &dst.File)
if err == nil {
jsonFile, _ := json.Marshal(dst.File)
if string(jsonFile) == "{}" { // empty struct
dst.File = nil
} else {
return nil // data stored in dst.File, return on the first match
}
} else {
dst.File = nil
}
}
// check if the discriminator value is 'folder'
if jsonDict["file_type"] == "folder" {
// try to unmarshal JSON data into Folder
err = json.Unmarshal(data, &dst.Folder)
if err == nil {
jsonFolder, _ := json.Marshal(dst.Folder)
if string(jsonFolder) == "{}" { // empty struct
dst.Folder = nil
} else {
return nil // data stored in dst.Folder, return on the first match
}
} else {
dst.Folder = nil
}
}
// try to unmarshal JSON data into ConnectedFile
err = json.Unmarshal(data, &dst.ConnectedFile)
if err == nil {
jsonConnectedFile, _ := json.Marshal(dst.ConnectedFile)
if string(jsonConnectedFile) == "{}" { // empty struct
dst.ConnectedFile = nil
} else {
return nil // data stored in dst.ConnectedFile, return on the first match
}
} else {
dst.ConnectedFile = nil
}
// try to unmarshal JSON data into ConnectedFolder
err = json.Unmarshal(data, &dst.ConnectedFolder)
if err == nil {
jsonConnectedFolder, _ := json.Marshal(dst.ConnectedFolder)
if string(jsonConnectedFolder) == "{}" { // empty struct
dst.ConnectedFolder = nil
} else {
return nil // data stored in dst.ConnectedFolder, return on the first match
}
} else {
dst.ConnectedFolder = nil
}
// try to unmarshal JSON data into File
err = json.Unmarshal(data, &dst.File)
if err == nil {
jsonFile, _ := json.Marshal(dst.File)
if string(jsonFile) == "{}" { // empty struct
dst.File = nil
} else {
return nil // data stored in dst.File, return on the first match
}
} else {
dst.File = nil
}
// try to unmarshal JSON data into Folder
err = json.Unmarshal(data, &dst.Folder)
if err == nil {
jsonFolder, _ := json.Marshal(dst.Folder)
if string(jsonFolder) == "{}" { // empty struct
dst.Folder = nil
} else {
return nil // data stored in dst.Folder, return on the first match
}
} else {
dst.Folder = nil
}
return fmt.Errorf("data failed to match schemas in anyOf(V2FilesGet200ResponseDataInner)")
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src V2FilesGet200ResponseDataInner) MarshalJSON() ([]byte, error) {
if src.ConnectedFile != nil {
return json.Marshal(&src.ConnectedFile)
}
if src.ConnectedFolder != nil {
return json.Marshal(&src.ConnectedFolder)
}
if src.File != nil {
return json.Marshal(&src.File)
}
if src.Folder != nil {
return json.Marshal(&src.Folder)
}
return nil, nil // no data in anyOf schemas
}
func (src V2FilesGet200ResponseDataInner) ToMap() (map[string]interface{}, error) {
if src.ConnectedFile != nil {
return src.ConnectedFile.ToMap()
}
if src.ConnectedFolder != nil {
return src.ConnectedFolder.ToMap()
}
if src.File != nil {
return src.File.ToMap()
}
if src.Folder != nil {
return src.Folder.ToMap()
}
return nil, nil // no data in anyOf schemas
}
type NullableV2FilesGet200ResponseDataInner struct {
value *V2FilesGet200ResponseDataInner
isSet bool
}
func (v NullableV2FilesGet200ResponseDataInner) Get() *V2FilesGet200ResponseDataInner {
return v.value
}
func (v *NullableV2FilesGet200ResponseDataInner) Set(val *V2FilesGet200ResponseDataInner) {
v.value = val
v.isSet = true
}
func (v NullableV2FilesGet200ResponseDataInner) IsSet() bool {
return v.isSet
}
func (v *NullableV2FilesGet200ResponseDataInner) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableV2FilesGet200ResponseDataInner(val *V2FilesGet200ResponseDataInner) *NullableV2FilesGet200ResponseDataInner {
return &NullableV2FilesGet200ResponseDataInner{value: val, isSet: true}
}
func (v NullableV2FilesGet200ResponseDataInner) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableV2FilesGet200ResponseDataInner) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}