updates models, adds rusty_money crate dependency

This commit is contained in:
cascode _ 2023-10-18 12:00:47 -04:00 committed by cascode
parent 25dc8413dd
commit c1626d920a
2 changed files with 59 additions and 1 deletions

View File

@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
tokio = { version = "1.2", features = ["full"] }
warp = "0.3"
rusty-money = "0.4.1"

View File

@ -22,6 +22,7 @@ struct Person {
handle: Option<String>,
email: Option<Vec<String>>,
is_active: bool,
is_blocked: bool,
created_at: chrono::DateTime,
modified_at: chrono::DateTime,
modified_by: PersonId,
@ -98,6 +99,7 @@ struct Track {
duration: chrono::Duration,
artists: HashMap<Artist>,
is_public: bool,
is_available: bool,
preview_source: Option<String>,
source: String,
price: Option<rusty_money::Money>,
@ -130,6 +132,7 @@ struct Album {
artists: HashMap<Artist>,
tracks: HashMap<Track>,
is_public: bool,
is_available: bool,
preview_source: Option<String>,
source: String,
price: Option<rusty_money::Money>,
@ -233,6 +236,48 @@ struct Comment {
}
```
# Collection
A Collection represents one or more Albums and/or Tracks that are offered together as a package for Purchase
``` rust
struct CollectionId {
id: String,
}
struct Collection {
id: CollectionId,
name: String,
description: String,
created_by: Person,
created_at: chrono::DateTime,
modified_by: Person,
modified_at: chrono::DateTime,
is_public: bool,
is_available: bool,
deleted_by: Option<Person>,
deleted_at: Option<chrono::DateTime>,
albums: Option<Vec<Album>>,
tracks: Option<Vec<Track>>,
price: Oprion<rusty_money::Money>,
}
```
# OtherProduct
An OtherProduct represents a product that is not a Track, Album, or Collection that is nonetheless for sale as a Purchase.
``` rust
struct OtherProductId {
id: String,
}
struct OtherProduct {
id: OtherProductId,
name: String,
description: String,
}
```
# Purchase
A Purchase represents one or more Tracks or Albums that a Person purchases from an Artist or Label through the server.
@ -264,8 +309,20 @@ struct PurchaseItem {
quantity: usize,
discount_percentage: usize,
}
enum PurchaseState {
InCart,
Processing,
PaymentRejected,
PaymentCompleted,
Fulfilled,
Cancelled,
Refunded,
}
struct Purchase {
id: String,
items: Vec<PurchaseItem>,
state: PurchaseState,
purchased_by: Person,
purchased_at: Option<chrono::DateTime>,
}
```