//
//  RDSDemoApiHelper.h
//  singleProduct
//
//  Created by coderYK on 2018/4/28.
//  Copyright © 2018年 RDIOT. All rights reserved.
//

#import <Foundation/Foundation.h>


#define TheApiHelper [RDSDemoApiHelper sharedInstance]

@interface RDSDemoApiHelper : NSObject

@property (nonatomic, copy) NSString *netWorkState;

@property (nonatomic, copy) NSString *baseUrlHost;
@property (nonatomic, copy) NSString *baseUrlHeadImg;
@property (nonatomic, assign) NSInteger isTest;

AS_SINGLETON(RDSDemoApiHelper)

/**
 基于 AFN 的图片上传接口
 
 @param image 需要上传的图片
 @param completionBlock 上传结构的回调
 @return 会话任务
 */
- (NSURLSessionUploadTask*)rds_uploadTaskWithImage:(UIImage*)image
                                        completion:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionBlock;


/**
 异步多图上传接口
 
 @param images 图片对象数组
 @param completionHandler 上传结构回调（有序的图片路径）
 */
- (void)rds_uploadImagesBatches:(NSArray<UIImage *>*)images
                     completion:(void (^)(id response))completionHandler
                       failture:(void (^)(NSError *error))failture;


/**
 APP检查更新
 */
+ (void)rds_appVersionCheckSuccess:(void (^)(id responseObject))success
                           failure:(void (^)(NSError *error))failure;


#pragma mark - 初始化
/// APP初始化调用
+ (void)rds_appInitSuccess:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

#pragma mark - 注册登录


/// 获取手机验证码
/// - Parameters:
///   - phone: 手机号
///   - type: 业务类型(1:登录 2:忘记密码)
+ (void)rds_getVerifyCodePhone:(NSString *)phone type:(int)type success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;



/// 验证码登录
/// - Parameters:
///   - phone: 手机号
///   - code: 验证码
+ (void)rds_loginWithVerifyCodePhone:(NSString *)phone code:(NSString *)code success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;


/// 手机号密码登录
/// - Parameters:
///   - phone: 手机号
///   - password: 密码（md5加密）
+ (void)rds_loginWithPwdPhone:(NSString *)phone password:(NSString *)password success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;


/// 首次登录设置密码
/// - Parameters:
///   - password: 密码（md5加密）
+ (void)rds_setPassword:(NSString *)password success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;


/// 重置密码
/// - Parameters:
///   - phone: 手机号
///   - password: 密码（md5加密）
///   - code: 验证码
+ (void)rds_resetPwdPhone:(NSString *)phone password:(NSString *)password code:(NSString *)code success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 刷新token
+ (void)rds_refreshTokenSuccess:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 退出登录
+ (void)rds_logoutSuccess:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;

/// 注销账户
+ (void)rds_unsubscribeSuccess:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;

/// 获取天气信息
+ (void)rds_getWeatherSuccess:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;

#pragma mark - 用户信息
/// 获取当前用户信息
+ (void)rds_getCurrentUserInfoSuccess:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure;

/// 上传头像
+ (void)rds_postImage:(UIImage *)image success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 更新用户信息
+ (void)rds_updateUserInfoChangeUserName:(NSString *)userName photoUrl:(NSString *)photoUrl defaultHomeId:(NSString *)homeId isSetPwd:(BOOL)isSetPwd success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;


/// 获取当前用户默认的家
+ (void)rds_getDefaultHomeSuccess:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;

/// 获取家庭列表 (家庭管理 is_admin 管理员填是）
+ (void)rds_getHomeListIsAdmin:(BOOL)is_admin success:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;

/// 获取家庭信息详情
+ (void)rds_getHomeDetailWithHomeId:(NSString *)homeId success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure;

/// 切换家庭 更新用户默认的家
+ (void)rds_setDefaultHome:(NSString *)home_id success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 更新家庭信息 （名称、城市 选填)
+ (void)rds_updateHomeInfoWithHomeId:(NSString *)record_id name:(NSString *)name city:(NSString *)city success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure;

/// 邀请家庭成员
+ (void)rds_addMemberWithHomeId:(NSString *)home_id phone:(NSString *)phone success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;

/// 删除家庭成员
+ (void)rds_delMemberWithHomeId:(NSString *)home_id user_id:(NSString *)user_id success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;


/// 创建家庭
+ (void)rds_addHomeWithName:(NSString *)name isDefault:(BOOL)is_default city:(NSString *)city success:(void (^)(id responseObject))success
                    failure:(void (^)(NSError *error))failure;

/// 删除家庭
+ (void)rds_delHomeWithHomeId:(NSString *)home_id success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure;
#pragma mark - 房间管理
/// 房间列表查询
+ (void)rds_getRoomListSuccess:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure;

/// 设备类型列表查询
+ (void)rds_getDeviceTypeListSuccess:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure;

/// 创建房间（绑定分控面板）
/// - Parameters:
///   - name: 房间名
///   - control_number: 分控编号
+ (void)rds_addRoomName:(NSString *)name control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;


/// 删除房间
/// - Parameters:
///   - record_ids:记录id数组
+ (void)rds_deleteRoomsRecord_ids:(NSArray *)record_ids success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 更新房间名称
+ (void)rds_updateRoomName:(NSString *)name record_id:(NSString *)record_id home_id:(NSString *)home_id success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 获取房间详情
+ (void)rds_getRoomDetailRecord_id:(NSString *)record_id success:(void (^)(id responseObject))success
                           failure:(void (^)(NSError *error))failure;

/// 获取房间实时状态
+ (void)rds_getRoomStatusWithControl_number:(NSString *)control_number success:(void (^)(id responseObject))success
                                    failure:(void (^)(NSError *error))failure;
#pragma mark - 设备控制

/// 温度
+ (void)rds_setTemp:(int)temp control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 模式
+ (void)rds_setMode:(int)mode control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 风速
+ (void)rds_setSpeed:(int)speed control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 定时
+ (void)rds_setTimer:(NSNumber *)timer onOff:(BOOL)onOff control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 开关
+ (void)rds_setPower:(int)power control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;
// 新风开关
+ (void)rds_setNewFanPower:(int)power control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 分控开关
+ (void)rds_setSubDevPower:(int)power control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;

/// 分控风速
+ (void)rds_setSubDevSpeed:(int)speed control_number:(NSString *)control_number success:(void (^)(id responseObject))success
                   failure:(void (^)(NSError *error))failure;
@end
