FDNetwork.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // FDNetwork.h
  3. // AFNetworking
  4. //
  5. // Created by fandongtongxue on 2020/2/27.
  6. //
  7. #import <Foundation/Foundation.h>
  8. @class FDNetworkResponseModel;
  9. NS_ASSUME_NONNULL_BEGIN
  10. typedef NS_ENUM(NSInteger, RequestContentType){
  11. RequestContentTypeJSON,
  12. };
  13. typedef NS_ENUM(NSInteger, ResponseContentType){
  14. ResponseContentTypeJSON,
  15. ResponseContentTypeText,
  16. };
  17. @interface FDNetwork : NSObject
  18. /**
  19. * 获取单例
  20. * @return BaseNetworking单例对象
  21. */
  22. + (FDNetwork *)shareInstance;
  23. /*!
  24. * @brief 超时时间,默认30秒
  25. */
  26. @property (assign, nonatomic) NSTimeInterval timeoutInterval;
  27. /*!
  28. * @brief 请求内容类型,默认JSON
  29. */
  30. @property (assign, nonatomic) RequestContentType requestContentType;
  31. /*!
  32. * @brief 返回数据内容类型,默认JSON
  33. */
  34. @property (assign, nonatomic) ResponseContentType responseContentType;
  35. /**
  36. * GET请求
  37. *
  38. * @param URLString 网络请求地址
  39. * @param param 参数(可以是字典或者nil)
  40. * @param success 成功后执行success block
  41. * @param failure 失败后执行failure block
  42. */
  43. - (void)GET:(NSString *)URLString param:(nullable NSDictionary *)param success:(nullable void (^)(FDNetworkResponseModel *result))success failure:(nullable void (^)(NSString *error))failure;
  44. /**
  45. * POST请求
  46. *
  47. * @param URLString 网络请求地址
  48. * @param param 参数(可以是字典或者nil)
  49. * @param success 成功后执行success block
  50. * @param failure 失败后执行failure block
  51. */
  52. - (void)POST:(NSString *)URLString param:(nullable NSDictionary *)param success:(nullable void (^)(FDNetworkResponseModel *result))success failure:(nullable void (^)(NSString *error))failure;
  53. @end
  54. NS_ASSUME_NONNULL_END