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 datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Location:
    y: float = 0.0
    x: float = 0.0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ClassedItem:
    object_id: Optional[str] = None
    class_: Optional[str] = field(metadata=config(field_name='class'), default=None)
    version_id: Optional[str] = None
    ancestors: Optional[List[str]] = None
    type: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Schedule:
    workspace: Optional[str] = None
    object_id: Optional[str] = None
    version_id: Optional[str] = None
    based_on: Optional[str] = None
    start: Optional[str] = None
    end: Optional[str] = None
    time_zone: Optional[str] = None
    users: Optional[List[str]] = None
    teams: Optional[List[str]] = None
    data: Optional[Dict[str, Object]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RouteNode(ClassedItem):
    location: Optional[Location] = None
    stop_time: int = 0
    schedule: Optional[Schedule] = None
    name: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RouteSegment:
    time: int = 0
    distance: float = 0.0
    start: Optional[str] = None
    end: Optional[str] = None
    geometry: Optional[List[Location]] = None
    driving_directions: Optional[List[str]] = None
    end_node: Optional[RouteNode] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Route:
    """
    Contains the data for a route within the system.
    """

    workspace: Optional[str] = None
    assigned_workspace: Optional[str] = None
    object_id: Optional[str] = None
    version_id: Optional[str] = None
    based_on: Optional[str] = None
    created: Optional[str] = None
    last_updated: Optional[str] = None
    date: Optional[str] = None
    start_time: Optional[str] = None
    end_time: Optional[str] = None
    user_id: Optional[str] = None
    name: Optional[str] = None
    type: Optional[str] = None
    segments: Optional[List[RouteSegment]] = None
    total_time: int = 0
    total_distance: float = 0.0
    nodes: Optional[List[RouteNode]] = None

Python Route DTOs

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

HTTP + JSV

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/jsv
Content-Type: text/jsv
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
		}
	]
}