use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct CustomerRef {
pub handle: String,
pub handle_type: HandleType,
pub receiver_org_id: Option<String>,
}
impl CustomerRef {
pub fn new(handle: String, handle_type: HandleType) -> Self {
Self {
handle,
handle_type,
receiver_org_id: None,
}
}
pub fn with_receiver_org_id(mut self, receiver_org_id: String) -> Self {
self.receiver_org_id = Some(receiver_org_id);
self
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SenderCustomerRef {
pub handle: String,
pub handle_type: HandleType,
pub receiver_org_id: String,
}
impl Into<CustomerRef> for SenderCustomerRef {
fn into(self) -> CustomerRef {
CustomerRef {
handle: self.handle,
handle_type: self.handle_type,
receiver_org_id: Some(self.receiver_org_id),
}
}
}
pub struct ReceiverCustomerRef {
pub handle: String,
pub handle_type: HandleType,
}
impl Into<CustomerRef> for ReceiverCustomerRef {
fn into(self) -> CustomerRef {
CustomerRef {
handle: self.handle,
handle_type: self.handle_type,
receiver_org_id: None,
}
}
}
#[derive(Debug, Deserialize, PartialEq, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum HandleType {
CustomerEmail,
CustomerEmailDomain,
MerchantGroupCode,
MerchantUserCode,
}