TRON
open class TRON : TronDelegate
TRON is a root object, that serves as a provider for single API endpoint. It is used to create and configure instances of APIRequest and MultipartAPIRequest.
You need to hold strong reference to TRON instance while your network requests are running.
-
URL builder to be used by default in all requests. Can be overridden for specific requests.
Declaration
Swift
open var urlBuilder: URLBuilder -
Global property, that defines whether stubbing is enabled. It is simply set on each
APIRequestinstance and can be reset.Declaration
Swift
open var stubbingEnabled: Bool -
Global plugins, that will receive events from all requests, created from current TRON instance.
Declaration
Swift
open var plugins: [Plugin] -
Default parameter encoding, that will be set on all APIRequests. Can be overrided by setting new value on APIRequest.parameterEncoding property. Default value - URLEncoding.default
Declaration
Swift
open var parameterEncoding: Alamofire.ParameterEncoding -
Queue, used to deliver result completion blocks. Defaults to dispatch_get_main_queue().
Declaration
Swift
open var resultDeliveryQueue: DispatchQueue -
CodableSerializerfor currentTRONinstance.Declaration
Swift
open lazy var codable: CodableSerializer { get set } -
Alamofire.Session instance used to send network requests
Declaration
Swift
public let session: Alamofire.Session -
Initializes
TRONwith given base URL, Alamofire.Session instance, and array of global plugins.Declaration
Swift
public init(baseURL: String, buildingURL: URLBuilder.Behavior = .appendingPathComponent, session: Alamofire.Session = .default, plugins: [Plugin] = [])Parameters
baseURLBase URL to be used
buildingURLBehavior to use while building URLs. Defaults to .appendingPathComponent.
sessionAlamofire.Session instance that will send requests created by current
TRONpluginsArray of plugins, that will receive events from requests, created and managed by current
TRONinstance. -
Creates APIRequest with specified relative path and type RequestType.Default.
Declaration
Swift
open func request<Model, ErrorModel: ErrorSerializable, Serializer: DataResponseSerializerProtocol> (_ path: String, responseSerializer: Serializer) -> APIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadFromFile.
Declaration
Swift
open func upload<Model, ErrorModel: ErrorSerializable, Serializer: DataResponseSerializerProtocol> (_ path: String, fromFileAt fileURL: URL, responseSerializer: Serializer) -> UploadAPIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.fileURLFile url to upload from.
responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadData.
Declaration
Swift
open func upload<Model, ErrorModel: ErrorSerializable, Serializer: DataResponseSerializerProtocol> (_ path: String, data: Data, responseSerializer: Serializer) -> UploadAPIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.dataData to upload.
responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.UploadStream.
Declaration
Swift
open func upload<Model, ErrorModel: ErrorSerializable, Serializer: DataResponseSerializerProtocol> (_ path: String, from stream: InputStream, responseSerializer: Serializer) -> UploadAPIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.streamStream to upload from.
responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates MultipartAPIRequest with specified relative path.
Declaration
Swift
open func uploadMultipart<Model, ErrorModel, Serializer> (_ path: String, responseSerializer: Serializer, encodingMemoryThreshold: UInt64 = MultipartFormData.encodingMemoryThreshold, fileManager: FileManager = .default, formData: @escaping (MultipartFormData) -> Void) -> UploadAPIRequest<Model, ErrorModel> where ErrorModel: ErrorSerializable, Serializer: DataResponseSerializerProtocol, Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.responseSerializerobject used to serialize response.
formDataMultipart form data creation block.
Return Value
MultipartAPIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.Download.
Seealso
Alamofire.Request.suggestedDownloadDestination(directory:domain:)method.Declaration
Swift
open func download<Model, ErrorModel: DownloadErrorSerializable, Serializer: DownloadResponseSerializerProtocol> (_ path: String, to destination: @escaping DownloadRequest.Destination, responseSerializer: Serializer) -> DownloadAPIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.destinationDestination for downloading.
responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates APIRequest with specified relative path and type RequestType.DownloadResuming.
Seealso
Alamofire.Request.suggestedDownloadDestination(directory:domain:)method.Declaration
Swift
open func download<Model, ErrorModel: DownloadErrorSerializable, Serializer: DownloadResponseSerializerProtocol> (_ path: String, to destination: @escaping DownloadRequest.Destination, resumingFrom: Data, responseSerializer: Serializer) -> DownloadAPIRequest<Model, ErrorModel> where Serializer.SerializedObject == ModelParameters
pathPath, that will be appended to current
baseURL.destinationDestination to download to.
resumingFromResume data for current request.
responseSerializerobject used to serialize response.
Return Value
APIRequest instance.
-
Creates
CodableSerializerwith currentTRONinstance and specificmodelDecoder.Declaration
Swift
open func codable(modelDecoder: JSONDecoder) -> CodableSerializer
View on GitHub
Install in Dash
TRON Class Reference