tvpl.api

<back to all web services

UpdateCategoryRequest

Requires Authentication
Required role:super-admin
The following routes are available for this service:
POST/category/update
import Foundation
import ServiceStack

public class UpdateCategoryRequest : CreateCategoryModel
{
    public var id:Int
    public var isDeleted:Bool?

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case id
        case isDeleted
    }

    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)
        isDeleted = try container.decodeIfPresent(Bool.self, forKey: .isDeleted)
    }

    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 isDeleted != nil { try container.encode(isDeleted, forKey: .isDeleted) }
    }
}

public class CreateCategoryModel : Codable
{
    public var name:String
    public var Description:String
    public var type:CategoryTypes
    public var isParty:Bool
    // @Ignore()
    public var childList:[Int] = []

    required public init(){}
}

public enum CategoryTypes : String, Codable
{
    case Department
    case PartyGroup
    case DocGroup
    case DocType
    case IssuingAgency
    case Status
    case Subjects
    case Workflow
}

public class CreateCategoryResponse : IResponseRequest, Codable
{
    public var id:Int
    public var code:Int
    public var message:String

    required public init(){}
}


Swift UpdateCategoryRequest DTOs

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

HTTP + CSV

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

POST /category/update HTTP/1.1 
Host: etc-api.vsmlab.vn 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"id":0,"isDeleted":false,"name":"String","description":"String","type":"Department","isParty":false,"childList":[0]}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"id":0,"code":0,"message":"String"}