Required role: | Moderator |
import Foundation
import ServiceStack
// @ValidateRequest(Validator="HasRole(`Moderator`)")
public class UpdateSignup : IPatchDb<Signup>, Codable
{
public var id:Int
public var type:SignupType?
// @Validate(Validator="Email")
public var email:String
public var name:String
public var cancelledDate:Date?
required public init(){}
}
public enum SignupType : String, Codable
{
case Updates
case Beta
}
public class Signup : StatBase
{
public var id:Int
public var type:SignupType
public var email:String
public var name:String
public var cancelledDate:Date?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case type
case email
case name
case cancelledDate
}
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)
type = try container.decodeIfPresent(SignupType.self, forKey: .type)
email = try container.decodeIfPresent(String.self, forKey: .email)
name = try container.decodeIfPresent(String.self, forKey: .name)
cancelledDate = try container.decodeIfPresent(Date.self, forKey: .cancelledDate)
}
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) }
if type != nil { try container.encode(type, forKey: .type) }
if email != nil { try container.encode(email, forKey: .email) }
if name != nil { try container.encode(name, forKey: .name) }
if cancelledDate != nil { try container.encode(cancelledDate, forKey: .cancelledDate) }
}
}
public class StatBase : Codable
{
public var refId:String
public var appUserId:Int?
public var rawUrl:String
public var remoteIp:String
public var createdDate:Date
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 /xml/reply/UpdateSignup HTTP/1.1
Host: blazordiffusion.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<UpdateSignup xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BlazorDiffusion.ServiceModel">
<CancelledDate>0001-01-01T00:00:00</CancelledDate>
<Email>String</Email>
<Id>0</Id>
<Name>String</Name>
<Type>Updates</Type>
</UpdateSignup>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <Signup xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BlazorDiffusion.ServiceModel"> <AppUserId>0</AppUserId> <CreatedDate>0001-01-01T00:00:00</CreatedDate> <RawUrl>String</RawUrl> <RefId>String</RefId> <RemoteIp>String</RemoteIp> <CancelledDate>0001-01-01T00:00:00</CancelledDate> <Email>String</Email> <Id>0</Id> <Name>String</Name> <Type>Updates</Type> </Signup>