Requires any of the roles: | bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read |
GET | /trials | Get all valid trials | Get all valid trials that can be started |
---|
import Foundation
import ServiceStack
// @ValidateRequest(Validator="IsAuthenticated")
public class TrialsQuery : QueryDb2<TrialType, TrialQueryResponse>
{
/**
* Trial Id
*/
// @ApiMember(Description="Trial Id", IsRequired=true, ParameterType="query")
public var id:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(Int.self, forKey: .id)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
}
}
public class TrialType : BaseModel
{
// @Required()
public var name:String?
// @Required()
public var days:Int?
public var modifiedDate:Date?
public var id:Int
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case days
case modifiedDate
case id
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
name = try container.decodeIfPresent(String.self, forKey: .name)
days = try container.decodeIfPresent(Int.self, forKey: .days)
modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate)
id = try container.decodeIfPresent(Int.self, forKey: .id)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if name != nil { try container.encode(name, forKey: .name) }
if days != nil { try container.encode(days, forKey: .days) }
if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) }
if id != nil { try container.encode(id, forKey: .id) }
}
}
public class BaseModel : Codable
{
required public init(){}
}
public class TrialQueryResponse : Codable
{
public var id:Int
public var name:String
public var trialDays:Int
required public init(){}
}
public class AccessKeyTypeResponse : Codable
{
public var id:Int
public var keyType:String
public var Description:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /trials HTTP/1.1 Host: api.bokamera.se Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"Offset":0,"Total":0,"Results":[{"Id":0,"Name":"String","TrialDays":0}],"Meta":{"String":"String"},"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}