HttpManager.h 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // HttpManager.h
  3. // TheoryNetwork
  4. //
  5. // Created by tederen on 2019/9/25.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "FwzAppConfig.h"
  10. NS_ASSUME_NONNULL_BEGIN
  11. @class AFHTTPSessionManager;
  12. @interface HttpManager : NSObject
  13. @property (nonatomic, strong) AFHTTPSessionManager *manager;
  14. TDShareInstance_interface(HttpManager)
  15. - (void)GET:(NSString *)URLString
  16. parameters:(nullable id)parameters
  17. success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  18. failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  19. - (void)POST:(NSString *)URLString
  20. parameters:(nullable id)parameters
  21. success:(nullable void (^)(NSURLSessionDataTask *task, id _Nullable responseObject))success
  22. failure:(nullable void (^)(NSURLSessionDataTask * _Nullable task, NSError *error))failure;
  23. #pragma mark - GET请求
  24. /// GET请求接口 接收格式固定
  25. - (void)GETUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  26. /// GET请求接口 接收格式可选
  27. - (void)GETUrl:(NSString *)url parameters:(NSDictionary *)parameters responseStyle:(FWZRsponseStyle)style success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  28. /// 只需要传 api url 即可
  29. - (void)GETWithUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  30. #pragma mark - POST请求
  31. /// POST 请求接口 接收格式固定
  32. - (void)POSTUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  33. /// POST 请求接口 接收格式可选
  34. - (void)POSTUrl:(NSString *)url parameters:(NSDictionary *)parameters responseStyle:(FWZRsponseStyle)style success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  35. /// 只需要传 api url 即可
  36. - (void)POSTWithUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  37. #pragma mark - PUT请求
  38. /// PUT请求接口
  39. - (void)PUTUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  40. /// PUT请求接口 接收格式可选
  41. - (void)PUTUrl:(NSString *)url parameters:(NSDictionary *)parameters responseStyle:(FWZRsponseStyle)style success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  42. #pragma mark - Delete请求
  43. /// Delete请求接口 接收格式固定
  44. - (void)DeleteUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  45. /// Delete请求接口 接收格式可选
  46. - (void)DeleteUrl:(NSString *)url parameters:(NSDictionary *)parameters responseStyle:(FWZRsponseStyle)style success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  47. /// 只需要传 api url 即可 Delete请求接口 接收格式固定
  48. - (void)DeleteWithUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))successful failure:(void (^) (NSError *error))failure;
  49. #pragma mark - 图片上传
  50. /**
  51. 图片上传接口(上传音频与图片是一致的,需要更改的只是 mimeType类型,根据要求设置对应的格式即可)
  52. @param url 请求接口
  53. @param paramters 请求参数
  54. @param pictureData 图片数据
  55. @param pictureKey 与后台约定的 文件key
  56. @param successful 成功返回
  57. @param failure 失败返回
  58. */
  59. - (void)HeaderUploadUrl:(NSString *)url parameters:(NSDictionary *)paramters pictureData:(NSData *)pictureData pictureKey:(NSString *)pictureKey success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure;
  60. - (void)HeaderUploadUrl:(NSString *)url parameters:(NSDictionary *)paramters pictureArray:(NSArray *)array pictureKey:(NSString *)pictureKey success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure;
  61. - (void)downloadUrl:(NSString *)url downloadFilePath:(NSString *)downloadFilePath success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure;
  62. - (void)HeaderUploadFileUrl:(NSString *)url parameters:(NSDictionary *)paramters fileData:(NSData *)fileData fileKey:(NSString *)fileKey fileName:(NSString *)fileName mimeType:(NSString *)mimeType success:(void (^) (id responseObject))successful failure:(void (^) (NSError *error))failure;
  63. - (void)cancelRequest;
  64. @end
  65. NS_ASSUME_NONNULL_END