//
//  LTHTTPService.h
//  LTUnionSDK
//
//  Created by 孙泉 on 2017/6/30.
//  Copyright © 2017年 孙泉. All rights reserved.
//

#import <Foundation/Foundation.h>

@class LTHTTPRequest;
@class LTHTTPResponse;

/**
 响应回调
 
 @param response 响应对象
 */
typedef void(^LTHTTPResponseBlock)(LTHTTPResponse *response);

@interface LTHTTPService : NSObject

/**
 HTTP请求对象
 */
@property (nonatomic, strong) LTHTTPRequest *request;

#pragma mark - 初始化方法

/**
 快速初始化对象
 
 @return 初始化对象
 */
+ (instancetype)sharedService;

/**
 使用baseURL初始化对象
 */
- (instancetype)initWithBaseURL:(NSString *)baseURL;

/**
 生成service对象
 */
+ (instancetype)serviceWithBaseURL:(NSString *)baseURL;

#pragma mark - HTTP请求方法

/**
 发送GET请求, 参数为NSDictionary
 */
- (void)getRequest:(NSString *)url
            params:(NSDictionary *)params
           success:(LTHTTPResponseBlock)success
           failure:(LTHTTPResponseBlock)failure;

/**
 发送POST请求, 参数为NSDictionary
 */
- (void)postRequest:(NSString *)url
             params:(NSDictionary *)params
            success:(LTHTTPResponseBlock)success
            failure:(LTHTTPResponseBlock)failure;

/**
 发送POST请求, 参数为NSString
 */
- (void)postNSStringRequest:(NSString *)url
                     params:(NSDictionary *)params
                    success:(LTHTTPResponseBlock)success
                    failure:(LTHTTPResponseBlock)failure;

/**
 发送POST请求, 参数为NSData
 */
- (void)postRequest:(NSString *)url
         bodyStream:(NSData *)bodyStream
            success:(LTHTTPResponseBlock)success
            failure:(LTHTTPResponseBlock)failure;

/**
 发送PUT请求, 参数为NSData
 */
- (void)putRequest:(NSString *)url
        bodyStream:(NSData *)bodyStream
           success:(LTHTTPResponseBlock)success
           failure:(LTHTTPResponseBlock)failure;

@end
