tvpl.api

<back to all web services

GetPublishItem

Requires Authentication
The following routes are available for this service:
GET/DocumentPolicy/PublishByDeparment
import Foundation
import ServiceStack

public class GetPublishItem : PagingRequest, IGet
{
    public var name:String

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

    private enum CodingKeys : String, CodingKey {
        case name
    }

    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)
    }

    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) }
    }
}

public class PagingRequest : Codable
{
    public var page:Int
    public var limit:Int

    required public init(){}
}

public class ApprovedResponse : IResponseRequest, Codable
{
    public var updatedData:DocumentPolicy
    public var code:Int
    public var message:String

    required public init(){}
}

public class DocumentPolicy : UpdateDocumentPolicyModel
{
    public var approvedDate:Date?
    public var estimatedDeadline:Date?
    public var isApproved:Bool
    // @Required()
    public var createdBy:Int?

    public var createdDate:Date
    public var deletedAt:Date?
    public var deletedBy:Int?
    public var approvalComment:String
    public var isDeleted:Bool?
    public var lastUpdateAt:Date?
    public var updatedBy:Int

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

    private enum CodingKeys : String, CodingKey {
        case approvedDate
        case estimatedDeadline
        case isApproved
        case createdBy
        case createdDate
        case deletedAt
        case deletedBy
        case approvalComment
        case isDeleted
        case lastUpdateAt
        case updatedBy
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        approvedDate = try container.decodeIfPresent(Date.self, forKey: .approvedDate)
        estimatedDeadline = try container.decodeIfPresent(Date.self, forKey: .estimatedDeadline)
        isApproved = try container.decodeIfPresent(Bool.self, forKey: .isApproved)
        createdBy = try container.decodeIfPresent(Int.self, forKey: .createdBy)
        createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate)
        deletedAt = try container.decodeIfPresent(Date.self, forKey: .deletedAt)
        deletedBy = try container.decodeIfPresent(Int.self, forKey: .deletedBy)
        approvalComment = try container.decodeIfPresent(String.self, forKey: .approvalComment)
        isDeleted = try container.decodeIfPresent(Bool.self, forKey: .isDeleted)
        lastUpdateAt = try container.decodeIfPresent(Date.self, forKey: .lastUpdateAt)
        updatedBy = try container.decodeIfPresent(Int.self, forKey: .updatedBy)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if approvedDate != nil { try container.encode(approvedDate, forKey: .approvedDate) }
        if estimatedDeadline != nil { try container.encode(estimatedDeadline, forKey: .estimatedDeadline) }
        if isApproved != nil { try container.encode(isApproved, forKey: .isApproved) }
        if createdBy != nil { try container.encode(createdBy, forKey: .createdBy) }
        if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) }
        if deletedAt != nil { try container.encode(deletedAt, forKey: .deletedAt) }
        if deletedBy != nil { try container.encode(deletedBy, forKey: .deletedBy) }
        if approvalComment != nil { try container.encode(approvalComment, forKey: .approvalComment) }
        if isDeleted != nil { try container.encode(isDeleted, forKey: .isDeleted) }
        if lastUpdateAt != nil { try container.encode(lastUpdateAt, forKey: .lastUpdateAt) }
        if updatedBy != nil { try container.encode(updatedBy, forKey: .updatedBy) }
    }
}

public class UpdateDocumentPolicyModel : Codable
{
    public var id:Int
    public var policyCode:String
    public var title:String
    public var documentLink:String
    public var documentGroupId:Int
    public var Description:String
    public var approvedBy:Int?
    // @Required()
    public var departmentLeadId:Int?

    public var departmentCoId:Int?

    required public init(){}
}


Swift GetPublishItem DTOs

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

HTTP + XML

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

GET /DocumentPolicy/PublishByDeparment HTTP/1.1 
Host: etc-api.vsmlab.vn 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ApprovedResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/tvpl.api.ServiceModel">
  <Code>0</Code>
  <Message>String</Message>
  <UpdatedData xmlns:d2p1="http://schemas.datacontract.org/2004/07/tvpl.data.Models">
    <d2p1:ApprovedBy>0</d2p1:ApprovedBy>
    <d2p1:DepartmentCoId>0</d2p1:DepartmentCoId>
    <d2p1:DepartmentLeadId>0</d2p1:DepartmentLeadId>
    <d2p1:Description>String</d2p1:Description>
    <d2p1:DocumentGroupId>0</d2p1:DocumentGroupId>
    <d2p1:DocumentLink>String</d2p1:DocumentLink>
    <d2p1:Id>0</d2p1:Id>
    <d2p1:PolicyCode>String</d2p1:PolicyCode>
    <d2p1:Title>String</d2p1:Title>
    <d2p1:ApprovalComment>String</d2p1:ApprovalComment>
    <d2p1:ApprovedDate>0001-01-01T00:00:00</d2p1:ApprovedDate>
    <d2p1:CreatedBy>0</d2p1:CreatedBy>
    <d2p1:CreatedDate>0001-01-01T00:00:00</d2p1:CreatedDate>
    <d2p1:DeletedAt>0001-01-01T00:00:00</d2p1:DeletedAt>
    <d2p1:DeletedBy>0</d2p1:DeletedBy>
    <d2p1:EstimatedDeadline>0001-01-01T00:00:00</d2p1:EstimatedDeadline>
    <d2p1:IsApproved>false</d2p1:IsApproved>
    <d2p1:IsDeleted>false</d2p1:IsDeleted>
    <d2p1:LastUpdateAt>0001-01-01T00:00:00</d2p1:LastUpdateAt>
    <d2p1:UpdatedBy>0</d2p1:UpdatedBy>
  </UpdatedData>
</ApprovedResponse>