-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_shopping_cart.rs
41 lines (34 loc) · 1.42 KB
/
create_shopping_cart.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Shopping Cart Example
#![allow(unused_imports)]
use tmflib::common::related_party::RelatedParty;
use tmflib::common::note::Note;
#[cfg(all(feature = "tmf632", feature = "build-V4"))]
use tmflib::tmf620::product_offering::{ProductOffering,ProductOfferingRef};
#[cfg(all(feature = "tmf632", feature = "build-V5"))]
use tmflib::tmf620::product_offering_v5::{ProductOffering,ProductOfferingRef};
#[cfg(all(feature = "tmf632", feature = "build-V4"))]
use tmflib::tmf632::individual_v4::Individual;
#[cfg(all(feature = "tmf632", feature = "build-V5"))]
use tmflib::tmf632::individual_v5::Individual;
#[cfg(all(feature = "tmf663", feature = "build-V4"))]
use tmflib::tmf663::shopping_cart::ShoppingCart;
#[cfg(all(feature = "tmf663", feature = "build-V4"))]
use tmflib::tmf663::cart_item::CartItem;
use tmflib::HasRelatedParty;
fn main() {
#[cfg(all(feature = "tmf663", feature = "build-V4"))]
{
let mut cart = ShoppingCart::new();
let offer = ProductOffering::new("MyProductOffer");
let por = ProductOfferingRef::from(offer);
let individual = Individual::new("John Smith")
.email("[email protected]")
.mobile("0411 111 111");
let note1 = Note::from("Checking on stock levels");
let mut item = CartItem::from(por);
item.add_note(note1);
cart.add_item(item);
cart.add_party(RelatedParty::from(&individual));
dbg!(cart);
}
}