@@ -65,9 +65,7 @@ def __init__(self, seam: Seam):
65
65
def list (
66
66
self ,
67
67
device : Optional [Union [DeviceId , Device ]] = None ,
68
- access_codes : Optional [
69
- Union [List [AccessCode ], List [AccessCodeId ]]
70
- ] = None ,
68
+ access_codes : Optional [Union [List [AccessCode ], List [AccessCodeId ]]] = None ,
71
69
) -> List [AccessCode ]:
72
70
"""Gets a list of access codes for a device.
73
71
@@ -92,9 +90,7 @@ def list(
92
90
if device :
93
91
params ["device_id" ] = to_device_id (device )
94
92
if access_codes :
95
- params ["access_code_ids" ] = [
96
- to_access_code_id (ac ) for ac in access_codes
97
- ]
93
+ params ["access_code_ids" ] = [to_access_code_id (ac ) for ac in access_codes ]
98
94
99
95
res = self .seam .make_request (
100
96
"GET" ,
@@ -150,6 +146,7 @@ def create(
150
146
device : Union [DeviceId , Device ],
151
147
name : Optional [str ] = None ,
152
148
code : Optional [str ] = None ,
149
+ type : Optional [str ] = None ,
153
150
starts_at : Optional [str ] = None ,
154
151
ends_at : Optional [str ] = None ,
155
152
common_code_key : Optional [str ] = None ,
@@ -174,6 +171,8 @@ def create(
174
171
Access code name
175
172
code : str, optional
176
173
Access code value
174
+ type : str, optional
175
+ Access code type eg. ongoing or time_bound
177
176
starts_at : str, optional
178
177
Time when access code becomes effective
179
178
ends_at : str, optional
@@ -224,48 +223,32 @@ def create(
224
223
create_payload ["ends_at" ] = ends_at
225
224
if common_code_key is not None :
226
225
create_payload ["common_code_key" ] = common_code_key
226
+ if type is not None :
227
+ create_payload ["type" ] = type
227
228
if attempt_for_offline_device is not None :
228
- create_payload [
229
- "attempt_for_offline_device"
230
- ] = attempt_for_offline_device
229
+ create_payload ["attempt_for_offline_device" ] = attempt_for_offline_device
231
230
if allow_external_modification is not None :
232
- create_payload [
233
- "allow_external_modification"
234
- ] = allow_external_modification
231
+ create_payload ["allow_external_modification" ] = allow_external_modification
235
232
if prefer_native_scheduling is not None :
236
- create_payload [
237
- "prefer_native_scheduling"
238
- ] = prefer_native_scheduling
233
+ create_payload ["prefer_native_scheduling" ] = prefer_native_scheduling
239
234
if use_backup_access_code_pool is not None :
240
- create_payload [
241
- "use_backup_access_code_pool"
242
- ] = use_backup_access_code_pool
235
+ create_payload ["use_backup_access_code_pool" ] = use_backup_access_code_pool
243
236
if use_offline_access_code is not None :
244
- create_payload [
245
- "use_offline_access_code"
246
- ] = use_offline_access_code
237
+ create_payload ["use_offline_access_code" ] = use_offline_access_code
247
238
if is_offline_access_code is not None :
248
- create_payload [
249
- "is_offline_access_code"
250
- ] = is_offline_access_code
239
+ create_payload ["is_offline_access_code" ] = is_offline_access_code
251
240
if is_one_time_use is not None :
252
- create_payload [
253
- "is_one_time_use"
254
- ] = is_one_time_use
241
+ create_payload ["is_one_time_use" ] = is_one_time_use
255
242
if max_time_rounding is not None :
256
- create_payload [
257
- "max_time_rounding"
258
- ] = max_time_rounding
243
+ create_payload ["max_time_rounding" ] = max_time_rounding
259
244
260
245
if (
261
246
wait_for_code
262
247
and starts_at is not None
263
248
and datetime .fromisoformat (starts_at )
264
249
> datetime .now () + timedelta (seconds = 5 )
265
250
):
266
- raise RuntimeError (
267
- "Cannot use wait_for_code with a future time bound code"
268
- )
251
+ raise RuntimeError ("Cannot use wait_for_code with a future time bound code" )
269
252
270
253
res = self .seam .make_request (
271
254
"POST" ,
@@ -422,9 +405,7 @@ def update(
422
405
if type is not None :
423
406
update_payload ["type" ] = type
424
407
if allow_external_modification is not None :
425
- update_payload [
426
- "allow_external_modification"
427
- ] = allow_external_modification
408
+ update_payload ["allow_external_modification" ] = allow_external_modification
428
409
429
410
res = self .seam .make_request (
430
411
"POST" ,
@@ -655,9 +636,7 @@ def convert_to_managed(
655
636
}
656
637
657
638
if allow_external_modification is not None :
658
- payload [
659
- "allow_external_modification"
660
- ] = allow_external_modification
639
+ payload ["allow_external_modification" ] = allow_external_modification
661
640
662
641
res = self .seam .make_request (
663
642
"POST" ,
@@ -668,5 +647,5 @@ def convert_to_managed(
668
647
action_attempt = self .seam .action_attempts .poll_until_ready (
669
648
res ["action_attempt" ]["action_attempt_id" ]
670
649
)
671
-
650
+
672
651
return action_attempt
0 commit comments