| | |
| | | |
| | | #define TestRequestHttpsHost @"https://test-gz.hdlcontrol.com" |
| | | #pragma mark API |
| | | #define API_POST_EZ_VerifyLocalLock @"/home-wisdom/platform/yingshi/lock/verifyLocalLock"//萤石门锁本地验证 |
| | | #define API_POST_EZ_AddDevice @"/home-wisdom/platform/yingshi/child/addDevice" |
| | | #define API_POST_EZ_GetChildToken @"/home-wisdom/platform/yingshi/child/token" |
| | | #define API_POST_EZ_ChildDelDevice @"/home-wisdom/platform/yingshi/child/deleteDevice" |
| | | #define API_POST_EZ_RefreshToken @"/smart-footstone/member/oauth/login" |
| | | #define API_POST_EZ_LockAuth @"/home-wisdom/platform/yingshi/lock/auth"//萤石门锁终端授权 |
| | | #define API_POST_EZ_RemoteOpen @"/home-wisdom/platform/yingshi/lock/remote/open/door"//萤石门锁远程开锁 |
| | | #define API_POST_EZ_TempList @"/home-wisdom/platform/yingshi/lock/temp/list"//萤石门临时密码列表 |
| | | #define API_POST_EZ_AddTemp @"/home-wisdom/platform/yingshi/lock/temp/add"//萤石门添加临时密码 |
| | | #define API_POST_EZ_DeleteTemp @"/home-wisdom/platform/yingshi/lock/temp/delete"//萤石门删除临时密码 |
| | | |
| | | #define API_POST_EZ_GetAlarmList @"/home-wisdom/platform/yingshi/alarm/records"//获取报警消息 |
| | | #define API_POST_EZ_DeleteAlarmMes @"/home-wisdom/platform/yingshi/alarm/delete"//删除报警消息 |
| | |
| | | |
| | | // return task; |
| | | } |
| | | |
| | | /** |
| | | * @since 河东添加设备之前本地验证的接口(智能门锁使用,调用接口后输入门锁密码,再进行绑定) |
| | | * @param deviceSerial 设备序列号 |
| | | * @param completion 回调block,error为空时表示调用验证接口成功 |
| | | * |
| | | */ |
| | | - (void)verifyLocalLockByHDL:(NSString *)deviceSerial |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //2.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceSerial forKey:@"deviceSerial"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue: [NSString stringWithFormat:@"%d",[GlobalKit shareKit].hdlPlatform] forKey:@"platform"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_VerifyLocalLock parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | /** |
| | | * @since 河东添加设备的接口 |
| | | * 根据设备序列号和设备验证码添加设备接口 |
| | |
| | | }]; |
| | | } |
| | | |
| | | /** |
| | | * @since 河东门锁终端授权接口 |
| | | * @param password 门锁密码 |
| | | * @param deviceId 设备id |
| | | * @param verifyCode sdk获取的校验码 |
| | | * @param completion 回调block,error为空时表示添加成功 |
| | | * |
| | | */ |
| | | - (void)authLockByHDL:(NSString *)password |
| | | deviceId:(NSString *)deviceId |
| | | verifyCode:(NSString *)verifyCode |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //2.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceId forKey:@"deviceId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue:password forKey:@"password"]; |
| | | [parameters setValue:verifyCode forKey:@"verifyCode"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | NSLog(@"终端授权参数:%@",parameters); |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_LockAuth parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @since 河东远程开锁接口 |
| | | * @param streamToken 设备序列号 |
| | | * @param deviceId 设备id |
| | | * @param completion 回调block,error为空时表示添加成功 |
| | | * |
| | | */ |
| | | - (void)remoteOpenByHDL:(NSString *)streamToken |
| | | deviceId:(NSString *)deviceId |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //2.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceId forKey:@"deviceId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue:streamToken forKey:@"streamToken"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | NSLog(@"开门参数:%@",parameters); |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_RemoteOpen parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @since 河东获取临时密码列表接口 |
| | | * @param deviceId 设备id |
| | | * @param completion 回调block,error为空时表示成功 |
| | | * |
| | | */ |
| | | - (void)getTempListByHDL:(NSString *)deviceId |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //2.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceId forKey:@"deviceId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | NSLog(@"获取临时密码列表参数:%@",parameters); |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_TempList parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | /** |
| | | * @since 河东添加临时密码接口 |
| | | * @param tempInfo 临时密码信息 |
| | | * @param deviceId 设备id |
| | | * @param completion 回调block,error为空时表示成功 |
| | | * |
| | | */ |
| | | - (void)addTempByHDL:(HDLEZTemInfoModel *)tempInfo |
| | | deviceId:(NSString *)deviceId |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithDictionary:[tempInfo yy_modelToJSONObject]]; |
| | | [parameters setValue:deviceId forKey:@"deviceId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | NSLog(@"添加临时密码参数:%@",parameters); |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_AddTemp parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | /** |
| | | * @since 河东删除临时密码接口 |
| | | * @param extVisitorId 临时密码索引 |
| | | * @param deviceId 设备id |
| | | * @param completion 回调block,error为空时表示成功 |
| | | * |
| | | */ |
| | | - (void)deleteTempByHDL:(NSString *)extVisitorId |
| | | deviceId:(NSString *)deviceId |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | //设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:extVisitorId forKey:@"extVisitorId"]; |
| | | [parameters setValue:deviceId forKey:@"deviceId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | NSLog(@"删除临时密码参数:%@",parameters); |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_DeleteTemp parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | |
| | | } |
| | | |
| | | /// 刷新token |
| | | /// @param block 结果 |
| | |
| | | }]; |
| | | } |
| | | }]; |
| | | }else{ |
| | | completion(responseData); |
| | | } |
| | | |
| | | completion(responseData); |
| | | } |
| | | }]; |
| | | } |
| | |
| | | |
| | | if(responseObject != NULL){ |
| | | //4.解析拿到的响应数据 |
| | | NSLog(@"%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]); |
| | | NSLog(@"数据返回%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]); |
| | | NSDictionary * outDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil]; |
| | | responseData = [[ResponseData alloc] initWithDictionary:outDic]; |
| | | } |