// // DSBDataProxy.h // FirstLink // // Created by ascii on 2016/12/6. // Copyright © 2016年 FirstLink. All rights reserved. // #import @class DSBBaseRequest; @class DSBResponseHeader; typedef NS_ENUM(NSUInteger, DSBCacheSource) { DSBCacheSourceNone, DSBCacheSourceDatabase, DSBCacheSourceURLCache, }; @interface DSBRequestProxy : NSObject /** 单个请求方法 @param request 请求 @param success 应答成功回掉 @param failure 应答失败回掉 @return */ + (NSURLSessionDataTask *)request:(DSBBaseRequest *)request success:(void (^)(NSURLSessionDataTask *task, NSDictionary *responseJson, DSBBaseRequest *request))success failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure; /** 顺序请求方法,依次返回应答,顺序与传入的请求顺序相同 @param requests 批量请求 @param success 一旦有请求返回,就会按顺序回掉 @param failure 只要有一个请求失败,就会取消所有请求,然后会回掉该block @return */ + (NSArray *)requestSerial:(NSArray *)requests success:(void (^)(NSURLSessionDataTask *task, NSDictionary *responseJson, DSBBaseRequest *request))success failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure; /** 批量获取请求方法,请求应答的数组与传入请求顺序相同 @param requestArray 批量请求方法 @param success 所有请求成功返回后回掉,顺序与传入的请求顺序相同 @param failure 只要有一个请求失败,就会取消所有请求,然后会回掉该block @return 返回task */ + (NSArray *)requestBatch:(NSArray*)requestArray success:(void (^)(NSArray *taskArray, NSArray *responseArray, NSArray *requestArray))success failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure; @end