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

HTTP + OTHER

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/jsonl
Content-Type: text/jsonl
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-01T00:00:00.0000000"}}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"description":"String","heading":"String","wasSuccessful":false,"modelState":{}}