forked from seamapi/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocks.go
235 lines (205 loc) · 6.83 KB
/
locks.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
// 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 LocksGetRequest struct {
DeviceId *string `json:"device_id,omitempty"`
Name *string `json:"name,omitempty"`
}
type LocksListRequest 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]*LocksListRequestCustomMetadataHasValue `json:"custom_metadata_has,omitempty"`
}
type LocksLockDoorRequest struct {
DeviceId string `json:"device_id"`
Sync *bool `json:"sync,omitempty"`
}
type LocksGetResponse struct {
Lock *Device `json:"lock,omitempty"`
Device *Device `json:"device,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (l *LocksGetResponse) UnmarshalJSON(data []byte) error {
type unmarshaler LocksGetResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = LocksGetResponse(value)
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *LocksGetResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type LocksListRequestCustomMetadataHasValue struct {
typeName string
String string
Boolean bool
StringOptional *string
}
func NewLocksListRequestCustomMetadataHasValueFromString(value string) *LocksListRequestCustomMetadataHasValue {
return &LocksListRequestCustomMetadataHasValue{typeName: "string", String: value}
}
func NewLocksListRequestCustomMetadataHasValueFromBoolean(value bool) *LocksListRequestCustomMetadataHasValue {
return &LocksListRequestCustomMetadataHasValue{typeName: "boolean", Boolean: value}
}
func NewLocksListRequestCustomMetadataHasValueFromStringOptional(value *string) *LocksListRequestCustomMetadataHasValue {
return &LocksListRequestCustomMetadataHasValue{typeName: "stringOptional", StringOptional: value}
}
func (l *LocksListRequestCustomMetadataHasValue) UnmarshalJSON(data []byte) error {
var valueString string
if err := json.Unmarshal(data, &valueString); err == nil {
l.typeName = "string"
l.String = valueString
return nil
}
var valueBoolean bool
if err := json.Unmarshal(data, &valueBoolean); err == nil {
l.typeName = "boolean"
l.Boolean = valueBoolean
return nil
}
var valueStringOptional *string
if err := json.Unmarshal(data, &valueStringOptional); err == nil {
l.typeName = "stringOptional"
l.StringOptional = valueStringOptional
return nil
}
return fmt.Errorf("%s cannot be deserialized as a %T", data, l)
}
func (l LocksListRequestCustomMetadataHasValue) MarshalJSON() ([]byte, error) {
switch l.typeName {
default:
return nil, fmt.Errorf("invalid type %s in %T", l.typeName, l)
case "string":
return json.Marshal(l.String)
case "boolean":
return json.Marshal(l.Boolean)
case "stringOptional":
return json.Marshal(l.StringOptional)
}
}
type LocksListRequestCustomMetadataHasValueVisitor interface {
VisitString(string) error
VisitBoolean(bool) error
VisitStringOptional(*string) error
}
func (l *LocksListRequestCustomMetadataHasValue) Accept(visitor LocksListRequestCustomMetadataHasValueVisitor) error {
switch l.typeName {
default:
return fmt.Errorf("invalid type %s in %T", l.typeName, l)
case "string":
return visitor.VisitString(l.String)
case "boolean":
return visitor.VisitBoolean(l.Boolean)
case "stringOptional":
return visitor.VisitStringOptional(l.StringOptional)
}
}
type LocksListResponse struct {
Locks []*Device `json:"locks,omitempty"`
Devices []*Device `json:"devices,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (l *LocksListResponse) UnmarshalJSON(data []byte) error {
type unmarshaler LocksListResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = LocksListResponse(value)
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *LocksListResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type LocksLockDoorResponse struct {
ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (l *LocksLockDoorResponse) UnmarshalJSON(data []byte) error {
type unmarshaler LocksLockDoorResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = LocksLockDoorResponse(value)
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *LocksLockDoorResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type LocksUnlockDoorResponse struct {
ActionAttempt *ActionAttempt `json:"action_attempt,omitempty"`
Ok bool `json:"ok"`
_rawJSON json.RawMessage
}
func (l *LocksUnlockDoorResponse) UnmarshalJSON(data []byte) error {
type unmarshaler LocksUnlockDoorResponse
var value unmarshaler
if err := json.Unmarshal(data, &value); err != nil {
return err
}
*l = LocksUnlockDoorResponse(value)
l._rawJSON = json.RawMessage(data)
return nil
}
func (l *LocksUnlockDoorResponse) String() string {
if len(l._rawJSON) > 0 {
if value, err := core.StringifyJSON(l._rawJSON); err == nil {
return value
}
}
if value, err := core.StringifyJSON(l); err == nil {
return value
}
return fmt.Sprintf("%#v", l)
}
type LocksUnlockDoorRequest struct {
DeviceId string `json:"device_id"`
Sync *bool `json:"sync,omitempty"`
}