| POST | /{Workspace}/UserLocation/{ObjectId} |
|---|
import Foundation
import ServiceStack
/**
* 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 .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Workspace}/UserLocation/{ObjectId} HTTP/1.1
Host: dev.fieldsquared.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UserLocation xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Field2Office.API.Model.Users">
<x xmlns="http://schemas.datacontract.org/2004/07/Field2Office.API.Model">0</x>
<y xmlns="http://schemas.datacontract.org/2004/07/Field2Office.API.Model">0</y>
<BasedOn>String</BasedOn>
<ObjectId>String</ObjectId>
<UserStatus>NotStarted</UserStatus>
<VersionId>String</VersionId>
<Workspace>String</Workspace>
</UserLocation>