use serde::{Deserialize, Serialize};
use crate::common::tmf_error::TMFError;
use crate::{HasDescription, HasId, HasName, HasRelatedParty, HasValidity, TimePeriod, Uri};
use crate::tmf663::{cart_item::ItemRef, shopping_cart::ShoppingCartRef};
use crate::common::product::ProductRefOrValue;
use crate::common::related_party::RelatedParty;
use crate::common::related_place::RelatedPlaceRefOrValue;
#[cfg(feature = "build-V4")]
use crate::tmf620::product_offering::ProductOfferingRef;
#[cfg(feature = "build-V5")]
use crate::tmf620::product_offering_v5::ProductOfferingRef;
#[cfg(feature = "build-V4")]
use crate::tmf622::product_order_v4::ProductOrderRef;
#[cfg(feature = "build-V5")]
use crate::tmf622::product_order_v5::ProductOrderRef;
use super::MOD_PATH;
use tmflib_derive::{HasDescription, HasId, HasName, HasRelatedParty, HasValidity};
const CLASS_PATH: &str = "queryProductRecommendation";
#[derive(Clone, Default, Debug, Serialize, Deserialize)]
pub struct RecommentationItem {
pub id: Option<String>,
pub priority: u32,
pub product: Option<Vec<ProductRefOrValue>>,
pub product_offering: Option<Vec<ProductOfferingRef>>,
}
#[derive(
Clone,
Default,
Debug,
HasId,
HasName,
HasDescription,
HasValidity,
HasRelatedParty,
Deserialize,
Serialize,
)]
pub struct QueryProductRecommendation {
pub id: Option<String>,
pub href: Option<Uri>,
pub name: Option<String>,
pub description: Option<String>,
pub valid_for: Option<TimePeriod>,
pub related_party: Option<Vec<RelatedParty>>,
pub place: Option<Vec<RelatedPlaceRefOrValue>>,
pub product: Option<Vec<ProductRefOrValue>>,
pub product_order: Option<Vec<ProductOrderRef>>,
pub recommendation_item: Option<Vec<RecommentationItem>>,
pub shopping_cart: Option<Vec<ShoppingCartRef>>,
pub shopping_cart_item: Option<Vec<ItemRef>>,
}
impl QueryProductRecommendation {
pub fn new(name: impl Into<String>) -> QueryProductRecommendation {
QueryProductRecommendation {
name: Some(name.into()),
..QueryProductRecommendation::create()
}
}
}
#[cfg(test)]
mod test {
use super::*;
const REC_NAME: &str = "Recommendation Name";
const REC_DESC: &str = "Recommendation Description";
#[test]
fn test_recommendation_create() {
let recommendation = QueryProductRecommendation::new(REC_NAME).description(REC_DESC);
assert_eq!(recommendation.get_name(), REC_NAME.to_string());
assert_eq!(recommendation.get_description(), REC_DESC.to_string());
}
}