-
Notifications
You must be signed in to change notification settings - Fork 3
/
locks.go
305 lines (266 loc) · 10.4 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
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
// 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" url:"device_id,omitempty"`
Name *string `json:"name,omitempty" url:"name,omitempty"`
}
type LocksListRequest struct {
// List all devices owned by this connected account
ConnectedAccountId *string `json:"connected_account_id,omitempty" url:"connected_account_id,omitempty"`
ConnectedAccountIds []string `json:"connected_account_ids,omitempty" url:"connected_account_ids,omitempty"`
ConnectWebviewId *string `json:"connect_webview_id,omitempty" url:"connect_webview_id,omitempty"`
DeviceType *DeviceType `json:"device_type,omitempty" url:"device_type,omitempty"`
DeviceTypes []DeviceType `json:"device_types,omitempty" url:"device_types,omitempty"`
Manufacturer *Manufacturer `json:"manufacturer,omitempty" url:"manufacturer,omitempty"`
DeviceIds []string `json:"device_ids,omitempty" url:"device_ids,omitempty"`
Limit *float64 `json:"limit,omitempty" url:"limit,omitempty"`
CreatedBefore *time.Time `json:"created_before,omitempty" url:"created_before,omitempty"`
UserIdentifierKey *string `json:"user_identifier_key,omitempty" url:"user_identifier_key,omitempty"`
CustomMetadataHas map[string]*LocksListRequestCustomMetadataHasValue `json:"custom_metadata_has,omitempty" url:"custom_metadata_has,omitempty"`
IncludeIf []LocksListRequestIncludeIfItem `json:"include_if,omitempty" url:"include_if,omitempty"`
ExcludeIf []LocksListRequestExcludeIfItem `json:"exclude_if,omitempty" url:"exclude_if,omitempty"`
}
func (l *LocksListRequest) UnmarshalJSON(data []byte) error {
type unmarshaler LocksListRequest
var body unmarshaler
if err := json.Unmarshal(data, &body); err != nil {
return err
}
*l = LocksListRequest(body)
return nil
}
func (l *LocksListRequest) MarshalJSON() ([]byte, error) {
type embed LocksListRequest
var marshaler = struct {
embed
CreatedBefore *core.DateTime `json:"created_before,omitempty"`
}{
embed: embed(*l),
CreatedBefore: core.NewOptionalDateTime(l.CreatedBefore),
}
return json.Marshal(marshaler)
}
type LocksLockDoorRequest struct {
DeviceId string `json:"device_id" url:"device_id"`
Sync *bool `json:"sync,omitempty" url:"sync,omitempty"`
}
type LocksGetResponse struct {
Lock *Device `json:"lock,omitempty" url:"lock,omitempty"`
Device *Device `json:"device,omitempty" url:"device,omitempty"`
Ok bool `json:"ok" url:"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
}
func NewLocksListRequestCustomMetadataHasValueFromString(value string) *LocksListRequestCustomMetadataHasValue {
return &LocksListRequestCustomMetadataHasValue{typeName: "string", String: value}
}
func NewLocksListRequestCustomMetadataHasValueFromBoolean(value bool) *LocksListRequestCustomMetadataHasValue {
return &LocksListRequestCustomMetadataHasValue{typeName: "boolean", Boolean: 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
}
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)
}
}
type LocksListRequestCustomMetadataHasValueVisitor interface {
VisitString(string) error
VisitBoolean(bool) 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)
}
}
type LocksListRequestExcludeIfItem string
const (
LocksListRequestExcludeIfItemCanRemotelyUnlock LocksListRequestExcludeIfItem = "can_remotely_unlock"
LocksListRequestExcludeIfItemCanRemotelyLock LocksListRequestExcludeIfItem = "can_remotely_lock"
LocksListRequestExcludeIfItemCanProgramOfflineAccessCodes LocksListRequestExcludeIfItem = "can_program_offline_access_codes"
LocksListRequestExcludeIfItemCanProgramOnlineAccessCodes LocksListRequestExcludeIfItem = "can_program_online_access_codes"
LocksListRequestExcludeIfItemCanSimulateRemoval LocksListRequestExcludeIfItem = "can_simulate_removal"
)
func NewLocksListRequestExcludeIfItemFromString(s string) (LocksListRequestExcludeIfItem, error) {
switch s {
case "can_remotely_unlock":
return LocksListRequestExcludeIfItemCanRemotelyUnlock, nil
case "can_remotely_lock":
return LocksListRequestExcludeIfItemCanRemotelyLock, nil
case "can_program_offline_access_codes":
return LocksListRequestExcludeIfItemCanProgramOfflineAccessCodes, nil
case "can_program_online_access_codes":
return LocksListRequestExcludeIfItemCanProgramOnlineAccessCodes, nil
case "can_simulate_removal":
return LocksListRequestExcludeIfItemCanSimulateRemoval, nil
}
var t LocksListRequestExcludeIfItem
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (l LocksListRequestExcludeIfItem) Ptr() *LocksListRequestExcludeIfItem {
return &l
}
type LocksListRequestIncludeIfItem string
const (
LocksListRequestIncludeIfItemCanRemotelyUnlock LocksListRequestIncludeIfItem = "can_remotely_unlock"
LocksListRequestIncludeIfItemCanRemotelyLock LocksListRequestIncludeIfItem = "can_remotely_lock"
LocksListRequestIncludeIfItemCanProgramOfflineAccessCodes LocksListRequestIncludeIfItem = "can_program_offline_access_codes"
LocksListRequestIncludeIfItemCanProgramOnlineAccessCodes LocksListRequestIncludeIfItem = "can_program_online_access_codes"
LocksListRequestIncludeIfItemCanSimulateRemoval LocksListRequestIncludeIfItem = "can_simulate_removal"
)
func NewLocksListRequestIncludeIfItemFromString(s string) (LocksListRequestIncludeIfItem, error) {
switch s {
case "can_remotely_unlock":
return LocksListRequestIncludeIfItemCanRemotelyUnlock, nil
case "can_remotely_lock":
return LocksListRequestIncludeIfItemCanRemotelyLock, nil
case "can_program_offline_access_codes":
return LocksListRequestIncludeIfItemCanProgramOfflineAccessCodes, nil
case "can_program_online_access_codes":
return LocksListRequestIncludeIfItemCanProgramOnlineAccessCodes, nil
case "can_simulate_removal":
return LocksListRequestIncludeIfItemCanSimulateRemoval, nil
}
var t LocksListRequestIncludeIfItem
return "", fmt.Errorf("%s is not a valid %T", s, t)
}
func (l LocksListRequestIncludeIfItem) Ptr() *LocksListRequestIncludeIfItem {
return &l
}
type LocksListResponse struct {
Locks []*Device `json:"locks,omitempty" url:"locks,omitempty"`
Devices []*Device `json:"devices,omitempty" url:"devices,omitempty"`
Ok bool `json:"ok" url:"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" url:"action_attempt,omitempty"`
Ok bool `json:"ok" url:"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" url:"action_attempt,omitempty"`
Ok bool `json:"ok" url:"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" url:"device_id"`
Sync *bool `json:"sync,omitempty" url:"sync,omitempty"`
}