/* Options: Date: 2025-12-06 06:42:39 SwiftVersion: 5.0 Version: 8.0 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://api.1fetch.co.za //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: Order.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack // @Route("/order", "GET") public class Order : ApiServiceRequest, IReturn, ILogRequest { public typealias Return = OrderResponse /** * The ID if getting specific order */ // @ApiMember(Description="The ID if getting specific order") public var orderId:String /** * The amount of elements to offset the index by */ // @ApiMember(Description="The amount of elements to offset the index by") public var offset:Int /** * The number of elements to be returned, defaults to 10 */ // @ApiMember(Description="The number of elements to be returned, defaults to 10") public var count:Int required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case orderId case offset case count } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) orderId = try container.decodeIfPresent(String.self, forKey: .orderId) offset = try container.decodeIfPresent(Int.self, forKey: .offset) count = try container.decodeIfPresent(Int.self, forKey: .count) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if orderId != nil { try container.encode(orderId, forKey: .orderId) } if offset != nil { try container.encode(offset, forKey: .offset) } if count != nil { try container.encode(count, forKey: .count) } } } public class OrderResponse : ApiServiceResponse { /** * List with order details, will only contain one item if requested with order id */ // @ApiMember(Description="List with order details, will only contain one item if requested with order id") public var orderItems:[OrderDetail] = [] /** * Total number of items in order collection */ // @ApiMember(Description="Total number of items in order collection") public var totalCount:Int /** * Used to indicate if there are more items available */ // @ApiMember(Description="Used to indicate if there are more items available") public var lastPage:Bool required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case orderItems case totalCount case lastPage } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) orderItems = try container.decodeIfPresent([OrderDetail].self, forKey: .orderItems) ?? [] totalCount = try container.decodeIfPresent(Int.self, forKey: .totalCount) lastPage = try container.decodeIfPresent(Bool.self, forKey: .lastPage) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if orderItems.count > 0 { try container.encode(orderItems, forKey: .orderItems) } if totalCount != nil { try container.encode(totalCount, forKey: .totalCount) } if lastPage != nil { try container.encode(lastPage, forKey: .lastPage) } } } public class ApiServiceRequest : IServiceRequest, IHasApiKey, Codable { /** * The API Key required for authentication */ // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true) public var apiKey:String required public init(){} } public protocol IServiceRequest { } public protocol IHasApiKey { var apiKey:String { get set } } public protocol ILogRequest { } public class OrderDetail : Codable { /** * ID of quote attached to the order */ // @ApiMember(Description="ID of quote attached to the order") public var quoteId:String /** * ID of order */ // @ApiMember(Description="ID of order") public var orderId:String /** * User friendly order identifier */ // @ApiMember(Description="User friendly order identifier") public var waybill:String /** * Invoice number for the order */ // @ApiMember(Description="Invoice number for the order") public var invoiceNumber:String /** * The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true */ // @ApiMember(Description="The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true") public var scheduledDate:String /** * Order status number */ // @ApiMember(Description="Order status number") public var orderStatus:OrderStatus /** * String value of order status */ // @ApiMember(Description="String value of order status") public var orderStatusValue:String /** * List of waypoints for this order */ // @ApiMember(Description="List of waypoints for this order") public var waypoints:[OrderItemWaypoint] = [] /** * List of sections between waypoints */ // @ApiMember(Description="List of sections between waypoints") public var transitPoints:[OrderTransitPoint] = [] /** * Order Final price including VAT */ // @ApiMember(Description="Order Final price including VAT") public var finalPrice:Double /** * Final price formatted as ZA currency */ // @ApiMember(Description="Final price formatted as ZA currency") public var finalPriceValue:String /** * Total distance for the order in km */ // @ApiMember(Description="Total distance for the order in km") public var totalDistance:Double /** * Total distance for the order formatted as a string */ // @ApiMember(Description="Total distance for the order formatted as a string") public var totalDistanceValue:String /** * Date order was placed */ // @ApiMember(Description="Date order was placed") public var date:String /** * Google encoded maps polyline path for drawing route on a google map */ // @ApiMember(Description="Google encoded maps polyline path for drawing route on a google map") public var encodedPolyPath:String /** * List of events as they occurred while the order was in progress */ // @ApiMember(Description="List of events as they occurred while the order was in progress") public var events:[EventDetail] = [] required public init(){} } public enum OrderStatus : Int, Codable { case AwaitingPayment = 0 case ProcessingPayment = 1 case AwaitingDispatch = 2 case DriverDispatched = 3 case PackageEnRoute = 4 case Completed = 5 case Cancelled = 6 case DeliveryFailed = 7 } public class OrderItemWaypoint : Codable { /** * Has the driver completed this waypoint */ // @ApiMember(Description="Has the driver completed this waypoint") public var completed:Bool public var latitude:Double public var longitude:Double public var address:String public var contactName:String public var contactNumber:String public var deliveryInstructions:String /** * Details captured at waypoint */ // @ApiMember(Description="Details captured at waypoint") public var scanDetail:ScanDetail required public init(){} } public class OrderTransitPoint : Codable { /** * Origin waypoint number */ // @ApiMember(Description="Origin waypoint number") public var fromWaypointNumber:Int /** * Destination waypoint number */ // @ApiMember(Description="Destination waypoint number") public var toWaypointNumber:Int /** * Distance between waypoints */ // @ApiMember(Description="Distance between waypoints") public var distance:Double /** * Distance between waypoints rounded and converted to a string */ // @ApiMember(Description="Distance between waypoints rounded and converted to a string") public var distanceValue:String /** * Price calculated between waypoints */ // @ApiMember(Description="Price calculated between waypoints") public var price:Double /** * Price calculated between waypoints formatted as ZA currency */ // @ApiMember(Description="Price calculated between waypoints formatted as ZA currency") public var priceValue:String required public init(){} } public class EventDetail : Codable { public var Description:String public var time:String public var eventDateTime:Date required public init(){} } public class ScanDetail : Codable { /** * List of URLs for images captured at the waypoint */ // @ApiMember(Description="List of URLs for images captured at the waypoint") public var photoUrls:[String] = [] /** * List of URLs for images of signatures captured at the waypoint */ // @ApiMember(Description="List of URLs for images of signatures captured at the waypoint") public var signatureUrls:[String] = [] /** * Name of person the driver interacted with at the waypoint */ // @ApiMember(Description="Name of person the driver interacted with at the waypoint") public var receivedBy:String /** * The date the driver interacted with the person */ // @ApiMember(Description="The date the driver interacted with the person") public var receivedDate:String /** * Number of packages collected by the driver */ // @ApiMember(Description="Number of packages collected by the driver") public var packagesCollected:Int required public init(){} } public class ApiServiceResponse : IServiceResponse, Codable { /** * Information about the response. */ // @ApiMember(Description="Information about the response.", IsRequired=true) public var Description:String /** * Heading or summary of the response. */ // @ApiMember(Description="Heading or summary of the response.", IsRequired=true) public var heading:String /** * Did the intended operation for this response complete successfully? */ // @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true) public var wasSuccessful:Bool required public init(){} }