| POST | /user/login |
|---|
import Foundation
import ServiceStack
public class UserLogin : ApiServiceRequest
{
public var username:String
public var password:String
public var utcOffset:Int
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case username
case password
case utcOffset
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
username = try container.decodeIfPresent(String.self, forKey: .username)
password = try container.decodeIfPresent(String.self, forKey: .password)
utcOffset = try container.decodeIfPresent(Int.self, forKey: .utcOffset)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if username != nil { try container.encode(username, forKey: .username) }
if password != nil { try container.encode(password, forKey: .password) }
if utcOffset != nil { try container.encode(utcOffset, forKey: .utcOffset) }
}
}
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(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /user/login HTTP/1.1
Host: cochraneplus-api-dev.happen.zone
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"username":"String","password":"String","utcOffset":0,"apiKey":"String","latitude":0,"longitude":0}
HTTP/1.1 200 OK
Content-Type: text/jsonl
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":{}}