forked from seamapi/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devices.go
369 lines (322 loc) · 10.9 KB
/
devices.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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
// This file was auto-generated by Fern from our API Definition.
package api
import (
json "encoding/json"
fmt "fmt"
core "github.com/seamapi/go/core"
time "time"
)
type DevicesDeleteRequest struct {
DeviceId string `json:"device_id"`
}
type DevicesGetRequest struct {
DeviceId *string `json:"device_id,omitempty"`
Name *string `json:"name,omitempty"`
}
type DevicesListRequest struct {
// List all devices owned by this connected account
ConnectedAccountId *string `json:"connected_account_id,omitempty"`
ConnectedAccountIds []string `json:"connected_account_ids,omitempty"`
ConnectWebviewId *string `json:"connect_webview_id,omitempty"`
DeviceType *DeviceType `json:"device_type,omitempty"`
DeviceTypes []DeviceType `json:"device_types,omitempty"`
Manufacturer *Manufacturer `json:"manufacturer,omitempty"`
DeviceIds []string `json:"device_ids,omitempty"`
Limit *float64 `json:"limit,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty"`
UserIdentifierKey *string `json:"user_identifier_key,omitempty"`
CustomMetadataHas map[string]*DevicesListRequestCustomMetadataHasValue `json:"custom_metadata_has,omitempty"`
}
type DevicesListDeviceProvidersRequest struct {
ProviderCategory *ProviderCategory `json:"provider_category,omitempty"`
}
type DevicesDeleteResponse struct {
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (d *DevicesDeleteResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesDeleteResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesDeleteResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesDeleteResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesGetResponse struct {
Device *Device `json:"device,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (d *DevicesGetResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesGetResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesGetResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesGetResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesListDeviceProvidersResponse struct {
DeviceProviders []*DeviceProvider `json:"device_providers,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (d *DevicesListDeviceProvidersResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesListDeviceProvidersResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesListDeviceProvidersResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesListDeviceProvidersResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesListRequestCustomMetadataHasValue struct {
typeName string
String string
Boolean bool
StringOptional *string
}
func NewDevicesListRequestCustomMetadataHasValueFromString(value string) *DevicesListRequestCustomMetadataHasValue {
return &DevicesListRequestCustomMetadataHasValue{typeName: "string", String: value}
}
func NewDevicesListRequestCustomMetadataHasValueFromBoolean(value bool) *DevicesListRequestCustomMetadataHasValue {
return &DevicesListRequestCustomMetadataHasValue{typeName: "boolean", Boolean: value}
}
func NewDevicesListRequestCustomMetadataHasValueFromStringOptional(value *string) *DevicesListRequestCustomMetadataHasValue {
return &DevicesListRequestCustomMetadataHasValue{typeName: "stringOptional", StringOptional: value}
}
func (d *DevicesListRequestCustomMetadataHasValue) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
d.typeName = "string"
d.String = valueString
return nil
}
var valueBoolean bool
if err := json.Unmarshal(data, &valueBoolean); err == nil {
d.typeName = "boolean"
d.Boolean = valueBoolean
return nil
}
var valueStringOptional *string
if err := json.Unmarshal(data, &valueStringOptional); err == nil {
d.typeName = "stringOptional"
d.StringOptional = valueStringOptional
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, d)
}
func (d DevicesListRequestCustomMetadataHasValue) MarshalJSON() ([]byte, error) {
switch d.typeName {
default:
return nil, fmt.Errorf("invalid type %s in %T", d.typeName, d)
case "string":
return json.Marshal(d.String)
case "boolean":
return json.Marshal(d.Boolean)
case "stringOptional":
return json.Marshal(d.StringOptional)
}
}
type DevicesListRequestCustomMetadataHasValueVisitor interface {
VisitString(string) error
VisitBoolean(bool) error
VisitStringOptional(*string) error
}
func (d *DevicesListRequestCustomMetadataHasValue) Accept(visitor DevicesListRequestCustomMetadataHasValueVisitor) error {
switch d.typeName {
default:
return fmt.Errorf("invalid type %s in %T", d.typeName, d)
case "string":
return visitor.VisitString(d.String)
case "boolean":
return visitor.VisitBoolean(d.Boolean)
case "stringOptional":
return visitor.VisitStringOptional(d.StringOptional)
}
}
type DevicesListResponse struct {
Devices []*Device `json:"devices,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (d *DevicesListResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesListResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesListResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesListResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesUpdateRequestCustomMetadataValue struct {
typeName string
String string
Boolean bool
StringOptional *string
}
func NewDevicesUpdateRequestCustomMetadataValueFromString(value string) *DevicesUpdateRequestCustomMetadataValue {
return &DevicesUpdateRequestCustomMetadataValue{typeName: "string", String: value}
}
func NewDevicesUpdateRequestCustomMetadataValueFromBoolean(value bool) *DevicesUpdateRequestCustomMetadataValue {
return &DevicesUpdateRequestCustomMetadataValue{typeName: "boolean", Boolean: value}
}
func NewDevicesUpdateRequestCustomMetadataValueFromStringOptional(value *string) *DevicesUpdateRequestCustomMetadataValue {
return &DevicesUpdateRequestCustomMetadataValue{typeName: "stringOptional", StringOptional: value}
}
func (d *DevicesUpdateRequestCustomMetadataValue) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
d.typeName = "string"
d.String = valueString
return nil
}
var valueBoolean bool
if err := json.Unmarshal(data, &valueBoolean); err == nil {
d.typeName = "boolean"
d.Boolean = valueBoolean
return nil
}
var valueStringOptional *string
if err := json.Unmarshal(data, &valueStringOptional); err == nil {
d.typeName = "stringOptional"
d.StringOptional = valueStringOptional
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, d)
}
func (d DevicesUpdateRequestCustomMetadataValue) MarshalJSON() ([]byte, error) {
switch d.typeName {
default:
return nil, fmt.Errorf("invalid type %s in %T", d.typeName, d)
case "string":
return json.Marshal(d.String)
case "boolean":
return json.Marshal(d.Boolean)
case "stringOptional":
return json.Marshal(d.StringOptional)
}
}
type DevicesUpdateRequestCustomMetadataValueVisitor interface {
VisitString(string) error
VisitBoolean(bool) error
VisitStringOptional(*string) error
}
func (d *DevicesUpdateRequestCustomMetadataValue) Accept(visitor DevicesUpdateRequestCustomMetadataValueVisitor) error {
switch d.typeName {
default:
return fmt.Errorf("invalid type %s in %T", d.typeName, d)
case "string":
return visitor.VisitString(d.String)
case "boolean":
return visitor.VisitBoolean(d.Boolean)
case "stringOptional":
return visitor.VisitStringOptional(d.StringOptional)
}
}
type DevicesUpdateRequestProperties struct {
Name *string `json:"name,omitempty"`
_rawJSON json.RawMessage
}
func (d *DevicesUpdateRequestProperties) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesUpdateRequestProperties
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesUpdateRequestProperties(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesUpdateRequestProperties) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesUpdateResponse struct {
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (d *DevicesUpdateResponse) UnmarshalJSON(data []byte) error {
type unmarshaler DevicesUpdateResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*d = DevicesUpdateResponse(value)
d._rawJSON = json.RawMessage(data)
return nil
}
func (d *DevicesUpdateResponse) String() string {
if len(d._rawJSON) > 0 {
if value, err := core.StringifyJSON(d._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(d); err == nil {
return value
}
return fmt.Sprintf("%#v", d)
}
type DevicesUpdateRequest struct {
DeviceId string `json:"device_id"`
Properties *DevicesUpdateRequestProperties `json:"properties,omitempty"`
Name *string `json:"name,omitempty"`
IsManaged *bool `json:"is_managed,omitempty"`
CustomMetadata map[string]*DevicesUpdateRequestCustomMetadataValue `json:"custom_metadata,omitempty"`
}