Nenhuma Descrição

DSBRequestProxy.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // DSBDataProxy.h
  3. // FirstLink
  4. //
  5. // Created by ascii on 2016/12/6.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class DSBBaseRequest;
  10. @class DSBResponseHeader;
  11. typedef NS_ENUM(NSUInteger, DSBCacheSource) {
  12. DSBCacheSourceNone,
  13. DSBCacheSourceDatabase,
  14. DSBCacheSourceURLCache,
  15. };
  16. @interface DSBRequestProxy : NSObject
  17. /**
  18. 单个请求方法
  19. @param request 请求
  20. @param success 应答成功回掉
  21. @param failure 应答失败回掉
  22. @return
  23. */
  24. + (NSURLSessionDataTask *)request:(DSBBaseRequest *)request
  25. success:(void (^)(NSURLSessionDataTask *task, NSDictionary *responseJson, DSBBaseRequest *request))success
  26. failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure;
  27. /**
  28. 顺序请求方法,依次返回应答,顺序与传入的请求顺序相同
  29. @param requests 批量请求
  30. @param success 一旦有请求返回,就会按顺序回掉
  31. @param failure 只要有一个请求失败,就会取消所有请求,然后会回掉该block
  32. @return
  33. */
  34. + (NSArray<NSURLSessionDataTask *> *)requestSerial:(NSArray<DSBBaseRequest *> *)requests
  35. success:(void (^)(NSURLSessionDataTask *task, NSDictionary *responseJson, DSBBaseRequest *request))success
  36. failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure;
  37. /**
  38. 批量获取请求方法,请求应答的数组与传入请求顺序相同
  39. @param requestArray 批量请求方法
  40. @param success 所有请求成功返回后回掉,顺序与传入的请求顺序相同
  41. @param failure 只要有一个请求失败,就会取消所有请求,然后会回掉该block
  42. @return 返回task
  43. */
  44. + (NSArray<NSURLSessionDataTask *> *)requestBatch:(NSArray<DSBBaseRequest*>*)requestArray
  45. success:(void (^)(NSArray<NSURLSessionDataTask *> *taskArray, NSArray<NSDictionary *> *responseArray, NSArray<DSBBaseRequest *> *requestArray))success
  46. failure:(void (^)(NSURLSessionDataTask *task, DSBResponseHeader *header, DSBBaseRequest *request))failure;
  47. @end