From 7f899fbd249459b54bd7a8354153e3fba7f28869 Mon Sep 17 00:00:00 2001 From: Maciej Gierada Date: Fri, 12 Jan 2024 22:22:34 +0100 Subject: [PATCH] feat: rename office_light_setup to office_setup --- src/routes/office_routes.rs | 18 +++++++++--------- src/routes/standing_routes.rs | 14 +++++++------- src/services/light_setup_service.rs | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/routes/office_routes.rs b/src/routes/office_routes.rs index c63d2b3..2c952ec 100644 --- a/src/routes/office_routes.rs +++ b/src/routes/office_routes.rs @@ -4,7 +4,7 @@ use rocket::serde::json::Json; use crate::constants::enums::OfficeDevices; use crate::implementations::access_token::Token; -use crate::services::light_setup_service::office_light_setup; +use crate::services::light_setup_service::office_setup; use crate::GOVEE_API_KEY; #[get("/on")] @@ -18,7 +18,7 @@ pub async fn office_on_handler(_token: Token) -> Json { ]; let payloads: Vec = devices .iter() - .map(|device| office_light_setup(device, "on")) + .map(|device| office_setup(device, "on")) .collect(); let govee_client = GoveeClient::new(&GOVEE_API_KEY); @@ -39,7 +39,7 @@ pub async fn office_off_handler(_token: Token) -> Json { ]; let payloads: Vec = devices .iter() - .map(|device| office_light_setup(device, "off")) + .map(|device| office_setup(device, "off")) .collect(); let govee_client = GoveeClient::new(&GOVEE_API_KEY); @@ -52,7 +52,7 @@ pub async fn office_off_handler(_token: Token) -> Json { #[get("/board/on")] pub async fn office_board_on_handler(_token: Token) -> Json { let board_led = OfficeDevices::board_led(); - let payload = office_light_setup(&board_led, "on"); + let payload = office_setup(&board_led, "on"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -64,7 +64,7 @@ pub async fn office_board_on_handler(_token: Token) -> Json { #[get("/board/off")] pub async fn office_board_off_on_handler(_token: Token) -> Json { let board_led = OfficeDevices::board_led(); - let payload = office_light_setup(&board_led, "off"); + let payload = office_setup(&board_led, "off"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -77,7 +77,7 @@ pub async fn office_board_off_on_handler(_token: Token) -> Json Json { let table_led = OfficeDevices::table_led(); - let payload = office_light_setup(&table_led, "on"); + let payload = office_setup(&table_led, "on"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -89,7 +89,7 @@ pub async fn office_table_on_handler(_token: Token) -> Json { #[get("/table/off")] pub async fn office_table_off_handler(_token: Token) -> Json { let table_led = OfficeDevices::table_led(); - let payload = office_light_setup(&table_led, "off"); + let payload = office_setup(&table_led, "off"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -101,7 +101,7 @@ pub async fn office_table_off_handler(_token: Token) -> Json #[get("/window/on")] pub async fn office_window_on_handler(_token: Token) -> Json { let window_led = OfficeDevices::window_led(); - let payload = office_light_setup(&window_led, "on"); + let payload = office_setup(&window_led, "on"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -113,7 +113,7 @@ pub async fn office_window_on_handler(_token: Token) -> Json #[get("/window/off")] pub async fn office_window_off_handler(_token: Token) -> Json { let window_led = OfficeDevices::window_led(); - let payload = office_light_setup(&window_led, "off"); + let payload = office_setup(&window_led, "off"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { diff --git a/src/routes/standing_routes.rs b/src/routes/standing_routes.rs index af3eb80..7f6db19 100644 --- a/src/routes/standing_routes.rs +++ b/src/routes/standing_routes.rs @@ -1,6 +1,6 @@ use crate::constants::enums::OfficeDevices; use crate::implementations::access_token::Token; -use crate::services::light_setup_service::office_light_setup; +use crate::services::light_setup_service::office_setup; use crate::GOVEE_API_KEY; use govee_api::structs::govee::PayloadBody; use govee_api::GoveeClient; @@ -14,7 +14,7 @@ pub async fn standing_on_handler(_token: Token) -> Json { ]; let payloads: Vec = devices .iter() - .map(|device| office_light_setup(device, "on")) + .map(|device| office_setup(device, "on")) .collect(); let govee_client = GoveeClient::new(&GOVEE_API_KEY); @@ -32,7 +32,7 @@ pub async fn standing_off_handler(_token: Token) -> Json { ]; let payloads: Vec = devices .iter() - .map(|device| office_light_setup(device, "off")) + .map(|device| office_setup(device, "off")) .collect(); let govee_client = GoveeClient::new(&GOVEE_API_KEY); @@ -45,7 +45,7 @@ pub async fn standing_off_handler(_token: Token) -> Json { #[get("/right/on")] pub async fn standing_right_on_handler(_token: Token) -> Json { let standing_right_led = OfficeDevices::standing_right_led(); - let payload = office_light_setup(&standing_right_led, "on"); + let payload = office_setup(&standing_right_led, "on"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -57,7 +57,7 @@ pub async fn standing_right_on_handler(_token: Token) -> Json #[get("/right/off")] pub async fn standing_right_off_handler(_token: Token) -> Json { let standing_right_led = OfficeDevices::standing_right_led(); - let payload = office_light_setup(&standing_right_led, "off"); + let payload = office_setup(&standing_right_led, "off"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -69,7 +69,7 @@ pub async fn standing_right_off_handler(_token: Token) -> Json Json { let standing_left_led = OfficeDevices::standing_left_led(); - let payload = office_light_setup(&standing_left_led, "on"); + let payload = office_setup(&standing_left_led, "on"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { @@ -81,7 +81,7 @@ pub async fn standing_left_on_handler(_token: Token) -> Json #[get("/left/off")] pub async fn standing_left_off_handler(_token: Token) -> Json { let standing_left_led = OfficeDevices::standing_left_led(); - let payload = office_light_setup(&standing_left_led, "off"); + let payload = office_setup(&standing_left_led, "off"); let govee_client = GoveeClient::new(&GOVEE_API_KEY); let result = govee_client.control_device(payload).await; if let Err(err) = result { diff --git a/src/services/light_setup_service.rs b/src/services/light_setup_service.rs index 7c6b9e6..6518d4e 100644 --- a/src/services/light_setup_service.rs +++ b/src/services/light_setup_service.rs @@ -81,7 +81,7 @@ impl OfficeDevices { } } -pub fn office_light_setup(device: &OfficeDevices, command: &str) -> PayloadBody { +pub fn office_setup(device: &OfficeDevices, command: &str) -> PayloadBody { let command = GoveeCommand { name: "turn".to_string(), value: command.to_string(),