tap_msg/message/
reject.rs1use serde::{Deserialize, Serialize};
7
8use crate::error::{Error, Result};
9use crate::TapMessage;
10
11#[derive(Debug, Clone, Serialize, Deserialize, TapMessage)]
13#[tap(message_type = "https://tap.rsvp/schema/1.0#Reject")]
14pub struct Reject {
15 #[tap(thread_id)]
17 pub transaction_id: String,
18
19 pub reason: String,
21}
22
23impl Reject {
24 pub fn new(transaction_id: &str, reason: &str) -> Self {
26 Self {
27 transaction_id: transaction_id.to_string(),
28 reason: reason.to_string(),
29 }
30 }
31}
32
33impl Reject {
34 pub fn validate_reject(&self) -> Result<()> {
36 if self.transaction_id.is_empty() {
37 return Err(Error::Validation(
38 "Transaction ID is required in Reject".to_string(),
39 ));
40 }
41
42 if self.reason.is_empty() {
43 return Err(Error::Validation(
44 "Reason is required in Reject".to_string(),
45 ));
46 }
47
48 Ok(())
49 }
50}