35 lines
783 B
Swift
35 lines
783 B
Swift
//
|
|
// Task.swift
|
|
// Cyberlock
|
|
//
|
|
// Created by Jura on 8/21/19.
|
|
// Copyright © 2019 Omicronmedia. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public typealias HTTPParameters = [String: Any]
|
|
|
|
public protocol ParameterEncoder {
|
|
static func encode(parameters: HTTPParameters, for request: inout URLRequest) throws
|
|
}
|
|
|
|
public typealias TaskRequestPreparation = (_ request: inout URLRequest) throws -> Void
|
|
|
|
public enum Task {
|
|
|
|
case request
|
|
|
|
case requestParameters(parameters: HTTPParameters, parameterEncoding: ParameterEncoding)
|
|
|
|
case requestCompositeParameters(bodyParameters: HTTPParameters, urlParameters: HTTPParameters)
|
|
|
|
case custom(preparation: TaskRequestPreparation)
|
|
|
|
}
|
|
|
|
public enum ParameterEncoding {
|
|
case query
|
|
case json
|
|
}
|