| GET | /{Workspace}/UserLocationList |
|---|
import Foundation
import ServiceStack
/**
* Returns a list of all user's locations for the entire workspace.
*/
public class UserLocationList : Codable
{
public var workspace:String
public var dateGenerated:String
public var userLocations:[UserLocation] = []
required public init(){}
}
/**
* Service representing a UserLocation in a workspace.
*/
public class UserLocation : Location
{
public var workspace:String
public var objectId:String
public var versionId:String
public var basedOn:String
public var userStatus:UserStatus
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case workspace
case objectId
case versionId
case basedOn
case userStatus
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
workspace = try container.decodeIfPresent(String.self, forKey: .workspace)
objectId = try container.decodeIfPresent(String.self, forKey: .objectId)
versionId = try container.decodeIfPresent(String.self, forKey: .versionId)
basedOn = try container.decodeIfPresent(String.self, forKey: .basedOn)
userStatus = try container.decodeIfPresent(UserStatus.self, forKey: .userStatus)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if workspace != nil { try container.encode(workspace, forKey: .workspace) }
if objectId != nil { try container.encode(objectId, forKey: .objectId) }
if versionId != nil { try container.encode(versionId, forKey: .versionId) }
if basedOn != nil { try container.encode(basedOn, forKey: .basedOn) }
if userStatus != nil { try container.encode(userStatus, forKey: .userStatus) }
}
}
public class Location : Codable
{
public var y:Double
public var x:Double
required public init(){}
}
public enum UserStatus : String, Codable
{
case NotStarted
case Driving
case InProgress
case Complete
case Blocked
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /{Workspace}/UserLocationList HTTP/1.1
Host: dev.fieldsquared.com
Accept: application/json