| GET | /purchase-history/search |
|---|
import Foundation
import ServiceStack
public class SearchPurchaseHistoryRequest : PagingRequest
{
public var name:String
public var workflowId:Int?
public var equipmentId:Int?
public var onlyMissingEquipment:Bool?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case workflowId
case equipmentId
case onlyMissingEquipment
}
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)
workflowId = try container.decodeIfPresent(Int.self, forKey: .workflowId)
equipmentId = try container.decodeIfPresent(Int.self, forKey: .equipmentId)
onlyMissingEquipment = try container.decodeIfPresent(Bool.self, forKey: .onlyMissingEquipment)
}
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) }
if workflowId != nil { try container.encode(workflowId, forKey: .workflowId) }
if equipmentId != nil { try container.encode(equipmentId, forKey: .equipmentId) }
if onlyMissingEquipment != nil { try container.encode(onlyMissingEquipment, forKey: .onlyMissingEquipment) }
}
}
public class PagingRequest : Codable
{
public var page:Int
public var limit:Int
required public init(){}
}
public class PageResponse<AuditLog : Codable> : IResponseRequest, Codable
{
public var code:Int
public var message:String
public var data:[AuditLog] = []
public var pagination:Pagination
required public init(){}
}
public class AuditLog : MongoObject, IEntityId, ICreated, IUpdate
{
public var userName:String
public var userId:Int?
public var documentId:Int
public var action:String
public var Description:String
public var createdDate:Date
public var updatedDate:Date
public var ipAddress:String
public var userAgent:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case userName
case userId
case documentId
case action
case Description
case createdDate
case updatedDate
case ipAddress
case userAgent
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
userName = try container.decodeIfPresent(String.self, forKey: .userName)
userId = try container.decodeIfPresent(Int.self, forKey: .userId)
documentId = try container.decodeIfPresent(Int.self, forKey: .documentId)
action = try container.decodeIfPresent(String.self, forKey: .action)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate)
updatedDate = try container.decodeIfPresent(Date.self, forKey: .updatedDate)
ipAddress = try container.decodeIfPresent(String.self, forKey: .ipAddress)
userAgent = try container.decodeIfPresent(String.self, forKey: .userAgent)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if userName != nil { try container.encode(userName, forKey: .userName) }
if userId != nil { try container.encode(userId, forKey: .userId) }
if documentId != nil { try container.encode(documentId, forKey: .documentId) }
if action != nil { try container.encode(action, forKey: .action) }
if Description != nil { try container.encode(Description, forKey: .Description) }
if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) }
if updatedDate != nil { try container.encode(updatedDate, forKey: .updatedDate) }
if ipAddress != nil { try container.encode(ipAddress, forKey: .ipAddress) }
if userAgent != nil { try container.encode(userAgent, forKey: .userAgent) }
}
}
public class MongoObject : IMongoModel, Codable
{
public var id:String
required public init(){}
}
public class Pagination : Codable
{
public var total:Int
public var pages:Int
public var offset:Int
public var limit:Int
public var currentPage:Int
required public init(){}
}
Swift SearchPurchaseHistoryRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /purchase-history/search HTTP/1.1 Host: etc-api.vsmlab.vn Accept: text/csv
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"code":0,"message":"String","data":[{"id":0,"workflowId":0,"sequenceNo":0,"detail":"String","unit":"String","quantity":0,"unitPrice":0,"amount":0,"vatRate":0,"totalAmount":0,"note":"String","name":"String","equipmentId":0,"purpose":"String","createdAt":"0001-01-01T00:00:00.0000000+07:06","createdBy":0,"workflowCode":"String","workflowTitle":"String","equipmentName":"String"}],"pagination":null}