use alloc::borrow::Cow;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use crate::models::{amount::XRPAmount, requests::RequestMethod, Model};
use super::{CommonFields, Request};
#[skip_serializing_none]
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
pub struct ChannelVerify<'a> {
#[serde(flatten)]
pub common_fields: CommonFields<'a>,
pub amount: XRPAmount<'a>,
pub channel_id: Cow<'a, str>,
pub public_key: Cow<'a, str>,
pub signature: Cow<'a, str>,
}
impl<'a> Model for ChannelVerify<'a> {}
impl<'a> Request<'a> for ChannelVerify<'a> {
fn get_common_fields(&self) -> &CommonFields<'a> {
&self.common_fields
}
fn get_common_fields_mut(&mut self) -> &mut CommonFields<'a> {
&mut self.common_fields
}
}
impl<'a> ChannelVerify<'a> {
pub fn new(
id: Option<Cow<'a, str>>,
amount: XRPAmount<'a>,
channel_id: Cow<'a, str>,
public_key: Cow<'a, str>,
signature: Cow<'a, str>,
) -> Self {
Self {
common_fields: CommonFields {
command: RequestMethod::ChannelVerify,
id,
},
channel_id,
amount,
public_key,
signature,
}
}
}