YH_HttpEngine.h 3.43 KB
//
//  YH_HttpEngine.h
//  YH_FRAME
//
//  Created by Leo on 14-5-23.
//  Copyright (c) 2014年 YOHO. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

//非登陆接口超时时间设为10秒
#define YHNetworkingTimeoutInterval   (10.0f)

//登录接口超时时间为40秒
#define YHNetworkingTimeoutIntervalLogin   (40.0f)

//上传文件接口超时时间为60秒
#define YHNetworkingTimeoutIntervalUpload   (60.0f)

//全球购购物车结算接口超时时间为10秒
#define YHNetworkingTimeoutIntervalGlobalCart  (10.0f)
@interface YH_HttpEngine : NSObject

@property (nonatomic, strong) NSString *httpURLString;

+ (instancetype)manager;

+ (instancetype)roomEngine;

+ (instancetype)validateAnchorEngine;

/**
 *  @author Kennaki Kai, 16-08-19 13:08:36
 *
 *  @brief Start or stop push notification.
 *
 *  @return null
 *
 *  @since 1.0.1
 */
+ (instancetype)pushStatusEngine;

/**
 *  @author Kennaki Kai, 16-08-19 13:08:48
 *
 *  @brief Get push room list.
 *
 *  @return null
 *
 *  @since 1.0.1
 */
+ (instancetype)roomListEngine;

/**
 *  @author Kennaki Kai, 16-08-18 15:08:20
 *
 *  @brief Get live barrage socket address
 *
 *  @return Socket address.
 *
 *  @since 1.0
 */
+ (instancetype)socketAddrEngine;

+ (instancetype)liveEngine;
+ (instancetype)apiEngine;
/**
 @brief 支付引擎
 
 @param hostName 支付数据请求域名
 
 @return self
 
 @since 4.5
 */
+ (instancetype)paymentEngine:(NSString *)hostName;

-(void)post:(NSDictionary*)parameters
    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

-(void)post:(NSDictionary*)parameters
    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
    timeout:(NSTimeInterval)timeoutInterval;


-(void)post:(NSDictionary *)parameters
    resourcePath:(NSString *)path
    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

-(void)post:(NSDictionary *)parameters
resourcePath:(NSString *)path
    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
    timeout:(NSTimeInterval)timeoutInterval;

- (AFHTTPRequestOperation *)POST:(NSDictionary *)parameters
       constructingBodyWithBlock:(void (^)(id <AFMultipartFormData> formData))block
                      completion:(void (^)(id response, NSError *error))completion;

-(void)get:(NSDictionary*)parameters
   success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
   failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

-(void)get:(NSDictionary*)parameters
    resourcePath:(NSString *)path
   success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
   failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

-(void)getHtml:(NSDictionary*)parameters
    success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
    failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

//数据鉴权
- (NSMutableDictionary *)encodeParams:(NSDictionary *)parameters;

- (NSMutableDictionary *)encodeParams:(NSDictionary *)parameters withPrivateKey:(NSString *)key;

@end