use crate::core::macros::{tmf_entity, tmf_patch_body, tmf_struct};
use crate::core::{
BillingAccount, Characteristic, Duration, Intent, ItemAction, Price, Ref, RelatedParty,
RelatedPlace, TimePeriod, Timestamp,
};
use crate::resource::Resource;
use crate::service::Service;
use super::{ProductOffering, ProductOfferingPrice, ProductSpecification};
tmf_struct! {
@name = "Product", @ref = "ProductRef";
pub struct Product {
id: String,
href: String,
name: String,
description: String,
is_bundle: bool,
is_customer_visible: bool,
product_serial_number: String,
status: ProductStatus,
creation_date: Timestamp,
order_date: Timestamp,
start_date: Timestamp,
termination_date: Timestamp,
product_specification: Ref<ProductSpecification>,
product_offering: Ref<ProductOffering>,
product_characteristic: Vec<Characteristic>,
product_price: Vec<ProductPrice>,
product_term: Vec<ProductTerm>,
product_relationship: Vec<ProductRelationship>,
product: Vec<Product>,
product_order_item: Vec<RelatedOrderItem>,
agreement_item: Vec<AgreementItemRef>,
place: Vec<RelatedPlace>,
realizing_service: Vec<Ref<Service>>,
realizing_resource: Vec<Ref<Resource>>,
intent: Ref<Intent>,
related_party: Vec<RelatedParty>,
billing_account: Ref<BillingAccount>,
@renamed {
"@referredType" referred_type: String,
}
}
}
tmf_entity!(Product);
tmf_struct! {
@name = "Product";
pub struct ProductCreate {
id: String,
name: String,
description: String,
is_bundle: bool,
is_customer_visible: bool,
product_serial_number: String,
status: ProductStatus,
order_date: Timestamp,
start_date: Timestamp,
termination_date: Timestamp,
product_specification: Ref<ProductSpecification>,
product_offering: Ref<ProductOffering>,
product_characteristic: Vec<Characteristic>,
product_price: Vec<ProductPrice>,
product_term: Vec<ProductTerm>,
product_relationship: Vec<ProductRelationship>,
product: Vec<Product>,
product_order_item: Vec<RelatedOrderItem>,
agreement_item: Vec<AgreementItemRef>,
place: Vec<RelatedPlace>,
realizing_service: Vec<Ref<Service>>,
realizing_resource: Vec<Ref<Resource>>,
intent: Ref<Intent>,
related_party: Vec<RelatedParty>,
billing_account: Ref<BillingAccount>,
}
}
tmf_struct! {
@name = "Product";
pub struct ProductUpdate {
name: String,
description: String,
is_bundle: bool,
is_customer_visible: bool,
product_serial_number: String,
status: ProductStatus,
order_date: Timestamp,
start_date: Timestamp,
termination_date: Timestamp,
product_specification: Ref<ProductSpecification>,
product_offering: Ref<ProductOffering>,
product_characteristic: Vec<Characteristic>,
product_price: Vec<ProductPrice>,
product_term: Vec<ProductTerm>,
product_relationship: Vec<ProductRelationship>,
product: Vec<Product>,
product_order_item: Vec<RelatedOrderItem>,
agreement_item: Vec<AgreementItemRef>,
place: Vec<RelatedPlace>,
realizing_service: Vec<Ref<Service>>,
realizing_resource: Vec<Ref<Resource>>,
intent: Ref<Intent>,
related_party: Vec<RelatedParty>,
billing_account: Ref<BillingAccount>,
}
}
tmf_patch_body!(ProductUpdate);
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[non_exhaustive]
pub enum ProductStatus {
#[serde(rename = "created")]
Created,
#[serde(rename = "pendingActive")]
PendingActive,
#[serde(rename = "active")]
Active,
#[serde(rename = "suspended")]
Suspended,
#[serde(rename = "pendingTerminate")]
PendingTerminate,
#[serde(rename = "terminated")]
Terminated,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "aborted ")]
Aborted,
#[serde(untagged)]
Other(String),
}
tmf_struct! {
@name = "ProductPrice";
pub struct ProductPrice {
name: String,
description: String,
price_type: String,
recurring_charge_period: String,
unit_of_measure: String,
price: Price,
price_alteration: Vec<PriceAlteration>,
product_offering_price: Ref<ProductOfferingPrice>,
}
}
tmf_struct! {
@name = "ProductTerm";
pub struct ProductTerm {
name: String,
description: String,
duration: Duration,
valid_for: TimePeriod,
}
}
tmf_struct! {
@name = "ProductRelationship";
pub struct ProductRelationship {
id: String,
href: String,
name: String,
relationship_type: String,
@renamed {
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "RelatedOrderItem";
pub struct RelatedOrderItem {
order_id: String,
order_href: String,
order_item_id: String,
order_item_action: ItemAction,
role: String,
@renamed {
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "AgreementItemRef";
pub struct AgreementItemRef {
agreement_id: String,
agreement_href: String,
agreement_name: String,
agreement_item_id: String,
@renamed {
"@referredType" referred_type: String,
}
}
}
tmf_struct! {
@name = "PriceAlteration";
pub struct PriceAlteration {
name: String,
description: String,
price_type: String,
priority: i64,
recurring_charge_period: String,
application_duration: i64,
unit_of_measure: String,
price: Price,
product_offering_price: Ref<ProductOfferingPrice>,
}
}