Blazor Diffusion

<back to all web services

UpdateSignup

Analytics
Requires Authentication
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(){}
}


Swift UpdateSignup DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/reply/UpdateSignup HTTP/1.1 
Host: blazordiffusion.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	id: 0,
	type: Updates,
	email: String,
	name: String,
	cancelledDate: 0001-01-01
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	id: 0,
	type: Updates,
	email: String,
	name: String,
	cancelledDate: 0001-01-01,
	refId: String,
	appUserId: 0,
	rawUrl: String,
	remoteIp: String,
	createdDate: 0001-01-01
}