

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

#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)

@class ZYJQNHttpResponseInfo;

typedef void (^ZYJQNInternalProgressBlock)(long long totalBytesWritten, long long totalBytesExpectedToWrite);
typedef void (^ZYJQNCompleteBlock)(ZYJQNHttpResponseInfo *httpResponseInfo, NSDictionary *respBody);
typedef BOOL (^ZYJQNCancelBlock)(void);

@interface ZYJQNSessionStatistics : NSObject

@property (nonatomic, copy) NSString *remoteIp;
@property (nonatomic, assign) int64_t port;
@property (nonatomic, assign) int64_t totalElapsedTime;
@property (nonatomic, assign) int64_t dnsElapsedTime;
@property (nonatomic, assign) int64_t connectElapsedTime;
@property (nonatomic, assign) int64_t tlsConnectElapsedTime;
@property (nonatomic, assign) int64_t requestElapsedTime;
@property (nonatomic, assign) int64_t waitElapsedTime;
@property (nonatomic, assign) int64_t responseElapsedTime;
@property (nonatomic, assign) int64_t bytesSent;
@property (nonatomic, assign) int64_t bytesTotal;
@property (nonatomic, assign, getter=isProxyConnection) BOOL proxyConnection;

@end

@interface ZYJQNSessionManager : NSObject

- (instancetype)initWithProxy:(NSDictionary *)proxyDict
                      timeout:(UInt32)timeout
                 urlConverter:(ZYJQNUrlConvert)converter;

- (void)multipartPost:(NSString *)url
             withData:(NSData *)data
           withParams:(NSDictionary *)params
         withFileName:(NSString *)key
         withMimeType:(NSString *)mime
   withIdentifier:(NSString *)identifier
    withCompleteBlock:(ZYJQNCompleteBlock)completeBlock
    withProgressBlock:(ZYJQNInternalProgressBlock)progressBlock
      withCancelBlock:(ZYJQNCancelBlock)cancelBlock
           withAccess:(NSString *)access;

- (void)post:(NSString *)url
             withData:(NSData *)data
           withParams:(NSDictionary *)params
          withHeaders:(NSDictionary *)headers
    withIdentifier:(NSString *)identifier
    withCompleteBlock:(ZYJQNCompleteBlock)completeBlock
    withProgressBlock:(ZYJQNInternalProgressBlock)progressBlock
      withCancelBlock:(ZYJQNCancelBlock)cancelBlock
           withAccess:(NSString *)access;

- (void)get:(NSString *)url
          withHeaders:(NSDictionary *)headers
    withCompleteBlock:(ZYJQNCompleteBlock)completeBlock;

- (void)invalidateSessionWithIdentifier:(NSString *)identifier;

@end

#endif
