//
//  HttpRequest.h
//  zhuxun
//
//  Created by 张建伟 on 15/4/7.
//  Copyright (c) 2015年 张建伟. All rights reserved.
//

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


typedef enum {
    get = 0,
    post,
    put,
    delet
} RequestMethod;


@interface HttpRequest : NSObject

@property (nonatomic, strong) HttpClient *client;

+ (instancetype)sharedManager;


//公共的请求方法
-(void)public_Request_With_MethodType:(RequestMethod)method path:(NSString *)path params:(id)params andBlock:(void (^) (id data, NSError *error))block;




//登录
-(void)postLoginParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete;

//获取群组通信和存储信息
-(void)getGroupParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete;

//完善登录信息
-(void)postDeviceInfo:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  重置未读条数接口
 *
 *  @param params @{@"serverID":Server_ID,@"userID":User_ID, @"count":@(count)}
 *  @param block  返回调用的block
 */
-(void)request_resetUnreadCount_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

#pragma mark - users info
/**
 *  搜索用户的接口
 *
 *  @param params :@{@"serverID": "0",@"key":"searchText"  @"pageSize":@(20), @"pageIndex":@(1)}
 *
 *  @param block  返回调用的block
 */
-(void)search_users_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取用户详情
 *
 *  @param params   @{@"serverID": Server_ID,@"userName": loginName}
 *  @param block  返回调用的block
 */
-(void)request_userDetail_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取多用户详情
 *
 *
 *  @pramas @{@"userTokens":[array],@"uuid":可选参数}
 */
-(void)request_UserDetailListWith:(id)params andBlock:(void(^)(id data,NSError *error))block;


/**
 *  获取用户详情
 * @params @{@"serverID":serverID,@"userNames":@[loginName],@"uuid":@""}
 */
//-(void)request_userState_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block;


/**
 *  获取未阅的通知公告提醒
 *
 *  @param @{@"receiver":receiver,@"pageSize":pageSize,@"pageIndex":pageIndex,@"uuid",uuid}
 */

-(void)request_NoticeOffline_WithParams:(id)params andBlock:(void(^)(id data,NSError *error))block;

/**
 *  获取离线消息
 *  @params @{@"receiver":@"receiver",@"pageSize":@"pageSize",@"pageIndex":@"pageIndex",@"uuid":@"uuid"}
 */
-(void)request_MsgOffLine_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block;

/**
 *  获取历史消息
 *  @params   { uuid:"", userToken:"CID+serverID-loginName", time:"", size:"", index:"" }
 */
-(void)request_HistoryMessage_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block;

/**
 *  拉取用户最后的设备
 *  @params @{ serverID:"serverID", loginName:"loginName"， uuid:"uuid" }
 */
-(void)request_User_lastDevice_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block;


/**
 *  获取所有的组
 *
 *  @param params @{ @"serverID":Server_ID,b@"parentID":@"0"}
 *  @param block  返回调用的block
 */
-(void)request_Branches_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取branch下面所有的child，包括branch和addrbook
 *
 *  @param params  @{@"parentID":parentbranch.branchID, @"serverID":Server_ID}
 *  @param block  返回调用的block
 */
-(void)request_allChildOfBranch_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  上传头像
 *
 *  @param params @{@"userID":@"", @"user":@"serverID-loginName",@"uuid":@"",@"time":@"123123123",@"image":@"base64"}
 *  @param block  返回调用的block
 */
-(void)upload_headImage_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;
//======================================================================================
/**
 *  私人通讯录同步数据接口
 *
 *  @param params @{@"serverID":Server_ID, @"userName":Login_Name
 };
 *  @param block  返回调用的block
 */
-(void)request_personalAddrbook_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取单对单历史消息
 *  
 *  { sender:"", receiver:"", time:12345, index:1, size:20, uuid:"" }
 */
-(void)request_chatObjectHistory_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;


/**
 *  获取发送者离线同步消息 自己在PC设备上发送的消息
 *
 *  @param params ：{ sender:"CID+serverID-loginName", pageSize:"", pageIndex:"", uuid:"" }
 */
-(void)request_MsgOffLinesync_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  统一获取离线消息
 *
 *  @param params
 *  @param block
 */
-(void)request_MsgOffLinesMsgsParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  离线消息获取并反馈成功接口
 *
 *  @param params
 *  @param block
 */
-(void)request_MsgOffLinesMsgsReceiveResponse:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  用户最近联系人列表(只含有未读消息)
 *
 *  @param params id
 *  @param block  return
 */
- (void)request_UnReadMsgListWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取单人聊天历史纪录
 *
 *  @param params id
 参数说明：
 String current  -必填项，当前用户，格式：CID+serverID-loginName
 String target   -必填项，目标用户，格式：CID+serverID-loginName
 String uuid     -可选项，请求唯一标识
 参数格式：{ current:"CID+serverID-loginName", target:"CID+serverID-loginName", uuid:"" }
 *  @param block  return
 */
- (void)request_SingleUnReadMsgsWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  获取单人聊天历史纪录成功的反馈
 *
 *  @param params id
 参数说明：
 String current   -必填项，当前用户，格式：CID+serverID-loginName
 String target    -必填项，目标用户，格式：CID+serverID-loginName
 String|int time  -必填项，拉取的消息中最新的消息时间戳，Number类型
 String uuid      -可选项，请求唯一标识
 参数格式：{ current:"CID+serverID-loginName", target:"CID+serverID-loginName", time:123455678.45, uuid:"" }
 *  @param block  return
 */
- (void)request_SingleUnReadMsgsResponseWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

/**
 *  删除服务器聊天信息
 *
 *
 *  @params  参数格式：{ current:"CID+serverID-loginName", target:"CID+serverID-loginName", uuid:"" }
 */

-(void)request_deleteCurrentChatMessagesWithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;

/**
 *  注销登录
 *
 *  @param params 参数－serverid，loginname，uuid(optional)
 *  @param block  result
 */
- (void)logout_withParams:(id)params andBlock:(void (^)(id data,NSError *error))block;
/**
 *  获取我的客服列表
 *
 *  @param params 参数-serverID,loginName,timestamp
 *  @param block  result
 */
- (void)getMyCustomerServicerwithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;

/**
 *  获取我的常用联系人
 *
 *  @param params 参数-serverID,loginName
 *  @param block  result
 */
- (void)getMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;

/**
 *  添加我的常用联系人
 *
 *  @param params 参数-self:serverID,loginName contact:full_login-name;
 *  @param block  result
 */
- (void)addMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;

/**
 *  删除我的常用联系人
 *
 *  @param params 参数 -serverid+loginname
 *  @param block  result
 */
- (void)deleteMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;
/**
 *  获取顶级部门成员
 *
 *  @param params params
 *  @param block  block
 */
- (void)postTopDepartmentMembers:(id)params andBlock:(void (^)(id data,NSError *error))block;

//======================================================================================
#pragma mark - 短信验证
-(void)request_sendSMS_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

-(void)request_authSMS_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

#pragma mark - 微助手自带短信
- (void)request_SendSMS_NoLocalWithParams:(id)params andBlock:(void (^)(id data,NSError *error))block;

//======================================================================================
#pragma mark - SOCKET.IO 模拟的http
//获取离线同步数据
-(void)request_isSync_WithParams:(id)params andBlock:(void(^)(id data,NSError *error))block;

-(void)request_login_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;

-(void)request_auth_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block;


///=============================================================================
/// @name CloudStorage
///=============================================================================

/**
 *  cloud login
 *
 *  @param params   params
 *  @param complete callback
 */
- (void)cloudStoragePostLoginWithParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  cloud file search
 *
 *  @param pid      father branchid
 *  @param key      if(search) key
 *  @param fileExt  if(file type) fileext . 0：图片文件 1:文档文件 2：音频 3：视频
 *  @param complete callback
 */
- (void)cloudStorageGetFilesWithPid:(NSString *)pid searchKey:(NSString *)key ext:(NSString *)fileExt complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  获取回收站的文件
 *
 *  @param complete callback
 */
- (void)cloudStorageGetRecycledFilesWithComplete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  文件(夹)删除
 *
 *  @param fileID      文件id
 *  @param deleteLevel 0.彻底删除 1.移到垃圾桶
 *  @param complete    callback
 */
- (void)cloudStorageFileDeleteWithItemIDs:(NSArray *)fileIDs deleteLevel:(NSInteger)deleteLevel complete:(void (^)(BOOL success, id data, NSError *error)) complete;


/**
 *  根据父id获取所有文件夹(文件上传选择路径使用)
 *
 *  @param pid      父id
 *  @param excludeIds      不需要的ids
 *  @param complete callback
 */
- (void)cloudStorageGetAllFolderWithPid:(NSString *)pid excludeIds:(NSArray *)excludeIds complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  获取当前文件夹下的所有文件及文件夹信息
 *
 *  @param pids     pids
 *  @param complete callback
 */
- (void)cloudStorageGetAllChildsWithPids:(NSArray *)pids complete:(void (^)(BOOL success, id data, NSError *error)) complete;
/**
 *  file-folder rename
 *
 *  @param name     newname
 *  @param itemID   itemID
 *  @param complete callBack
 */
- (void)cloudStorageFileReNameWithNewName:(NSString *)name fileID:(NSString *)itemID complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  创建文件夹
 *
 *  @param folderName 文件夹名字
 *  @param pid        当前父节点id
 *  @param delflag    补充标识{0. 正常文件夹 1.删除的(文件),2.hidden文件夹 }}
 *  @param complete   callBack
 */
- (void)cloudStorageCreateNewFileFolderWithFolderName:(NSString *)folderName pid:(NSString *)pid delflag:(NSString *)delflag complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  文件选择云盘路径上传时检测是否已存在这样的名字的文件
 *
 *  @param pid      当前文件夹id
 *  @param fileName 要上传的文件name
 *  @param complete callback
 */
- (void)cloudStorageCheckFileNameIsExitWithPid:(NSString *)pid fileName:(NSString *)fileName isdir:(BOOL)isdir ext:(NSString *)ext  complete:(void (^)(BOOL success, id data, NSError *error)) complete;


/**
 *  创建文件(云盘上传后通知下方)
 *
 *  @param fileName 文件名
 *  @param md5      md5值
 *  @param pid      当前父节点id
 *  @param delflag  补充标识{0. 正常文件 1.删除的(文件),2.hidden文件 }}
 *  @param ext      文件扩展名
 *  @param size     文件大小bit
 *  @param complete callback
 */
- (void)cloudStorageCreateNewFileWithFileName:(NSString *)fileName md5:(NSString *)md5 pid:(NSString *)pid delflag:(NSString *)delflag ext:(NSString *)ext size:(NSNumber*)size complete:(void (^)(BOOL success, id data, NSError *error)) complete;



/**
 * 移动网盘文件位置
 *
 *  @param pid      新的父节点
 *  @param csfiles  需要移动的文件/文件夹ids
 *  @param complete callback
 */
- (void)cloudStorageMoveFilesToOtherPid:(NSString *)pid needMoveFiles:(NSArray *)csfiles complete:(void (^)(BOOL success, id data, NSError *error)) complete;
/**
 *  复制网盘文件到目标文件夹
 *
 *  @param pid      目标文件夹id
 *  @param csfiles  需要复制的文件/文件夹ids数组
 *  @param complete callback
 */
- (void)cloudStorageCopyFilesToOtherPid:(NSString *)pid needCopyFiles:(NSArray *)csfiles complete:(void (^)(BOOL success, id data, NSError *error)) complete;

//更新文件(夹)


/**
 *  获取文件下载url
 *
 *  @param md5      md5
 *  @param complete callback
 */
- (void)cloudStorageGetFileDownloadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete;

/**
 *  获取文件上传url
 *
 *  @param md5      md5
 *  @param complete callback
 */
- (void)cloudStorageGetFileUploadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete;
/**
 *  创建分享文件(夹)
 *
 *  @param filesdic   filesdic
 *  @param receivers  分享给[XXX]
 *  @param complete callback
 */
- (void)cloudStorageCreateShareFiles:(NSArray *)filesdic WithReceivers:(NSArray*)receivers complete:(void (^)(BOOL success, id data, NSError *error)) complete;
/**
 *  获取分享文件(夹)
 *
 *  @param shareID  shareID
 *  @param complete callback
 */
- (void)cloudStorageGetShareFiles:(NSString *)shareID complete:(void (^)(BOOL success, id data, NSError *error)) complete;

@end
