| | |
| | | #import <Foundation/Foundation.h> |
| | | #import <CommonCrypto/CommonDigest.h> |
| | | #import "AFNetworking.h" |
| | | #import "YYModel.h" |
| | | |
| | | #define TestRequestHttpsHost @"https://test-gz.hdlcontrol.com" |
| | | #pragma mark API |
| | | #define API_POST_EZ_AddDevice @"/home-wisdom/platform/childAddDevice" |
| | | #define API_POST_EZ_GetChildToken @"/home-wisdom/platform/childToken" |
| | | #define API_POST_EZ_ChildDelDevice @"/home-wisdom/platform/childDelDevice" |
| | | #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_GetAlarmList @"/home-wisdom/platform/yingshi/alarm/records"//获取报警消息 |
| | | #define API_POST_EZ_DeleteAlarmMes @"/home-wisdom/platform/yingshi/alarm/delete"//删除报警消息 |
| | | #define API_POST_EZ_ReadAlarmMes @"/home-wisdom/platform/yingshi/alarm/updateChecked"//标记报警消息已读 |
| | | |
| | | #pragma mark APP_KEY |
| | | #define APP_KEY @"HDL-HOME-APP-TEST" |
| | |
| | | |
| | | //2.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [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_GetChildToken parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (block) { |
| | | NSString * token = @""; |
| | | if(responseData.success){ |
| | | token = responseData.data[@"accessToken"]; |
| | | // token = responseData.data[@"accessToken"]; |
| | | token = [NSString stringWithFormat:@"%@",responseData.data]; |
| | | } |
| | | block(token); |
| | | } |
| | |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceSerial forKey:@"deviceSerial"]; |
| | | [parameters setValue:verifyCode forKey:@"validateCode"]; |
| | | [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_AddDevice parameters:parameters completion:^(ResponseData *responseData) { |
| | | [self requestHttpsPost:API_POST_EZ_AddDevice parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | |
| | | //1.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceSerial forKey:@"deviceSerial"]; |
| | | [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_ChildDelDevice parameters:parameters completion:^(ResponseData *responseData) { |
| | |
| | | // return task; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据设备序列号获取告警信息列表 |
| | | */ |
| | | - (void)getAlarmList:(NSString *)deviceSerial |
| | | pageNo:(NSInteger)pageNo |
| | | pageSize:(NSInteger)pageSize |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | |
| | | //1.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:deviceSerial forKey:@"deviceSerial"]; |
| | | [parameters setValue:[GlobalKit shareKit].hdlHomeId forKey:@"homeId"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%ld",(long)pageSize] forKey:@"pageSize"]; |
| | | [parameters setValue:[NSString stringWithFormat:@"%ld",(long)pageNo] forKey:@"pageNo"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | NSLog(@"HDLpageNo:%ld",(long)pageNo); |
| | | [self requestHttpsPost:API_POST_EZ_GetAlarmList parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | /** |
| | | * 批量删除报警记录 |
| | | */ |
| | | - (void)deleteAlarmMessage:(NSArray *)alarmIds |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | |
| | | //1.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:[alarmIds yy_modelToJSONObject] forKey:@"alarmIds"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_DeleteAlarmMes parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量标记报警记录已读 |
| | | */ |
| | | - (void)readAlarmMessage:(NSArray *)alarmIds |
| | | completion:(void (^)(ResponseData *responseData))completion{ |
| | | |
| | | //1.设置请求参数 |
| | | NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; |
| | | [parameters setValue:@"1" forKey:@"isChecked"]; |
| | | [parameters setValue:[alarmIds yy_modelToJSONObject] forKey:@"alarmIds"]; |
| | | |
| | | parameters = [self GetSignRequestDictionary:parameters]; |
| | | |
| | | [self requestHttpsPost:API_POST_EZ_ReadAlarmMes parameters:parameters completion:^(ResponseData *responseData) { |
| | | if (completion) { |
| | | completion (responseData); |
| | | } |
| | | }]; |
| | | } |
| | | |
| | | |
| | | /// 刷新token |
| | |
| | | if (block) { |
| | | if (responseData) { |
| | | if(responseData.success){ |
| | | [EZSDK setHDlAccessToken: |
| | | [[EZSDK sharedInstance] setHDlAccessToken: |
| | | [NSString stringWithFormat:@"%@%@",responseData.data[@"headerPrefix"], responseData.data[@"accessToken"]] |
| | | refreshToken:responseData.data[@"refreshToken"]]; |
| | | |
| | |
| | | NSString *newString = @""; |
| | | for(NSString *key in sortKeyArray){ |
| | | if(params[key] != NULL){ |
| | | NSString *valueStr = params[key]; |
| | | //Key对应的value强转为NSString |
| | | NSString *valueStr = [NSString stringWithFormat:@"%@",[params objectForKey:key]]; |
| | | //检测当前参数是否需要参与校验 |
| | | if([self IfValueNeedSign:valueStr]){ |
| | | newString = [newString stringByAppendingString:[NSString stringWithFormat:@"%@=%@&", key,valueStr]]; |
| | |
| | | if (( [self stringIsNullOrEmpty:valueStr])//判空字符 |
| | | || ([[valueStr substringToIndex:1] isEqual:@"{"])//判断是否为对象 |
| | | || ([[valueStr substringToIndex:1] isEqual:@"["])//判断是否为数组 |
| | | || ([[valueStr substringToIndex:1] isEqual:@"("])//判断是否为数组 |
| | | ) { |
| | | |
| | | // HDLSDKLog(@"不校验: %@",valueStr); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | |
| | | |
| | | @end |
| | | |
| | | |
| | | #pragma mark - 修改记录 |
| | | //2021-07-07 |
| | | //V1.1.3 |
| | | //1.替换为新接口,根据homeId注册萤石子账号方案。 |