Field Squared API Services

<back to all web services

Route

Contains the data for a route within the system.

The following routes are available for this service:
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(){}
}


Swift Route DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

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: application/xml
Content-Type: application/xml
Content-Length: length

<Route xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Field2Office.API.Model.MapRoute">
  <AssignedWorkspace>String</AssignedWorkspace>
  <BasedOn>String</BasedOn>
  <Created>String</Created>
  <Date>String</Date>
  <EndTime>String</EndTime>
  <LastUpdated>String</LastUpdated>
  <Name>String</Name>
  <Nodes>
    <RouteNode>
      <Ancestors xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">
        <d4p1:string>String</d4p1:string>
      </Ancestors>
      <Class xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</Class>
      <ObjectId xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</ObjectId>
      <Type xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</Type>
      <VersionId xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</VersionId>
      <Location xmlns:d4p1="http://schemas.datacontract.org/2004/07/Field2Office.API.Model">
        <d4p1:x>0</d4p1:x>
        <d4p1:y>0</d4p1:y>
      </Location>
      <Name>String</Name>
      <Schedule xmlns:d4p1="http://schemas.datacontract.org/2004/07/Field2Office.API.Model.Schedules">
        <d4p1:BasedOn>String</d4p1:BasedOn>
        <d4p1:Data xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringanyType>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value />
          </d5p1:KeyValueOfstringanyType>
        </d4p1:Data>
        <d4p1:End>String</d4p1:End>
        <d4p1:ObjectId>String</d4p1:ObjectId>
        <d4p1:Start>String</d4p1:Start>
        <d4p1:Teams xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:string>String</d5p1:string>
        </d4p1:Teams>
        <d4p1:TimeZone>String</d4p1:TimeZone>
        <d4p1:Users xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:string>String</d5p1:string>
        </d4p1:Users>
        <d4p1:VersionId>String</d4p1:VersionId>
        <d4p1:Workspace>String</d4p1:Workspace>
      </Schedule>
      <StopTime>0</StopTime>
    </RouteNode>
  </Nodes>
  <ObjectId>String</ObjectId>
  <Segments>
    <RouteSegment>
      <Distance>0</Distance>
      <DrivingDirections xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:string>String</d4p1:string>
      </DrivingDirections>
      <End>String</End>
      <EndNode>
        <Ancestors xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">
          <d5p1:string>String</d5p1:string>
        </Ancestors>
        <Class xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</Class>
        <ObjectId xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</ObjectId>
        <Type xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</Type>
        <VersionId xmlns="http://schemas.datacontract.org/2004/07/Field2Office.DomainObjects.Model">String</VersionId>
        <Location xmlns:d5p1="http://schemas.datacontract.org/2004/07/Field2Office.API.Model">
          <d5p1:x>0</d5p1:x>
          <d5p1:y>0</d5p1:y>
        </Location>
        <Name>String</Name>
        <Schedule xmlns:d5p1="http://schemas.datacontract.org/2004/07/Field2Office.API.Model.Schedules">
          <d5p1:BasedOn>String</d5p1:BasedOn>
          <d5p1:Data xmlns:d6p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
            <d6p1:KeyValueOfstringanyType>
              <d6p1:Key>String</d6p1:Key>
              <d6p1:Value />
            </d6p1:KeyValueOfstringanyType>
          </d5p1:Data>
          <d5p1:End>String</d5p1:End>
          <d5p1:ObjectId>String</d5p1:ObjectId>
          <d5p1:Start>String</d5p1:Start>
          <d5p1:Teams xmlns:d6p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
            <d6p1:string>String</d6p1:string>
          </d5p1:Teams>
          <d5p1:TimeZone>String</d5p1:TimeZone>
          <d5p1:Users xmlns:d6p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
            <d6p1:string>String</d6p1:string>
          </d5p1:Users>
          <d5p1:VersionId>String</d5p1:VersionId>
          <d5p1:Workspace>String</d5p1:Workspace>
        </Schedule>
        <StopTime>0</StopTime>
      </EndNode>
      <Geometry xmlns:d4p1="http://schemas.datacontract.org/2004/07/Field2Office.API.Model">
        <d4p1:Location>
          <d4p1:x>0</d4p1:x>
          <d4p1:y>0</d4p1:y>
        </d4p1:Location>
      </Geometry>
      <Start>String</Start>
      <Time>0</Time>
    </RouteSegment>
  </Segments>
  <StartTime>String</StartTime>
  <Type>String</Type>
  <UserId>String</UserId>
  <VersionId>String</VersionId>
  <Workspace>String</Workspace>
</Route>