CodableSerializer
open class CodableSerializer
Serializer for objects, that conform to Decodable
protocol.
-
Decoder to be used while parsing model.
Declaration
Swift
public let modelDecoder: JSONDecoder
-
Creates
CodableSerializer
withtron
instance to send requests, anddecoder
to be used while parsing response.Declaration
Swift
public init(_ tron: TRON, modelDecoder: JSONDecoder = JSONDecoder())
-
Creates APIRequest with specified relative path and type RequestType.Default.
Declaration
Swift
open func request<Model, ErrorModel>(_ path: String) -> APIRequest<Model, ErrorModel> where Model : Decodable, ErrorModel : ErrorSerializable
Parameters
path
Path, that will be appended to current
baseURL
.Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadFromFile.
Declaration
Swift
open func upload<Model, ErrorModel>(_ path: String, fromFileAt fileURL: URL) -> UploadAPIRequest<Model, ErrorModel> where Model : Decodable, ErrorModel : ErrorSerializable
Parameters
path
Path, that will be appended to current
baseURL
.fileURL
File url to upload from.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadData.
Declaration
Swift
open func upload<Model, ErrorModel>(_ path: String, data: Data) -> UploadAPIRequest<Model, ErrorModel> where Model : Decodable, ErrorModel : ErrorSerializable
Parameters
path
Path, that will be appended to current
baseURL
.data
Data to upload.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadStream.
Declaration
Swift
open func upload<Model, ErrorModel>(_ path: String, from stream: InputStream) -> UploadAPIRequest<Model, ErrorModel> where Model : Decodable, ErrorModel : ErrorSerializable
Parameters
path
Path, that will be appended to current
baseURL
.stream
Stream to upload from.
Return Value
APIRequest instance.
-
Creates MultipartAPIRequest with specified relative path.
Declaration
Swift
open func uploadMultipart<Model: Decodable, ErrorModel: ErrorSerializable>(_ path: String, encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, fileManager: FileManager = .default, formData: @escaping (MultipartFormData) -> Void) -> UploadAPIRequest<Model, ErrorModel>
Parameters
path
Path, that will be appended to current
baseURL
.formData
Multipart form data creation block.
Return Value
MultipartAPIRequest instance.