GET | /api/v1/logs/recharge |
---|
import Foundation
import ServiceStack
public class LogRechargeRequest : PagingRequest
{
public var type:String
public var price:Int
public var fromDate:Date
public var toDate:Date
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case type
case price
case fromDate
case toDate
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
type = try container.decodeIfPresent(String.self, forKey: .type)
price = try container.decodeIfPresent(Int.self, forKey: .price)
fromDate = try container.decodeIfPresent(Date.self, forKey: .fromDate)
toDate = try container.decodeIfPresent(Date.self, forKey: .toDate)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if type != nil { try container.encode(type, forKey: .type) }
if price != nil { try container.encode(price, forKey: .price) }
if fromDate != nil { try container.encode(fromDate, forKey: .fromDate) }
if toDate != nil { try container.encode(toDate, forKey: .toDate) }
}
}
public class PagingRequest : Codable
{
public var page:Int
public var limit:Int
public var offSet:Int
required public init(){}
}
public class PageResponse<Object : Codable> : IResponseRequest, Codable
{
public var code:Int
public var message:String
public var data:[Object] = []
public var pagination:Pagination
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(){}
}
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 /api/v1/logs/recharge HTTP/1.1 Host: efun-id-api-sandbox.efun.vn Accept: text/csv
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"code":0,"message":"String","data":[{}],"pagination":null}