1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //
- // DSBDataProxy.h
- // FirstLink
- //
- // Created by ascii on 2016/12/6.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- @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<NSURLSessionDataTask *> *)requestSerial:(NSArray<DSBBaseRequest *> *)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<NSURLSessionDataTask *> *)requestBatch:(NSArray<DSBBaseRequest*>*)requestArray
- success:(void (^)(NSArray<NSURLSessionDataTask *> *taskArray, NSArray<NSDictionary *> *responseArray, NSArray<DSBBaseRequest *> *requestArray))success
- failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure;
- @end
|