37 lines
899 B
Swift
37 lines
899 B
Swift
// Models.swift
|
|
//
|
|
// Generated by swagger-codegen
|
|
// https://github.com/swagger-api/swagger-codegen
|
|
//
|
|
|
|
import Foundation
|
|
|
|
protocol JSONEncodable {
|
|
func encodeToJSON() -> Any
|
|
}
|
|
|
|
public enum ErrorResponse : Error {
|
|
case error(Int, Data?, Error)
|
|
}
|
|
|
|
open class Response<T> {
|
|
public let statusCode: Int
|
|
public let header: [String: String]
|
|
public let body: T?
|
|
|
|
public init(statusCode: Int, header: [String: String], body: T?) {
|
|
self.statusCode = statusCode
|
|
self.header = header
|
|
self.body = body
|
|
}
|
|
|
|
public convenience init(response: HTTPURLResponse, body: T?) {
|
|
let rawHeader = response.allHeaderFields
|
|
var header = [String:String]()
|
|
for case let (key, value) as (String, String) in rawHeader {
|
|
header[key] = value
|
|
}
|
|
self.init(statusCode: response.statusCode, header: header, body: body)
|
|
}
|
|
}
|