| 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(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<AutoLogin xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel">
<ApiKey xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">String</ApiKey>
<Latitude xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">0</Latitude>
<Longitude xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel.Base">0</Longitude>
<RefreshToken>String</RefreshToken>
<SystemUserId>0</SystemUserId>
<UtcOffset>0</UtcOffset>
</AutoLogin>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<UserLoginResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebService.ServiceModel">
<Description xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Description>
<Heading xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">String</Heading>
<ModelState xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base" />
<WasSuccessful xmlns="http://schemas.datacontract.org/2004/07/CommonService.Api.Models.Base">false</WasSuccessful>
<AllowAttendanceOnLaptop>false</AllowAttendanceOnLaptop>
<EndLatitude>0</EndLatitude>
<EndLongitude>0</EndLongitude>
<FeelingStatusMappings xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>String</d2p1:string>
</FeelingStatusMappings>
<FriendlyName>String</FriendlyName>
<HasAiPermissions>false</HasAiPermissions>
<IsManagerOrPromotedTo>false</IsManagerOrPromotedTo>
<IsSalesPerson>false</IsSalesPerson>
<IsTemplateApprover>false</IsTemplateApprover>
<OutstandingApprovals>0</OutstandingApprovals>
<Permissions xmlns:d2p1="http://schemas.datacontract.org/2004/07/BusinessLogic.Entities">
<d2p1:Attendance>false</d2p1:Attendance>
<d2p1:Debrief>false</d2p1:Debrief>
<d2p1:InternalRating>false</d2p1:InternalRating>
<d2p1:Journey>false</d2p1:Journey>
<d2p1:Meeting>false</d2p1:Meeting>
<d2p1:NotificationCenter>false</d2p1:NotificationCenter>
<d2p1:OnTheMove>false</d2p1:OnTheMove>
<d2p1:ThunderBoltActions>false</d2p1:ThunderBoltActions>
</Permissions>
<ProfileImageUrl>String</ProfileImageUrl>
<RefreshToken>String</RefreshToken>
<Settings>
<AllowAbstainRatings>false</AllowAbstainRatings>
<ShowMoodIndicatorOnApp>false</ShowMoodIndicatorOnApp>
<TakePhotoForAnalysis>false</TakePhotoForAnalysis>
</Settings>
<StartLatitude>0</StartLatitude>
<StartLongitude>0</StartLongitude>
<SystemUserId>0</SystemUserId>
<Username>String</Username>
</UserLoginResponse>