JSONDecodableSerializer

open class JSONDecodableSerializer

Serializer for objects, that conform to JSONDecodable protocol.

  • Reading options to use while calling JSONSerialization.jsonObject(withData:options:)

    Declaration

    Swift

    open var options: JSONSerialization.ReadingOptions
  • Defines how JSON should be preprocessed before passing to Model initializer.

    Declaration

    Swift

    open var traverseJSON: (JSON) -> JSON
  • Creates JSONDecodableSerializer with tron instance to send requests, and JSON reading options to be passed to JSONSerialization.

    Declaration

    Swift

    public init(tron: TRON, options: JSONSerialization.ReadingOptions = [], traversingJSON: @escaping (JSON) -> JSON = { $0 })
  • Creates APIRequest with specified relative path and type RequestType.Default.

    Declaration

    Swift

    open func request<Model, ErrorModel>(_ path: String) -> APIRequest<Model, ErrorModel> where Model : JSONDecodable, 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 : JSONDecodable, 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 : JSONDecodable, 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 : JSONDecodable, 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: JSONDecodable, 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.