use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize)] pub struct GetRequest { #[serde(rename = "accountId")] account_id: String, ids: Option>, properties: Option>, #[serde(flatten)] arguments: A, } #[derive(Debug, Clone, Deserialize)] pub struct GetResponse { #[serde(rename = "accountId")] account_id: String, state: String, list: Vec, #[serde(rename = "notFound")] not_found: Vec, } impl GetRequest { pub fn new(account_id: String) -> Self { GetRequest { account_id, ids: None, properties: None, arguments: A::default(), } } pub fn account_id(&mut self, account_id: impl Into) -> &mut Self { self.account_id = account_id.into(); self } pub fn ids(&mut self, ids: U) -> &mut Self where U: IntoIterator, V: Into, { self.ids = Some(ids.into_iter().map(|v| v.into()).collect()); self } pub fn properties(&mut self, properties: impl IntoIterator) -> &mut Self { self.properties = Some(properties.into_iter().collect()); self } pub fn arguments(&mut self) -> &mut A { &mut self.arguments } } impl GetResponse { pub fn account_id(&self) -> &str { &self.account_id } pub fn state(&self) -> &str { &self.state } pub fn list(&self) -> &[T] { &self.list } pub fn not_found(&self) -> &[String] { &self.not_found } pub fn unwrap_list(&mut self) -> Vec { std::mem::take(&mut self.list) } pub fn unwrap_not_found(&mut self) -> Vec { std::mem::take(&mut self.not_found) } }