Cochrane+ App API

<back to all web services

AutoLogin

The following routes are available for this service:
POST/user/autologin
import Foundation
import ServiceStack

public class AutoLogin : ApiServiceRequest
{
    public var utcOffset:Int
    public var systemUserId:Int
    public var refreshToken:String

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case utcOffset
        case systemUserId
        case refreshToken
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        utcOffset = try container.decodeIfPresent(Int.self, forKey: .utcOffset)
        systemUserId = try container.decodeIfPresent(Int.self, forKey: .systemUserId)
        refreshToken = try container.decodeIfPresent(String.self, forKey: .refreshToken)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if utcOffset != nil { try container.encode(utcOffset, forKey: .utcOffset) }
        if systemUserId != nil { try container.encode(systemUserId, forKey: .systemUserId) }
        if refreshToken != nil { try container.encode(refreshToken, forKey: .refreshToken) }
    }
}

public class ApiServiceRequest : IServiceRequest, IHasApiKey, IHasDeviceInfo, Codable
{
    /**
    * The API Key required for authentication
    */
    // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
    public var apiKey:String

    /**
    * Latitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Latitude of the user making this request")
    public var latitude:Double

    /**
    * Longitude of the user making this request
    */
    // @ApiMember(DataType="double", Description="Longitude of the user making this request")
    public var longitude:Double

    required public init(){}
}

public class UserLoginResponse : ApiServiceResponse
{
    public var allowAttendanceOnLaptop:Bool
    public var profileImageUrl:String
    public var friendlyName:String
    public var systemUserId:Int
    public var username:String
    public var permissions:SystemUserPermission
    public var settings:AppSettings
    public var startLatitude:Double
    public var startLongitude:Double
    public var hasStartLocation:Bool
    public var endLatitude:Double
    public var endLongitude:Double
    public var hasEndLocation:Bool
    public var isSalesPerson:Bool
    public var feelingStatusMappings:[String] = []
    public var hasAiPermissions:Bool
    public var refreshToken:String
    public var isManagerOrPromotedTo:Bool
    public var isTemplateApprover:Bool
    public var outstandingApprovals:Int

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case allowAttendanceOnLaptop
        case profileImageUrl
        case friendlyName
        case systemUserId
        case username
        case permissions
        case settings
        case startLatitude
        case startLongitude
        case hasStartLocation
        case endLatitude
        case endLongitude
        case hasEndLocation
        case isSalesPerson
        case feelingStatusMappings
        case hasAiPermissions
        case refreshToken
        case isManagerOrPromotedTo
        case isTemplateApprover
        case outstandingApprovals
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        allowAttendanceOnLaptop = try container.decodeIfPresent(Bool.self, forKey: .allowAttendanceOnLaptop)
        profileImageUrl = try container.decodeIfPresent(String.self, forKey: .profileImageUrl)
        friendlyName = try container.decodeIfPresent(String.self, forKey: .friendlyName)
        systemUserId = try container.decodeIfPresent(Int.self, forKey: .systemUserId)
        username = try container.decodeIfPresent(String.self, forKey: .username)
        permissions = try container.decodeIfPresent(SystemUserPermission.self, forKey: .permissions)
        settings = try container.decodeIfPresent(AppSettings.self, forKey: .settings)
        startLatitude = try container.decodeIfPresent(Double.self, forKey: .startLatitude)
        startLongitude = try container.decodeIfPresent(Double.self, forKey: .startLongitude)
        hasStartLocation = try container.decodeIfPresent(Bool.self, forKey: .hasStartLocation)
        endLatitude = try container.decodeIfPresent(Double.self, forKey: .endLatitude)
        endLongitude = try container.decodeIfPresent(Double.self, forKey: .endLongitude)
        hasEndLocation = try container.decodeIfPresent(Bool.self, forKey: .hasEndLocation)
        isSalesPerson = try container.decodeIfPresent(Bool.self, forKey: .isSalesPerson)
        feelingStatusMappings = try container.decodeIfPresent([String].self, forKey: .feelingStatusMappings) ?? []
        hasAiPermissions = try container.decodeIfPresent(Bool.self, forKey: .hasAiPermissions)
        refreshToken = try container.decodeIfPresent(String.self, forKey: .refreshToken)
        isManagerOrPromotedTo = try container.decodeIfPresent(Bool.self, forKey: .isManagerOrPromotedTo)
        isTemplateApprover = try container.decodeIfPresent(Bool.self, forKey: .isTemplateApprover)
        outstandingApprovals = try container.decodeIfPresent(Int.self, forKey: .outstandingApprovals)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if allowAttendanceOnLaptop != nil { try container.encode(allowAttendanceOnLaptop, forKey: .allowAttendanceOnLaptop) }
        if profileImageUrl != nil { try container.encode(profileImageUrl, forKey: .profileImageUrl) }
        if friendlyName != nil { try container.encode(friendlyName, forKey: .friendlyName) }
        if systemUserId != nil { try container.encode(systemUserId, forKey: .systemUserId) }
        if username != nil { try container.encode(username, forKey: .username) }
        if permissions != nil { try container.encode(permissions, forKey: .permissions) }
        if settings != nil { try container.encode(settings, forKey: .settings) }
        if startLatitude != nil { try container.encode(startLatitude, forKey: .startLatitude) }
        if startLongitude != nil { try container.encode(startLongitude, forKey: .startLongitude) }
        if hasStartLocation != nil { try container.encode(hasStartLocation, forKey: .hasStartLocation) }
        if endLatitude != nil { try container.encode(endLatitude, forKey: .endLatitude) }
        if endLongitude != nil { try container.encode(endLongitude, forKey: .endLongitude) }
        if hasEndLocation != nil { try container.encode(hasEndLocation, forKey: .hasEndLocation) }
        if isSalesPerson != nil { try container.encode(isSalesPerson, forKey: .isSalesPerson) }
        if feelingStatusMappings.count > 0 { try container.encode(feelingStatusMappings, forKey: .feelingStatusMappings) }
        if hasAiPermissions != nil { try container.encode(hasAiPermissions, forKey: .hasAiPermissions) }
        if refreshToken != nil { try container.encode(refreshToken, forKey: .refreshToken) }
        if isManagerOrPromotedTo != nil { try container.encode(isManagerOrPromotedTo, forKey: .isManagerOrPromotedTo) }
        if isTemplateApprover != nil { try container.encode(isTemplateApprover, forKey: .isTemplateApprover) }
        if outstandingApprovals != nil { try container.encode(outstandingApprovals, forKey: .outstandingApprovals) }
    }
}

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(){}
}

public class SystemUserPermission : Codable
{
    public var meeting:Bool
    public var journey:Bool
    public var attendance:Bool
    public var notificationCenter:Bool
    public var internalRating:Bool
    public var debrief:Bool
    public var thunderBoltActions:Bool
    public var onTheMove:Bool

    required public init(){}
}

public class AppSettings : Codable
{
    public var allowAbstainRatings:Bool
    public var showMoodIndicatorOnApp:Bool
    public var takePhotoForAnalysis:Bool

    required public init(){}
}


Swift AutoLogin DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv

HTTP + CSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /user/autologin HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"utcOffset":0,"systemUserId":0,"refreshToken":"String","apiKey":"String","latitude":0,"longitude":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"allowAttendanceOnLaptop":false,"profileImageUrl":"String","friendlyName":"String","systemUserId":0,"username":"String","permissions":{"meeting":false,"journey":false,"attendance":false,"notificationCenter":false,"internalRating":false,"debrief":false,"thunderBoltActions":false,"onTheMove":false},"settings":{"allowAbstainRatings":false,"showMoodIndicatorOnApp":false,"takePhotoForAnalysis":false},"startLatitude":0,"startLongitude":0,"hasStartLocation":false,"endLatitude":0,"endLongitude":0,"hasEndLocation":false,"isSalesPerson":false,"feelingStatusMappings":["String"],"hasAiPermissions":false,"refreshToken":"String","isManagerOrPromotedTo":false,"isTemplateApprover":false,"outstandingApprovals":0,"description":"String","heading":"String","wasSuccessful":false,"modelState":{}}