| POST | /location/background |
|---|
import 'package:servicestack/servicestack.dart';
class ApiServiceResponse implements IServiceResponse, IConvertible
{
String? description;
String? heading;
bool? wasSuccessful;
dynamic? modelState;
ApiServiceResponse({this.description,this.heading,this.wasSuccessful,this.modelState});
ApiServiceResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
description = json['description'];
heading = json['heading'];
wasSuccessful = json['wasSuccessful'];
modelState = JsonConverters.fromJson(json['modelState'],'dynamic',context!);
return this;
}
Map<String, dynamic> toJson() => {
'description': description,
'heading': heading,
'wasSuccessful': wasSuccessful,
'modelState': JsonConverters.toJson(modelState,'dynamic',context!)
};
getTypeName() => "ApiServiceResponse";
TypeContext? context = _ctx;
}
class CoordsData implements IConvertible
{
double? speed;
double? longitude;
double? latitude;
double? accuracy;
double? altitude;
double? heading;
CoordsData({this.speed,this.longitude,this.latitude,this.accuracy,this.altitude,this.heading});
CoordsData.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
speed = JsonConverters.toDouble(json['speed']);
longitude = JsonConverters.toDouble(json['longitude']);
latitude = JsonConverters.toDouble(json['latitude']);
accuracy = JsonConverters.toDouble(json['accuracy']);
altitude = JsonConverters.toDouble(json['altitude']);
heading = JsonConverters.toDouble(json['heading']);
return this;
}
Map<String, dynamic> toJson() => {
'speed': speed,
'longitude': longitude,
'latitude': latitude,
'accuracy': accuracy,
'altitude': altitude,
'heading': heading
};
getTypeName() => "CoordsData";
TypeContext? context = _ctx;
}
class ExtrasData implements IConvertible
{
int? systemUserId;
String? deviceId;
ExtrasData({this.systemUserId,this.deviceId});
ExtrasData.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
systemUserId = json['systemUserId'];
deviceId = json['deviceId'];
return this;
}
Map<String, dynamic> toJson() => {
'systemUserId': systemUserId,
'deviceId': deviceId
};
getTypeName() => "ExtrasData";
TypeContext? context = _ctx;
}
class ActivityData implements IConvertible
{
String? type;
int? confidence;
ActivityData({this.type,this.confidence});
ActivityData.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
type = json['type'];
confidence = json['confidence'];
return this;
}
Map<String, dynamic> toJson() => {
'type': type,
'confidence': confidence
};
getTypeName() => "ActivityData";
TypeContext? context = _ctx;
}
class BatteryData implements IConvertible
{
double? level;
bool? is_charging;
BatteryData({this.level,this.is_charging});
BatteryData.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
level = JsonConverters.toDouble(json['level']);
is_charging = json['is_charging'];
return this;
}
Map<String, dynamic> toJson() => {
'level': level,
'is_charging': is_charging
};
getTypeName() => "BatteryData";
TypeContext? context = _ctx;
}
class LocationData implements IConvertible
{
CoordsData? coords;
ExtrasData? extras;
bool? is_moving;
double? odometer;
String? uuid;
ActivityData? activity;
BatteryData? battery;
DateTime? timestamp;
LocationData({this.coords,this.extras,this.is_moving,this.odometer,this.uuid,this.activity,this.battery,this.timestamp});
LocationData.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
coords = JsonConverters.fromJson(json['coords'],'CoordsData',context!);
extras = JsonConverters.fromJson(json['extras'],'ExtrasData',context!);
is_moving = json['is_moving'];
odometer = JsonConverters.toDouble(json['odometer']);
uuid = json['uuid'];
activity = JsonConverters.fromJson(json['activity'],'ActivityData',context!);
battery = JsonConverters.fromJson(json['battery'],'BatteryData',context!);
timestamp = JsonConverters.fromJson(json['timestamp'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'coords': JsonConverters.toJson(coords,'CoordsData',context!),
'extras': JsonConverters.toJson(extras,'ExtrasData',context!),
'is_moving': is_moving,
'odometer': odometer,
'uuid': uuid,
'activity': JsonConverters.toJson(activity,'ActivityData',context!),
'battery': JsonConverters.toJson(battery,'BatteryData',context!),
'timestamp': JsonConverters.toJson(timestamp,'DateTime',context!)
};
getTypeName() => "LocationData";
TypeContext? context = _ctx;
}
class BackgroundLocationReceived implements IHasApiKey, IConvertible
{
String? apiKey;
LocationData? location;
BackgroundLocationReceived({this.apiKey,this.location});
BackgroundLocationReceived.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
apiKey = json['apiKey'];
location = JsonConverters.fromJson(json['location'],'LocationData',context!);
return this;
}
Map<String, dynamic> toJson() => {
'apiKey': apiKey,
'location': JsonConverters.toJson(location,'LocationData',context!)
};
getTypeName() => "BackgroundLocationReceived";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'cochraneplus_api_dev.happen.zone', types: <String, TypeInfo> {
'ApiServiceResponse': TypeInfo(TypeOf.Class, create:() => ApiServiceResponse()),
'CoordsData': TypeInfo(TypeOf.Class, create:() => CoordsData()),
'ExtrasData': TypeInfo(TypeOf.Class, create:() => ExtrasData()),
'ActivityData': TypeInfo(TypeOf.Class, create:() => ActivityData()),
'BatteryData': TypeInfo(TypeOf.Class, create:() => BatteryData()),
'LocationData': TypeInfo(TypeOf.Class, create:() => LocationData()),
'BackgroundLocationReceived': TypeInfo(TypeOf.Class, create:() => BackgroundLocationReceived()),
});
Dart BackgroundLocationReceived DTOs
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 /location/background HTTP/1.1
Host: cochraneplus-api-dev.happen.zone
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
apiKey: String,
location:
{
coords:
{
speed: 0,
longitude: 0,
latitude: 0,
accuracy: 0,
altitude: 0,
heading: 0
},
extras:
{
systemUserId: 0,
deviceId: 00000000-0000-0000-0000-000000000000
},
is_moving: False,
odometer: 0,
uuid: String,
activity:
{
type: String,
confidence: 0
},
battery:
{
level: 0,
is_charging: False
},
timestamp: 0001-01-01
}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
description: String,
heading: String,
wasSuccessful: False,
modelState: {}
}