Cochrane+ App API

<back to all web services

BackgroundLocationReceived

The following routes are available for this service:
POST/location/background
import Foundation
import ServiceStack

public class BackgroundLocationReceived : IHasApiKey, Codable
{
    public var apiKey:String
    public var location:LocationData

    required public init(){}
}

public class LocationData : Codable
{
    public var coords:CoordsData
    public var extras:ExtrasData
    public var is_moving:Bool
    public var odometer:Double
    public var uuid:String
    public var activity:ActivityData
    public var battery:BatteryData
    public var timestamp:Date

    required public init(){}
}

public class CoordsData : Codable
{
    public var speed:Double
    public var longitude:Double
    public var latitude:Double
    public var accuracy:Double
    public var altitude:Double
    public var heading:Double

    required public init(){}
}

public class ExtrasData : Codable
{
    public var systemUserId:Int
    public var deviceId:String

    required public init(){}
}

public class ActivityData : Codable
{
    public var type:String
    public var confidence:Int

    required public init(){}
}

public class BatteryData : Codable
{
    public var level:Double
    public var is_charging:Bool

    required public init(){}
}

public class ApiServiceResponse : IServiceResponse, Codable
{
    public var Description:String
    public var heading:String
    public var wasSuccessful:Bool
    //modelState:Object ignored. Type could not be extended in Swift

    required public init(){}
}


Swift 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>