Cochrane+ App API

<back to all web services

AttendanceSessionStatusChangeRequest

Requires Authentication
The following routes are available for this service:
POST/attendance/sessionstatus
import Foundation
import ServiceStack

public class AttendanceSessionStatusChangeRequest : ApiServiceRequest
{
    public var attendanceSessionId:Int
    public var eventType:AttendanceEventType
    public var timeZoneName:String

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

    private enum CodingKeys : String, CodingKey {
        case attendanceSessionId
        case eventType
        case timeZoneName
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        attendanceSessionId = try container.decodeIfPresent(Int.self, forKey: .attendanceSessionId)
        eventType = try container.decodeIfPresent(AttendanceEventType.self, forKey: .eventType)
        timeZoneName = try container.decodeIfPresent(String.self, forKey: .timeZoneName)
    }

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

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 enum AttendanceEventType : Int, Codable
{
    case ClockOut = 0
    case ClockIn = 1
    case StartLunch = 2
    case EndLunch = 3
    case StartBreak = 4
    case EndBreak = 5
}

public class GetAttendanceSessionInfoResponse : ApiServiceResponse
{
    public var sessionInfo:AttendanceSessionInfo

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

    private enum CodingKeys : String, CodingKey {
        case sessionInfo
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        sessionInfo = try container.decodeIfPresent(AttendanceSessionInfo.self, forKey: .sessionInfo)
    }

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

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 AttendanceSessionInfo : Codable
{
    public var attendanceSessionId:Int
    public var attendanceGoalTime:Double
    public var attendanceGoalTimeValue:String
    public var attendanceEvents:[AttendanceEventData] = []
    public var startDate:String
    public var endDate:String
    public var isClockedIn:Bool
    public var timeElapsed:Double
    public var latestEventType:AttendanceEventType
    public var totalBreakTime:Double
    public var totalLunchTime:Double
    public var isNew:Bool

    required public init(){}
}

public class AttendanceEventData : Codable
{
    public var type:AttendanceEventType
    public var time:String
    public var location:String

    required public init(){}
}


Swift AttendanceSessionStatusChangeRequest 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 /attendance/sessionstatus HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"attendanceSessionId":0,"eventType":0,"timeZoneName":"String","apiKey":"String","latitude":0,"longitude":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"sessionInfo":{"attendanceSessionId":0,"attendanceGoalTime":0,"attendanceGoalTimeValue":"00:00:00","attendanceEvents":[{}],"startDate":"String","endDate":"String","isClockedIn":false,"timeElapsed":0,"latestEventType":0,"totalBreakTime":0,"totalLunchTime":0,"isNew":false},"description":"String","heading":"String","wasSuccessful":false,"modelState":{}}