Implemented phase 3 for the POC prototype in the Website service.
This commit is contained in:
1 parent
b1ceed7790
commit
0dc3fe6bea
29 files changed
+4089
-66
No files matched your search
@@ -13,7 +13,8 @@ extension Listing {
|
||||
condition: String = "NM/M",
|
||||
keyNotes: String? = nil,
|
||||
priceCents: Int = 24_000,
|
||||
acceptsOffers: Bool = true
|
||||
acceptsOffers: Bool = true,
|
||||
soldAt: Date? = nil
|
||||
) -> Self {
|
||||
.init(
|
||||
slug: slug, shop: shop, title: title, seriesTitle: "Nightward (2019 series)", issueLabel: "#1",
|
||||
@@ -23,7 +24,8 @@ extension Listing {
|
||||
keyNotes: keyNotes, sellerNotes: "Clean case.", priceCents: priceCents, shippingCents: 600,
|
||||
acceptsOffers: acceptsOffers,
|
||||
cover: .init(tone: "navy", title: "NIGHT\nWARD", imprint: "MERIDIAN", number: "1"),
|
||||
listedAt: .init(timeIntervalSince1970: 0)
|
||||
listedAt: .init(timeIntervalSince1970: 0),
|
||||
soldAt: soldAt
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
import Foundation
|
||||
import Persistence
|
||||
|
||||
extension Date {
|
||||
/// The moment the trade stubs are stamped at: 23 September 2026, 09:14 in Amsterdam.
|
||||
static let stub = Date(timeIntervalSince1970: 1_790_147_640)
|
||||
}
|
||||
|
||||
extension User {
|
||||
/// The demo buyer.
|
||||
static let mara = User(id: .init(), email: "mara.v@example.com", displayName: "Mara Visser")
|
||||
/// The demo seller, owner of the stub shop.
|
||||
static let joost = User(id: .init(), email: "joost@kestrelrow.example", displayName: "Joost de Wit")
|
||||
}
|
||||
|
||||
extension Offer {
|
||||
/// An offer of €215 by the demo buyer on the stub listing, open for another 47 hours unless told otherwise.
|
||||
static func stub(
|
||||
listing: Listing = .stub(),
|
||||
amountCents: Int = 21_500,
|
||||
status: Status = .open
|
||||
) -> Self {
|
||||
.init(
|
||||
id: .init(uuidString: "00000000-0000-0000-0000-0000000000AA") ?? .init(),
|
||||
conversationID: .init(uuidString: "00000000-0000-0000-0000-0000000000CC") ?? .init(),
|
||||
listing: listing,
|
||||
buyer: .mara,
|
||||
amountCents: amountCents,
|
||||
status: status,
|
||||
createdAt: .stub.addingTimeInterval(-3_600),
|
||||
expiresAt: .stub.addingTimeInterval(47 * 3_600 + 60)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Sale {
|
||||
/// A sale of the stub listing at €215 + €6, agreed at the stub moment, as far along as told.
|
||||
static func stub(
|
||||
priceCents: Int = 21_500,
|
||||
paid: Bool = false,
|
||||
sent: Bool = false,
|
||||
received: Bool = false,
|
||||
buyerRating: Int? = nil,
|
||||
sellerRating: Int? = nil
|
||||
) -> Self {
|
||||
.init(
|
||||
number: 48_213,
|
||||
conversationID: .init(uuidString: "00000000-0000-0000-0000-0000000000CC") ?? .init(),
|
||||
listing: .stub(soldAt: .stub),
|
||||
buyer: .mara,
|
||||
seller: .joost,
|
||||
priceCents: priceCents,
|
||||
askedCents: 24_000,
|
||||
shippingCents: 600,
|
||||
declared: .init(grade: "CGC 9.8 · cert 4312087-002", pageQuality: "White", printing: "First printing", notes: "Clean case."),
|
||||
agreedAt: .stub,
|
||||
paidAt: paid ? .stub.addingTimeInterval(360) : nil,
|
||||
paymentNote: paid ? "iDEAL" : nil,
|
||||
sentAt: sent ? .stub.addingTimeInterval(720) : nil,
|
||||
shippingNote: sent ? "DHL 3S123" : nil,
|
||||
receivedAt: received ? .stub.addingTimeInterval(1_080) : nil,
|
||||
buyerRating: buyerRating,
|
||||
sellerRating: sellerRating
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Conversation {
|
||||
/// A conversation about the stub listing, seen from the given side, holding the given entries.
|
||||
static func stub(
|
||||
side: Side = .buying,
|
||||
listing: Listing? = .stub(),
|
||||
entries: [Entry] = [],
|
||||
unreadCount: Int = 0,
|
||||
saleNumber: Int? = nil
|
||||
) -> Self {
|
||||
.init(
|
||||
id: .init(uuidString: "00000000-0000-0000-0000-0000000000CC") ?? .init(),
|
||||
buyer: .mara,
|
||||
shop: .stub(),
|
||||
listing: listing,
|
||||
side: side,
|
||||
entries: entries,
|
||||
unreadCount: unreadCount,
|
||||
saleNumber: saleNumber
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Conversation.Entry {
|
||||
/// Something a party wrote at the stub moment.
|
||||
static func text(
|
||||
_ body: String,
|
||||
from sender: User
|
||||
) -> Self {
|
||||
.init(kind: .text, sender: sender, body: body, createdAt: .stub)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user