| GET | /provider/search |
|---|
import Foundation
import ServiceStack
public class SearchProviderRequest : PagingRequest
{
public var name:String
public var providerType:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case name
case providerType
}
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)
providerType = try container.decodeIfPresent(Int.self, forKey: .providerType)
}
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 providerType != nil { try container.encode(providerType, forKey: .providerType) }
}
}
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 SearchProviderRequest 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 /provider/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,"name":"String","taxCode":"String","address":"String","email":"String","additionalInfo":"String","providerType":0,"createdAt":"0001-01-01T00:00:00.0000000+07:06","createdBy":0}],"pagination":null}