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

#import <Foundation/Foundation.h>

@interface LTHTTPRequest : NSObject

#pragma mark - 属性

/**
 NSURLRequest对象
 */
@property (nonatomic, strong) NSURLRequest *nsRequest;

/**
 HTTP请求方法, 如GET,POST, PUT
 */
@property (nonatomic, strong, readonly) NSString *method;

/**
 基础链接地址
 */
@property (nonatomic, strong, readonly) NSString *baseURL;

/**
 请求链接
 */
@property (nonatomic, copy, readonly) NSString *requestURL;

/**
 HTTP请求头
 */
@property (nonatomic, copy, readonly) NSDictionary<NSString *, NSString *> *allHTTPHeaders;

/**
 超时时长, 默认设置20s
 */
@property (nonatomic, assign) NSTimeInterval timeoutInterval;

/**
 缓存策略, 默认为NSURLRequestUseProtocolCachePolicy
 */
@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy;

#pragma mark - 初始化

/**
 初始化方法
 */
- (instancetype)initWithBaseURL:(NSString *)baseURL;

/**
 生成request对象
 */
+ (instancetype)requestWithBaseURL:(NSString *)baseURL;

#pragma mark - 设置HTTP的header

/**
 设置一个HTTPheader
 */
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;

/**
 设置多个HTTPheader
 */
- (void)setValuesAndHTTPHeaderFields:(NSDictionary<NSString *, NSString *> *)fields;

#pragma mark - 创建一个NSURLRequest对象

/**
 创建一个带有参数的请求对象
 */
- (NSURLRequest *)requestMethod:(NSString *)method
                            url:(NSString *)url
                         params:(NSDictionary *)params;

/**
 创建一个带有NSString的请求对象
 */
- (NSURLRequest *)requestNSStringMethod:(NSString *)method
                                    url:(NSString *)url
                                 params:(NSDictionary *)params;
/**
 创建一个请求对象
 */
- (NSURLRequest *)requestMethod:(NSString *)method
                            url:(NSString *)url;

@end
