Request ID is not a UUID like the documentation suggests
This commit is contained in:
@@ -3,7 +3,6 @@ pub mod query;
|
||||
pub mod execute;
|
||||
|
||||
use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(tag = "intent", content = "payload")]
|
||||
@@ -19,6 +18,6 @@ pub enum Intent {
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Request {
|
||||
pub request_id: Uuid,
|
||||
pub request_id: String,
|
||||
pub inputs: Vec<Intent>,
|
||||
}
|
||||
|
||||
@@ -35,8 +35,6 @@ pub enum CommandType {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use uuid::Uuid;
|
||||
use super::*;
|
||||
use crate::request::{Request, Intent};
|
||||
|
||||
@@ -88,7 +86,7 @@ mod tests {
|
||||
|
||||
println!("{:?}", req);
|
||||
|
||||
assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap());
|
||||
assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned());
|
||||
assert_eq!(req.inputs.len(), 1);
|
||||
match &req.inputs[0] {
|
||||
Intent::Execute(payload) => {
|
||||
|
||||
@@ -15,10 +15,6 @@ pub struct Device {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::request::{Request, Intent};
|
||||
|
||||
#[test]
|
||||
@@ -57,7 +53,7 @@ mod tests {
|
||||
|
||||
println!("{:?}", req);
|
||||
|
||||
assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap());
|
||||
assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned());
|
||||
assert_eq!(req.inputs.len(), 1);
|
||||
match &req.inputs[0] {
|
||||
Intent::Query(payload) => {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::request::{Request, Intent};
|
||||
|
||||
#[test]
|
||||
@@ -22,7 +18,7 @@ mod tests {
|
||||
|
||||
println!("{:?}", req);
|
||||
|
||||
assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap());
|
||||
assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned());
|
||||
assert_eq!(req.inputs.len(), 1);
|
||||
match req.inputs[0] {
|
||||
Intent::Sync => {},
|
||||
|
||||
@@ -4,17 +4,16 @@ pub mod execute;
|
||||
|
||||
use serde::Serialize;
|
||||
use serde_with::skip_serializing_none;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Response {
|
||||
request_id: Uuid,
|
||||
request_id: String,
|
||||
payload: ResponsePayload,
|
||||
}
|
||||
|
||||
impl Response {
|
||||
pub fn new(request_id: Uuid, payload: ResponsePayload) -> Self {
|
||||
pub fn new(request_id: String, payload: ResponsePayload) -> Self {
|
||||
Self { request_id, payload }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ pub enum Status {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use uuid::Uuid;
|
||||
use super::*;
|
||||
use crate::{response::{Response, ResponsePayload, State}, errors::DeviceError};
|
||||
|
||||
@@ -94,7 +92,7 @@ mod tests {
|
||||
command.ids.push("456".into());
|
||||
execute_resp.add_command(command);
|
||||
|
||||
let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Execute(execute_resp));
|
||||
let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Execute(execute_resp));
|
||||
|
||||
let json = serde_json::to_string(&resp).unwrap();
|
||||
|
||||
|
||||
@@ -66,8 +66,6 @@ impl Device {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use uuid::Uuid;
|
||||
use super::*;
|
||||
use crate::response::{Response, ResponsePayload};
|
||||
|
||||
@@ -83,7 +81,7 @@ mod tests {
|
||||
device.state.on = Some(false);
|
||||
query_resp.add_device("456", device);
|
||||
|
||||
let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Query(query_resp));
|
||||
let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Query(query_resp));
|
||||
|
||||
let json = serde_json::to_string(&resp).unwrap();
|
||||
|
||||
|
||||
@@ -61,8 +61,6 @@ impl Device {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
use uuid::Uuid;
|
||||
use super::*;
|
||||
use crate::{response::{Response, ResponsePayload}, types::Type, traits::Trait};
|
||||
|
||||
@@ -85,7 +83,7 @@ mod tests {
|
||||
|
||||
sync_resp.add_device(device);
|
||||
|
||||
let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Sync(sync_resp));
|
||||
let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Sync(sync_resp));
|
||||
|
||||
let json = serde_json::to_string(&resp).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user