| POST | /{Workspace}/Track/{UserId} |
|---|
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 StopItem:
"""
Service representing a StopItem object in a workspace.
"""
pt: Optional[str] = None
int_: int = field(metadata=config(field_name='int'), default=0)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class RedlineItem:
"""
Service representing a RedlineItem object in a workspace.
"""
pt: Optional[str] = None
int_: int = field(metadata=config(field_name='int'), default=0)
avg: float = 0.0
@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 Address:
street: Optional[str] = None
unit: Optional[str] = None
city: Optional[str] = None
state: Optional[str] = None
zip: Optional[str] = None
contact_title: Optional[str] = None
contact_name: Optional[str] = None
contact_phone: Optional[str] = None
contact_email: Optional[str] = None
location: Optional[Location] = None
site_name: Optional[str] = None
geocode_failed: bool = False
country: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Track:
"""
Service representing a Track object in a workspace. Note that request.TrackId is returned on successful POST else null. The Items property is a list of Item objects, each object representing a location where the user stopped for a period of time. The Item object is comprised of a Location property (Lat/Lon), Time property (Timestamp in UTC string format) and Interval Property (Time stopped in seconds). The RedlineItems property is a list of RedlineItem objects, each object representing a location where the user began exceeding the redline speed defined in the workspace for a period of time also defined in the workspace. The properties are identical to the StopItem object, however the Interval property represents time spent above the redline speed in seconds. Speed property is in meters per sec.
"""
workspace: Optional[str] = None
user_id: Optional[str] = None
track_id: Optional[str] = None
items: Optional[List[str]] = None
stops: Optional[List[StopItem]] = None
spd: Optional[List[RedlineItem]] = None
address: Optional[Address] = None
distance: float = 0.0
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Workspace}/Track/{UserId} HTTP/1.1
Host: dev.fieldsquared.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
Workspace: String,
UserId: String,
TrackId: String,
Items:
[
String
],
Stops:
[
{
PT: String,
Int: 0
}
],
Spd:
[
{
PT: String,
Int: 0,
Avg: 0
}
],
Address:
{
Street: String,
Unit: String,
City: String,
State: String,
Zip: String,
ContactTitle: String,
ContactName: String,
ContactPhone: String,
ContactEmail: String,
Location:
{
y: 0,
x: 0
},
SiteName: String,
GeocodeFailed: False,
Country: String
},
Distance: 0
}