use serde::{Deserialize, Serialize};
use crate::protocol::JsonMessage;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(tag = "op", rename = "removeStatus", rename_all = "camelCase")]
pub struct RemoveStatus {
pub status_ids: Vec<String>,
}
impl RemoveStatus {
pub fn new(status_ids: impl IntoIterator<Item = impl Into<String>>) -> Self {
Self {
status_ids: status_ids.into_iter().map(|s| s.into()).collect(),
}
}
}
impl JsonMessage for RemoveStatus {}
#[cfg(test)]
mod tests {
use super::*;
fn message() -> RemoveStatus {
RemoveStatus::new(["status-1", "status-2", "status-3"])
}
#[test]
fn test_encode() {
insta::assert_json_snapshot!(message());
}
#[test]
fn test_roundtrip() {
let orig = message();
let buf = orig.to_string();
let parsed: RemoveStatus = serde_json::from_str(&buf).unwrap();
assert_eq!(parsed, orig);
}
}