import Dependencies import Foundation public struct Vendor: Codable, Equatable, Identifiable, Sendable { public var id: UUID public var name: String public var branches: [VendorBranch]? public var createdAt: Date? public var updatedAt: Date? public init( id: UUID, name: String, branches: [VendorBranch]? = nil, createdAt: Date? = nil, updatedAt: Date? = nil ) { self.id = id self.name = name self.branches = branches self.createdAt = createdAt self.updatedAt = updatedAt } } public extension Vendor { struct Create: Codable, Sendable { public let name: String public init(name: String) { self.name = name } } struct Update: Codable, Sendable { public let name: String public init(name: String) { self.name = name } } } #if DEBUG // // public extension Vendor { // // static func generateMocks(count: Int = 20) -> [Self] { // @Dependency(\.date.now) var now // @Dependency(\.uuid) var uuid // // var output = [Self]() // // for _ in 0 ... count { // output.append(.init( // id: uuid(), // name: RandomNames.companyNames.randomElement()!, // branches: nil, // createdAt: now, // updatedAt: now // )) // } // // return output // } // } public extension Vendor.Create { static func generateMocks(count: Int = 5) -> [Self] { (0 ... count).reduce(into: [Self]()) { array, _ in array.append(.init( name: RandomNames.companyNames.randomElement()! + String(RandomNames.characterString.randomElement()!) )) } } } #endif