Skip to main content

storage/service_line/
retail.rs

1//! Retail storage projection codes for partner products and merchandising categories.
2//!
3//! Retail records preserve partner/product evidence used for operational upsell
4//! workflows. They do not authorize recommendations by themselves; app/domain
5//! policy still owns customer suitability, review gates, and messaging.
6
7use serde::{Deserialize, Serialize};
8
9use domain::retail::product;
10
11/// Storage shape for a migrated retail service rules.
12#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
13#[serde(transparent)]
14pub struct ContractRecord(pub domain::retail::Contract);
15
16impl From<domain::retail::Contract> for ContractRecord {
17    fn from(value: domain::retail::Contract) -> Self {
18        Self(value)
19    }
20}
21
22impl From<ContractRecord> for domain::retail::Contract {
23    fn from(record: ContractRecord) -> Self {
24        record.0
25    }
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
29#[serde(rename_all = "snake_case")]
30/// Storage-facing retail partner product code.
31pub enum PartnerCode {
32    /// Stable storage code for virbac calm care.
33    VirbacCalmCare,
34    /// Stable storage code for purina pro plan veterinary supplements.
35    PurinaProPlanVeterinarySupplements,
36    /// Stable storage code for purina en boarding diet.
37    PurinaEnBoardingDiet,
38}
39
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
41#[serde(rename_all = "snake_case")]
42/// Storage-facing retail product category code.
43pub enum ProductCategoryCode {
44    /// Stable storage code for supplement.
45    Supplement,
46    /// Stable storage code for in house diet.
47    InHouseDiet,
48    /// Stable storage code for personalized upsell.
49    PersonalizedUpsell,
50}
51
52impl From<PartnerCode> for domain::retail::Partner {
53    fn from(value: PartnerCode) -> Self {
54        match value {
55            PartnerCode::VirbacCalmCare => Self::VirbacCalmCare,
56            PartnerCode::PurinaProPlanVeterinarySupplements => {
57                Self::PurinaProPlanVeterinarySupplements
58            }
59            PartnerCode::PurinaEnBoardingDiet => Self::PurinaEnBoardingDiet,
60        }
61    }
62}
63
64impl From<domain::retail::Partner> for PartnerCode {
65    fn from(value: domain::retail::Partner) -> Self {
66        match value {
67            domain::retail::Partner::VirbacCalmCare => Self::VirbacCalmCare,
68            domain::retail::Partner::PurinaProPlanVeterinarySupplements => {
69                Self::PurinaProPlanVeterinarySupplements
70            }
71            domain::retail::Partner::PurinaEnBoardingDiet => Self::PurinaEnBoardingDiet,
72        }
73    }
74}
75
76impl From<ProductCategoryCode> for product::Category {
77    fn from(value: ProductCategoryCode) -> Self {
78        match value {
79            ProductCategoryCode::Supplement => Self::Supplement,
80            ProductCategoryCode::InHouseDiet => Self::InHouseDiet,
81            ProductCategoryCode::PersonalizedUpsell => Self::PersonalizedUpsell,
82        }
83    }
84}
85
86impl From<product::Category> for ProductCategoryCode {
87    fn from(value: product::Category) -> Self {
88        match value {
89            product::Category::Supplement => Self::Supplement,
90            product::Category::InHouseDiet => Self::InHouseDiet,
91            product::Category::PersonalizedUpsell => Self::PersonalizedUpsell,
92        }
93    }
94}