-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive_set_access_codes.rs
78 lines (63 loc) · 2 KB
/
interactive_set_access_codes.rs
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
use seamapi_rs::Seam;
use std::io;
fn main() {
println!("This will reset your workspace sandbox, continure? (Y/n)");
let mut guess = String::new();
io::stdin()
.read_line(&mut guess)
.expect("failed to read line");
println!("{guess}");
if guess != "Y\n" {
panic!();
}
let seam = Seam::new(None, None).unwrap();
println!("Reseting sandbox...");
seam.workspace().reset_sandbox();
println!("creating a Connect Webview...");
let webview = seam
.connect_webviews()
.create(vec!["august".to_string()], None, None)
.unwrap();
println!("This is my webview: \n{:?}", webview);
println!(
"Got the URL below and login\n\n{}\n\[email protected]\n123\n\n",
webview.url
);
let mut enter = String::new();
io::stdin()
.read_line(&mut enter)
.expect("failed to read line");
let updated_webview = seam
.connect_webviews()
.get(webview.connect_webview_id)
.unwrap();
print!("This is my updated webview: \n {:?}", updated_webview);
if updated_webview.login_successful {
println!("Successfully logged in!");
} else {
panic!("Webview wasn't logged in");
}
let locks = seam.locks().list().unwrap();
println!(
"Listing all the connected locks for our new account: {:?}",
locks
);
let mut front_door = String::new();
for lock in locks {
if lock.properties.august_metadata.unwrap().device_name == "FRONT DOOR" {
front_door = lock.device_id;
}
}
println!("Settings the code 123459 on FRONT DOOR");
seam.access_codes()
.create(
front_door.clone(),
Some("My personal entry code".to_string()),
Some("123459".to_string()),
None,
None,
)
.unwrap();
let all_access_codes_on_front_door = seam.access_codes().list(front_door.clone()).unwrap();
println!("{:?}", all_access_codes_on_front_door);
}