Skip to content

Commit

Permalink
fix: typos
Browse files Browse the repository at this point in the history
  • Loading branch information
mgierada committed Jul 29, 2023
1 parent 49ae536 commit 4cd9907
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
21 changes: 6 additions & 15 deletions src/api/api.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
use reqwest::{Client, Url};
use serde_json::json;

use crate::structs::govee::{
ApiResponseGoveeDevices, ApiResponseGoveeDeviceStatus, PayloadBody,
};
use crate::structs::govee::{ApiResponseGoveeDeviceState, ApiResponseGoveeDevices, PayloadBody};

// ------------------------
// Methods for the Govee API
// ------------------------

pub async fn control_device(
govee_root_url: &str,
govee_api_key: &str,
payload: PayloadBody,
) -> () {
pub async fn control_device(govee_root_url: &str, govee_api_key: &str, payload: PayloadBody) -> () {
let client = Client::new();
let payload_json = json!(payload);
let endpoint = format!("{}/v1/devices/control", govee_root_url);
Expand All @@ -26,10 +20,7 @@ pub async fn control_device(
.unwrap();
}

pub async fn get_devices(
govee_root_url: &str,
govee_api_key: &str,
) -> ApiResponseGoveeDevices {
pub async fn get_devices(govee_root_url: &str, govee_api_key: &str) -> ApiResponseGoveeDevices {
let client = Client::new();
let endpoint = format!("{}/v1/devices", govee_root_url);
let response = client
Expand All @@ -39,7 +30,7 @@ pub async fn get_devices(
.await
.unwrap()
.json::<ApiResponseGoveeDevices>();
let response_json: ApiResponseGoveeDevices= response.await.unwrap();
let response_json: ApiResponseGoveeDevices = response.await.unwrap();
response_json
}

Expand All @@ -48,7 +39,7 @@ pub async fn get_device_state(
govee_api_key: &str,
device: &str,
model: &str,
) -> ApiResponseGoveeDeviceStatus {
) -> ApiResponseGoveeDeviceState{
let client = Client::new();
let params = [("device", device), ("model", model)];
let endpoint = format!("{}/v1/devices/state", govee_root_url);
Expand All @@ -60,6 +51,6 @@ pub async fn get_device_state(
.await
.unwrap()
.json::<ApiResponseGoveeDeviceState>();
let response_json: ApiResponseGoveeDeviceState= response.await.unwrap();
let response_json: ApiResponseGoveeDeviceState = response.await.unwrap();
response_json
}
2 changes: 1 addition & 1 deletion src/tests/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod tests {
use mockito;

use crate::{
api::api::{get_device_state, get_devices, control_device},
api::api::{control_device, get_device_state, get_devices},
structs::govee::{GoveeCommand, PayloadBody},
};

Expand Down

0 comments on commit 4cd9907

Please sign in to comment.