From 4c1abca185a5727da6fb314a0cb4cd44bfe1b3bf Mon Sep 17 00:00:00 2001
From: Davin <591807572@qq.com>
Date: 星期五, 07 六月 2024 17:48:47 +0800
Subject: [PATCH] feature appkey修改

---
 EZSDK/EZSDK/EZ/Global/EZHttpUtil.m |  161 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 157 insertions(+), 4 deletions(-)

diff --git a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m
index 71d32d8..94b201a 100644
--- a/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m
+++ b/EZSDK/EZSDK/EZ/Global/EZHttpUtil.m
@@ -30,12 +30,18 @@
 #define API_POST_EZ_DeleteAlarmMes @"/home-wisdom/platform/yingshi/alarm/delete"//鍒犻櫎鎶ヨ娑堟伅
 #define API_POST_EZ_ReadAlarmMes @"/home-wisdom/platform/yingshi/alarm/updateChecked"//鏍囪鎶ヨ娑堟伅宸茶
 
+#define API_POST_EZ_GetCoverSwitchStaus @"/home-wisdom/platform/yingshi/getCoverSwitchStatus"//鑾峰彇钀ょ煶闀滃ご閬斀寮�鍏崇姸鎬�
+#define API_POST_EZ_GetCoverSwitch @"/home-wisdom/platform/yingshi/coverSwitch"//璁剧疆钀ょ煶闀滃ご閬斀寮�鍏�
+#define AOI_POST_EZ_UpdateAnswerStatus @"/home-wisdom/platform/yingshi/lock/updateAnswerStatus" // 鏇存敼闂ㄩ搩閫氳瘽鐘舵��(鎺ュ惉鍜屾湭鎺�)
+#define API_POST_EZ_GetAiSupportList @"/home-wisdom/platform/yingshi/getAiSupportList"//鑾峰彇鎽勫儚澶存櫤鑳界畻娉曞垪琛ㄥ拰鐘舵��
+#define API_POST_EZ_SetAiSupport @"/home-wisdom/platform/yingshi/setAiSupport"//璁剧疆鎽勫儚澶存櫤鑳界畻娉�
+
 #pragma mark APP_KEY
-#define APP_KEY @"HDL-HOME-APP-TEST"
-#define SECRET_KEY @"WeJ8TY88vbakCcnvH8G1tDUqzLWY8yss"
+#define APP_KEY @"QWERREWQ"
+#define SECRET_KEY @"CPBUCTRLCPBUABCD"
 
 
-#define TIME_OUT 15.0f
+#define TIME_OUT 30.0f
 
 @implementation EZHttpUtil
 
@@ -58,7 +64,7 @@
  *  @param block 鍥炶皟block
  */
 - (void)getChildToken:(void (^)(NSString *accessToken))block{
-    
+
     //2.璁剧疆璇锋眰鍙傛暟
     NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
     [parameters setValue: [NSString stringWithFormat:@"%d", [GlobalKit shareKit].hdlPlatform] forKey:@"platform"];
@@ -134,6 +140,21 @@
             if ([EZSDK sharedInstance].delegate&&[[EZSDK sharedInstance].delegate respondsToSelector:@selector(addDeviceSuccessed:)]) {
 //                HDLEZLog(@"娣诲姞璁惧璁惧鎴愬姛鍥炶皟:%@",parameters[@"deviceSerial"]);
                 [[EZSDK sharedInstance].delegate addDeviceSuccessed:parameters[@"deviceSerial"]];
+//
+//                //璁剧疆璁惧鍘绘帀楠岃瘉鐮�
+//                [EZOPENSDK setDeviceEncryptStatus:deviceSerial
+//                                       verifyCode:verifyCode
+//                                          encrypt:NO
+//                                       completion:^(NSError *error) {
+//                                            if (error)
+//                                            {
+//
+//                                            }
+//                                            else
+//                                            {
+//                                            }
+//
+//                }];
             }
         }
         
@@ -406,6 +427,136 @@
     }];
 }
 
+/**
+ *  @since 鑾峰彇闀滃ご闅愮閬斀鐘舵��
+ *  @param deviceSerial   璁惧搴忓垪鍙�
+ *  @param completion   鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔�
+ */
+- (void)getCoverSwitchStatus:(NSString *)deviceSerial
+                  completion:(void (^)(ResponseData *responseData))completion {
+    //璁剧疆璇锋眰鍙傛暟
+    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
+    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
+    [parameters setValue:@(1) forKey:@"platform"];
+    [parameters setValue:[NSString stringWithFormat:@"%@",[GlobalKit shareKit].hdlAppKey] forKey:@"appKey"];
+    [parameters setValue:@([[GlobalKit shareKit].hdlHomeId integerValue]) forKey:@"homeId"];
+    
+    parameters = [self GetSignRequestDictionary:parameters];
+    
+    NSLog(@"鑾峰彇璁惧娑堟伅鍙傛暟锛�%@",parameters);
+    
+    [self requestHttpsPost:API_POST_EZ_GetCoverSwitchStaus parameters:parameters completion:^(ResponseData *responseData) {
+        if (completion) {
+            completion (responseData);
+        }
+    }];
+}
+
+/**
+ *  @since 鏇存柊鎺ュ惉鐘舵��
+ *  @param msgId   娑堟伅id
+ *  @param answerStatus 鎺ュ惉鐘舵�侊紙answer 宸叉帴鍚�乶o_answer 鏈帴鍚級
+ *  @param completion   鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔�
+ */
+- (void)updateAnswerStatusWithMsgId:(NSString *)msgId
+                       answerStatus:(NSString *)answerStatus
+                  completion:(void (^)(ResponseData *responseData))completion {
+    //璁剧疆璇锋眰鍙傛暟
+    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
+    [parameters setValue:msgId forKey:@"msgId"];
+    [parameters setValue:answerStatus forKey:@"answerStatus"];
+    
+    parameters = [self GetSignRequestDictionary:parameters];
+    
+    [self requestHttpsPost:AOI_POST_EZ_UpdateAnswerStatus parameters:parameters completion:^(ResponseData *responseData) {
+        if (completion) {
+            completion (responseData);
+        }
+    }];
+}
+
+/**
+ *  @since 璁剧疆闀滃ご闅愮閬斀鐘舵��
+ *  @param deviceSerial   璁惧搴忓垪鍙�
+ *  @param enable   闅愮閬斀鐘舵��
+ *  @param completion   鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔�
+ */
+- (void)coverSwitchStatus:(NSString *)deviceSerial
+                      enable:(NSInteger)enable
+                  completion:(void (^)(ResponseData *responseData))completion {
+    //璁剧疆璇锋眰鍙傛暟
+    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
+    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
+    [parameters setValue:@(enable) forKey:@"enable"];
+    [parameters setValue:@(1) forKey:@"platform"];
+    [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_GetCoverSwitch parameters:parameters completion:^(ResponseData *responseData) {
+        if (completion) {
+            completion (responseData);
+        }
+    }];
+}
+
+/**
+ *  @since 鑾峰彇鎽勫儚澶存櫤鑳界畻娉曞垪琛ㄥ拰鐘舵��
+ *  @param deviceSerial   璁惧搴忓垪鍙�
+ *  @param completion   鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔�
+ */
+- (void)getAiSupportDetectionList:(NSString *)deviceSerial
+                       completion:(void (^)(ResponseData *responseData))completion {
+    //璁剧疆璇锋眰鍙傛暟
+    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
+    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
+//    [parameters setValue:@(1) forKey:@"platform"];
+//    [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_GetAiSupportList parameters:parameters completion:^(ResponseData *responseData) {
+        if (completion) {
+            completion (responseData);
+        }
+    }];
+}
+
+/**
+ *  @since 璁剧疆鎽勫儚澶存櫤鑳界畻娉�
+ *  @param deviceSerial   璁惧搴忓垪鍙�
+ *  @param code   鏅鸿兘绠楁硶缂栫爜
+ *  @param completion   鍥炶皟block锛宔rror涓虹┖鏃惰〃绀烘垚鍔�
+ */
+- (void)setAiSupportDetection:(NSString *)deviceSerial
+                     code:(NSString *)code
+                  completion:(void (^)(ResponseData *responseData))completion {
+    //璁剧疆璇锋眰鍙傛暟
+    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
+    [parameters setValue:deviceSerial forKey:@"deviceSerial"];
+    [parameters setValue:code forKey:@"code"];
+//    [parameters setValue:@(1) forKey:@"platform"];
+//    [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_SetAiSupport parameters:parameters completion:^(ResponseData *responseData) {
+        if (completion) {
+            completion (responseData);
+        }
+    }];
+}
+
+
 /// 鍒锋柊token
 /// @param block 缁撴灉
 - (void)refreshHDLToken:(void (^)(BOOL isSuccess))block{
@@ -486,6 +637,7 @@
         URL = TestRequestHttpsHost;
     }
     URL = [NSString stringWithFormat:@"%@%@", URL, apiPath];
+    NSLog(@"############鎺ュ彛璇锋眰url锛�%@", URL);
     
 //    NSURLSessionDataTask * task=nil;
     AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
@@ -533,6 +685,7 @@
     UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000;
     [params setValue:APP_KEY forKey:@"appKey"];
     [params setValue:[NSString stringWithFormat:@"%llu",recordTime] forKey:@"timestamp"];
+    NSLog(@"##########APPKEY:%@, SECRET_KEY:%@", APP_KEY, SECRET_KEY);
     //1.瀵筀EY鍗囧簭
     NSArray *keyArray = [params allKeys];
     NSArray *sortKeyArray = [keyArray sortedArrayUsingComparator:^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {

--
Gitblit v1.8.0