| Required role: | super-admin |
| POST | /document-template |
|---|
import Foundation
import ServiceStack
public class CreateOrUpdateTemplateRequest : Codable
{
public var id:Int?
public var documentIds:[Int] = []
public var title:String
public var Description:String
public var isActive:Bool
public var elements:[DocumentElementDto] = []
required public init(){}
}
public class DocumentElementDto : DocumentElement
{
public var children:[DocumentElementDto] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case children
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
children = try container.decodeIfPresent([DocumentElementDto].self, forKey: .children) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if children.count > 0 { try container.encode(children, forKey: .children) }
}
}
public class DocumentElement : Codable
{
public var id:Int
public var templateId:Int
// @Required()
public var elementKey:String?
// @Required()
public var tag:String?
public var parentId:Int?
// @Required()
public var title:String?
public var Description:String
// @Required()
public var dataType:String?
public var templateType:String
public var orderIndex:Int
public var isRequired:Bool?
required public init(){}
}
public class CreateDocumentTemplateResponse : IResponseRequest, Codable
{
public var insertedId:Int
public var code:Int
public var message:String
required public init(){}
}
Swift CreateOrUpdateTemplateRequest DTOs
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 /document-template HTTP/1.1
Host: etc-api.vsmlab.vn
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateOrUpdateTemplateRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel">
<Description>String</Description>
<DocumentIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</DocumentIds>
<Elements>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children>
<DocumentElementDto>
<CreatedAt xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0001-01-01T00:00:00</CreatedAt>
<DataType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</DataType>
<Description xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Description>
<ElementKey xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</ElementKey>
<Id xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</Id>
<IsRequired xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">false</IsRequired>
<OrderIndex xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</OrderIndex>
<ParentId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</ParentId>
<Tag xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Tag>
<TemplateId xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">0</TemplateId>
<TemplateType xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</TemplateType>
<Title xmlns="http://schemas.datacontract.org/2004/07/tvpl.data.Models">String</Title>
<Children i:nil="true" />
</DocumentElementDto>
</Children>
</DocumentElementDto>
</Children>
</DocumentElementDto>
</Elements>
<Id>0</Id>
<IsActive>false</IsActive>
<Title>String</Title>
</CreateOrUpdateTemplateRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <CreateDocumentTemplateResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel"> <Code>0</Code> <InsertedId>0</InsertedId> <Message>String</Message> </CreateDocumentTemplateResponse>