| 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 .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<BackgroundLocationReceived xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel">
<ApiKey>String</ApiKey>
<location>
<activity>
<confidence>0</confidence>
<type>String</type>
</activity>
<battery>
<is_charging>false</is_charging>
<level>0</level>
</battery>
<coords>
<accuracy>0</accuracy>
<altitude>0</altitude>
<heading>0</heading>
<latitude>0</latitude>
<longitude>0</longitude>
<speed>0</speed>
</coords>
<extras>
<deviceId>00000000-0000-0000-0000-000000000000</deviceId>
<systemUserId>0</systemUserId>
</extras>
<is_moving>false</is_moving>
<odometer>0</odometer>
<timestamp>0001-01-01T00:00:00</timestamp>
<uuid>String</uuid>
</location>
</BackgroundLocationReceived>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <ApiServiceResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base"> <Description>String</Description> <Heading>String</Heading> <ModelState /> <WasSuccessful>false</WasSuccessful> </ApiServiceResponse>