Brak opisu

MtopExtRequest.h 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. //
  2. // MtopExtRequest.h
  3. // mtopext
  4. //
  5. // Created by 亿刀/禚来强 on 16/6/13.
  6. // Copyright © 2016年 亿刀/禚来强. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @class MtopExtRequest;
  11. @class MtopExtResponse;
  12. typedef void (^MtopExtRequestStarted)(MtopExtRequest* request);
  13. typedef void (^MtopExtRequestFailed)(MtopExtResponse* response);
  14. typedef void (^MtopExtRequestSucceed)(MtopExtResponse* response);
  15. typedef enum {
  16. /* 标记用的,请不要用 */
  17. MtopSessionExpiredOptionDummy = -1,
  18. /* Session失效时,什么都不做 */
  19. MtopSessionExpiredOptionNone = 0,
  20. /* Session失效时,只做Auto Login */
  21. MtopSessionExpiredOptionAutoLogin = 1,
  22. /* Session失效时,先Auto Login,如果Auto Login失败,唤起登录界面 */
  23. MtopSessionExpiredOptionAutoLoginAndManualLogin = 2
  24. } MtopSessionExpiredOption;
  25. typedef enum {
  26. /* 标记用的,请不要用 */
  27. MtopAuthExpiredOptionDummy = -1,
  28. /* Session失效时,什么都不做 */
  29. MtopAuthExpiredOptionNone = 0,
  30. /* Session失效时,只做Auto Login */
  31. MtopAuthExpiredOptionAutoAuth = 1,
  32. /* Session失效时,先Auto Login,如果Auto Login失败,唤起登录界面 */
  33. MtopAuthExpiredOptionAutAuthAndManualAuth = 2
  34. } MtopAuthExpiredOption;
  35. @interface MtopExtRequest : NSObject
  36. @property(assign, nonatomic) BOOL needLogin;
  37. @property(assign, nonatomic) BOOL needAuth;
  38. @property(assign, nonatomic) BOOL needWUA;
  39. @property(assign, nonatomic) MtopSessionExpiredOption sessionExpiredOption;
  40. @property(assign, nonatomic) MtopAuthExpiredOption authExpiredOption;
  41. @property (nonatomic, unsafe_unretained) NSTimeInterval timeOutSeconds;
  42. @property(copy, atomic) MtopExtRequestStarted startedBlock;
  43. @property(copy, atomic) MtopExtRequestFailed failedBlock;
  44. @property(copy, atomic) MtopExtRequestSucceed succeedBlock;
  45. @property (nonatomic, strong, readonly) NSString *apiName;
  46. @property (nonatomic, strong, readonly) NSString *apiVersion;
  47. @property (nonatomic, strong, readonly) NSString *requestID;
  48. @property (nonatomic, strong, readonly) NSDictionary *requestHeaders;
  49. @property (nonatomic, strong) NSString *customHost;
  50. @property(assign, atomic, readonly) BOOL isCanceled;
  51. @property (nonatomic, strong) NSDictionary *userInfo;
  52. @property (nonatomic, strong, readonly) NSString *bizID;
  53. - (id)initWithApiName:(nullable NSString *)apiName apiVersion:(nullable NSString *)apiVersion bizID:(nullable NSString *)bizID;
  54. - (void)addHttpHeader:(NSString *)value forKey:(NSString *)key;
  55. - (void)addBizParameter:(id)value forKey:(NSString *)key;
  56. - (void)addBizParameters:(NSDictionary *)kvs;
  57. - (void)removeBizParameter:(NSString *)key;
  58. - (void)useHttpPost;
  59. - (BOOL)isUseHttpPost;
  60. - (void)cancel;
  61. - (NSDictionary *)getBizParameters;
  62. @end
  63. NS_ASSUME_NONNULL_END