Field Squared API Services

<back to all web services

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.

The following routes are available for this service:
POST/{Workspace}/Track/{UserId}
import 'package:servicestack/servicestack.dart';

/**
* Service representing a StopItem object in a workspace.
*/
class StopItem implements IConvertible
{
    String? PT;
    int? Int;

    StopItem({this.PT,this.Int});
    StopItem.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        PT = json['PT'];
        Int = json['Int'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'PT': PT,
        'Int': Int
    };

    getTypeName() => "StopItem";
    TypeContext? context = _ctx;
}

/**
* Service representing a RedlineItem object in a workspace.
*/
class RedlineItem implements IConvertible
{
    String? PT;
    int? Int;
    double? Avg;

    RedlineItem({this.PT,this.Int,this.Avg});
    RedlineItem.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        PT = json['PT'];
        Int = json['Int'];
        Avg = JsonConverters.toDouble(json['Avg']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'PT': PT,
        'Int': Int,
        'Avg': Avg
    };

    getTypeName() => "RedlineItem";
    TypeContext? context = _ctx;
}

class Location implements IConvertible
{
    double? y;
    double? x;

    Location({this.y,this.x});
    Location.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        y = JsonConverters.toDouble(json['y']);
        x = JsonConverters.toDouble(json['x']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'y': y,
        'x': x
    };

    getTypeName() => "Location";
    TypeContext? context = _ctx;
}

class Address implements IConvertible
{
    String? Street;
    String? Unit;
    String? City;
    String? State;
    String? Zip;
    String? ContactTitle;
    String? ContactName;
    String? ContactPhone;
    String? ContactEmail;
    Location? Location;
    String? SiteName;
    bool? GeocodeFailed;
    String? Country;

    Address({this.Street,this.Unit,this.City,this.State,this.Zip,this.ContactTitle,this.ContactName,this.ContactPhone,this.ContactEmail,this.Location,this.SiteName,this.GeocodeFailed,this.Country});
    Address.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Street = json['Street'];
        Unit = json['Unit'];
        City = json['City'];
        State = json['State'];
        Zip = json['Zip'];
        ContactTitle = json['ContactTitle'];
        ContactName = json['ContactName'];
        ContactPhone = json['ContactPhone'];
        ContactEmail = json['ContactEmail'];
        Location = JsonConverters.fromJson(json['Location'],'Location',context!);
        SiteName = json['SiteName'];
        GeocodeFailed = json['GeocodeFailed'];
        Country = json['Country'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Street': Street,
        'Unit': Unit,
        'City': City,
        'State': State,
        'Zip': Zip,
        'ContactTitle': ContactTitle,
        'ContactName': ContactName,
        'ContactPhone': ContactPhone,
        'ContactEmail': ContactEmail,
        'Location': JsonConverters.toJson(Location,'Location',context!),
        'SiteName': SiteName,
        'GeocodeFailed': GeocodeFailed,
        'Country': Country
    };

    getTypeName() => "Address";
    TypeContext? context = _ctx;
}

/**
* 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.
*/
class Track implements IConvertible
{
    String? Workspace;
    String? UserId;
    String? TrackId;
    List<String>? Items;
    List<StopItem>? Stops;
    List<RedlineItem>? Spd;
    Address? Address;
    double? Distance;

    Track({this.Workspace,this.UserId,this.TrackId,this.Items,this.Stops,this.Spd,this.Address,this.Distance});
    Track.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Workspace = json['Workspace'];
        UserId = json['UserId'];
        TrackId = json['TrackId'];
        Items = JsonConverters.fromJson(json['Items'],'List<String>',context!);
        Stops = JsonConverters.fromJson(json['Stops'],'List<StopItem>',context!);
        Spd = JsonConverters.fromJson(json['Spd'],'List<RedlineItem>',context!);
        Address = JsonConverters.fromJson(json['Address'],'Address',context!);
        Distance = JsonConverters.toDouble(json['Distance']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Workspace': Workspace,
        'UserId': UserId,
        'TrackId': TrackId,
        'Items': JsonConverters.toJson(Items,'List<String>',context!),
        'Stops': JsonConverters.toJson(Stops,'List<StopItem>',context!),
        'Spd': JsonConverters.toJson(Spd,'List<RedlineItem>',context!),
        'Address': JsonConverters.toJson(Address,'Address',context!),
        'Distance': Distance
    };

    getTypeName() => "Track";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'dev.fieldsquared.com', types: <String, TypeInfo> {
    'StopItem': TypeInfo(TypeOf.Class, create:() => StopItem()),
    'RedlineItem': TypeInfo(TypeOf.Class, create:() => RedlineItem()),
    'Location': TypeInfo(TypeOf.Class, create:() => Location()),
    'Address': TypeInfo(TypeOf.Class, create:() => Address()),
    'Track': TypeInfo(TypeOf.Class, create:() => Track()),
    'List<StopItem>': TypeInfo(TypeOf.Class, create:() => <StopItem>[]),
    'List<RedlineItem>': TypeInfo(TypeOf.Class, create:() => <RedlineItem>[]),
});

Dart Track 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}/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
}