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
CodableSerializerwithtroninstance to send requests, anddecoderto 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 : ErrorSerializableParameters
pathPath, 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 : ErrorSerializableParameters
pathPath, that will be appended to current
baseURL.fileURLFile 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 : ErrorSerializableParameters
pathPath, that will be appended to current
baseURL.dataData 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 : ErrorSerializableParameters
pathPath, that will be appended to current
baseURL.streamStream 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
pathPath, that will be appended to current
baseURL.formDataMultipart form data creation block.
Return Value
MultipartAPIRequest instance.
View on GitHub
Install in Dash
CodableSerializer Class Reference