Skip to content

Commit

Permalink
feat: rename office_light_setup to office_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mgierada committed Jan 12, 2024
1 parent cdd077b commit 7f899fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/routes/office_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -18,7 +18,7 @@ pub async fn office_on_handler(_token: Token) -> Json<serde_json::Value> {
];
let payloads: Vec<PayloadBody> = devices
.iter()
.map(|device| office_light_setup(device, "on"))
.map(|device| office_setup(device, "on"))
.collect();

let govee_client = GoveeClient::new(&GOVEE_API_KEY);
Expand All @@ -39,7 +39,7 @@ pub async fn office_off_handler(_token: Token) -> Json<serde_json::Value> {
];
let payloads: Vec<PayloadBody> = devices
.iter()
.map(|device| office_light_setup(device, "off"))
.map(|device| office_setup(device, "off"))
.collect();

let govee_client = GoveeClient::new(&GOVEE_API_KEY);
Expand All @@ -52,7 +52,7 @@ pub async fn office_off_handler(_token: Token) -> Json<serde_json::Value> {
#[get("/board/on")]
pub async fn office_board_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -64,7 +64,7 @@ pub async fn office_board_on_handler(_token: Token) -> Json<serde_json::Value> {
#[get("/board/off")]
pub async fn office_board_off_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -77,7 +77,7 @@ pub async fn office_board_off_on_handler(_token: Token) -> Json<serde_json::Valu
#[get("/table/on")]
pub async fn office_table_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -89,7 +89,7 @@ pub async fn office_table_on_handler(_token: Token) -> Json<serde_json::Value> {
#[get("/table/off")]
pub async fn office_table_off_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -101,7 +101,7 @@ pub async fn office_table_off_handler(_token: Token) -> Json<serde_json::Value>
#[get("/window/on")]
pub async fn office_window_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -113,7 +113,7 @@ pub async fn office_window_on_handler(_token: Token) -> Json<serde_json::Value>
#[get("/window/off")]
pub async fn office_window_off_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand Down
14 changes: 7 additions & 7 deletions src/routes/standing_routes.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,7 +14,7 @@ pub async fn standing_on_handler(_token: Token) -> Json<serde_json::Value> {
];
let payloads: Vec<PayloadBody> = devices
.iter()
.map(|device| office_light_setup(device, "on"))
.map(|device| office_setup(device, "on"))
.collect();

let govee_client = GoveeClient::new(&GOVEE_API_KEY);
Expand All @@ -32,7 +32,7 @@ pub async fn standing_off_handler(_token: Token) -> Json<serde_json::Value> {
];
let payloads: Vec<PayloadBody> = devices
.iter()
.map(|device| office_light_setup(device, "off"))
.map(|device| office_setup(device, "off"))
.collect();

let govee_client = GoveeClient::new(&GOVEE_API_KEY);
Expand All @@ -45,7 +45,7 @@ pub async fn standing_off_handler(_token: Token) -> Json<serde_json::Value> {
#[get("/right/on")]
pub async fn standing_right_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -57,7 +57,7 @@ pub async fn standing_right_on_handler(_token: Token) -> Json<serde_json::Value>
#[get("/right/off")]
pub async fn standing_right_off_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -69,7 +69,7 @@ pub async fn standing_right_off_handler(_token: Token) -> Json<serde_json::Value
#[get("/left/on")]
pub async fn standing_left_on_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand All @@ -81,7 +81,7 @@ pub async fn standing_left_on_handler(_token: Token) -> Json<serde_json::Value>
#[get("/left/off")]
pub async fn standing_left_off_handler(_token: Token) -> Json<serde_json::Value> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/services/light_setup_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 7f899fb

Please sign in to comment.