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 .xml suffix or ?format=xml

HTTP + 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>