| GET,POST,DELETE | /{Workspace}/Route/{ObjectId} | ||
|---|---|---|---|
| GET | /{Workspace}/Route/{UserId}/{Date} |
import Foundation
import ServiceStack
/**
* Contains the data for a route within the system.
*/
public class Route : Codable
{
public var workspace:String
public var assignedWorkspace:String
public var objectId:String
public var versionId:String
public var basedOn:String
public var created:String
public var lastUpdated:String
public var date:String
public var startTime:String
public var endTime:String
public var userId:String
public var name:String
public var type:String
public var segments:[RouteSegment] = []
public var totalTime:Int
public var totalDistance:Double
public var nodes:[RouteNode] = []
required public init(){}
}
public class RouteSegment : Codable
{
public var time:Int
public var distance:Double
public var start:String
public var end:String
public var geometry:[Location] = []
public var drivingDirections:[String] = []
public var endNode:RouteNode
required public init(){}
}
public class Location : Codable
{
public var y:Double
public var x:Double
required public init(){}
}
public class RouteNode : ClassedItem
{
public var location:Location
public var stopTime:Int
public var schedule:Schedule
public var name:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case location
case stopTime
case schedule
case name
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
location = try container.decodeIfPresent(Location.self, forKey: .location)
stopTime = try container.decodeIfPresent(Int.self, forKey: .stopTime)
schedule = try container.decodeIfPresent(Schedule.self, forKey: .schedule)
name = try container.decodeIfPresent(String.self, forKey: .name)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if location != nil { try container.encode(location, forKey: .location) }
if stopTime != nil { try container.encode(stopTime, forKey: .stopTime) }
if schedule != nil { try container.encode(schedule, forKey: .schedule) }
if name != nil { try container.encode(name, forKey: .name) }
}
}
public class ClassedItem : Codable
{
public var objectId:String
public var `class`:String
public var versionId:String
public var ancestors:[String] = []
public var type:String
required public init(){}
}
public class Schedule : Codable
{
public var workspace:String
public var objectId:String
public var versionId:String
public var basedOn:String
public var start:String
public var end:String
public var timeZone:String
public var users:[String] = []
public var teams:[String] = []
public var data:[String:Object] = [:]
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Workspace}/Route/{ObjectId} HTTP/1.1
Host: dev.fieldsquared.com
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"Workspace":"String","AssignedWorkspace":"String","ObjectId":"String","VersionId":"String","BasedOn":"String","Created":"String","LastUpdated":"String","Date":"String","StartTime":"String","EndTime":"String","UserId":"String","Name":"String","Type":"String","Segments":[{"Time":0,"Distance":0,"Start":"String","End":"String","Geometry":[{"y":0,"x":0}],"DrivingDirections":["String"],"EndNode":{"Location":{"y":0,"x":0},"StopTime":0,"Schedule":{"Workspace":"String","ObjectId":"String","VersionId":"String","BasedOn":"String","Start":"String","End":"String","TimeZone":"String","Users":["String"],"Teams":["String"],"Data":{"String":{}}},"Name":"String","ObjectId":"String","Class":"String","VersionId":"String","Ancestors":["String"],"Type":"String"}}],"TotalTime":0,"TotalDistance":0,"Nodes":[{"Location":{"y":0,"x":0},"StopTime":0,"Schedule":{"Workspace":"String","ObjectId":"String","VersionId":"String","BasedOn":"String","Start":"String","End":"String","TimeZone":"String","Users":["String"],"Teams":["String"],"Data":{"String":{}}},"Name":"String","ObjectId":"String","Class":"String","VersionId":"String","Ancestors":["String"],"Type":"String"}]}