Cochrane+ App API

<back to all web services

BackgroundLocationReceived

The following routes are available for this service:
POST/location/background
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 ApiServiceResponse(IServiceResponse):
    description: Optional[str] = None
    heading: Optional[str] = None
    was_successful: bool = False
    model_state: Optional[Object] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CoordsData:
    speed: float = 0.0
    longitude: float = 0.0
    latitude: float = 0.0
    accuracy: float = 0.0
    altitude: float = 0.0
    heading: float = 0.0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ExtrasData:
    system_user_id: int = 0
    device_id: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ActivityData:
    type: Optional[str] = None
    confidence: int = 0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BatteryData:
    level: float = 0.0
    is_charging: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class LocationData:
    coords: Optional[CoordsData] = None
    extras: Optional[ExtrasData] = None
    is_moving: bool = False
    odometer: float = 0.0
    uuid: Optional[str] = None
    activity: Optional[ActivityData] = None
    battery: Optional[BatteryData] = None
    timestamp: datetime.datetime = datetime.datetime(1, 1, 1)


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BackgroundLocationReceived(IHasApiKey):
    api_key: Optional[str] = None
    location: Optional[LocationData] = None

Python BackgroundLocationReceived 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 /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: {}
}