UZAPIConnector
open class UZAPIConnector
Class quản lý việc gọi các hàm API
-
Số giây hết hạn gọi lệnh
Declaration
Swift
public var timeoutInterval : TimeInterval = 30.0 -
Thiết lập kiểu cache
Declaration
Swift
public var cachePolicy : NSURLRequest.CachePolicy = .useProtocolCachePolicy -
Các tham số cho header
Declaration
Swift
public var requestHeaderFields : [String:String]! = [:] -
Block được gọi khi hoàn thành
Declaration
Swift
public var completionBlock : APIConnectorCompletionBlock? = nil -
Block được gọi khi có lỗi
Declaration
Swift
public var failureBlock : APIConnectorFailureBlock? = nil -
Block được gọi trong quá trình tải
Declaration
Swift
public var progressBlock : APIConnectorProgressBlock? = nil -
DataRequest của quá trình hiện tại
Declaration
Swift
public var dataRequest : DataRequest? = nil
-
Khởi tạo class
Declaration
Swift
public init() -
Hủy ngay việc gọi đến API, server có thể đã nhận được request nhưng sẽ không trả về thông tin nào cả
Declaration
Swift
public func cancel() -
Tự thực hiện việc gọi hàm API
Declaration
Swift
public func callAPI(_ node: String!, baseURLString: String? = nil, method: HTTPMethod! = .get, params paramValue:[String: Any]? = nil, completion completionBlock:APIConnectorResultBlock? = nil)Parameters
nodenode hàm API
methodcó thể là .get, .post, .put hoặc .delete
paramValuecác thông số truyền vào, theo format [String:Any]
completionBlockblock được gọi khi hoàn thành, trả về data hoặc error nếu có lỗi
UZAPIConnector Class Reference