New file |
| | |
| | | using System.Collections.Generic; |
| | | using SiriKit; |
| | | |
| | | namespace SiriIntents.Server |
| | | { |
| | | public class HttpServerRequest |
| | | { |
| | | static HttpServerRequest _httpServerRequest; |
| | | public static HttpServerRequest Ins { |
| | | get |
| | | { |
| | | if(_httpServerRequest == null) |
| | | { |
| | | _httpServerRequest = new HttpServerRequest(); |
| | | } |
| | | return _httpServerRequest; |
| | | } |
| | | } |
| | | SceneDateManager _dateManager; |
| | | public SceneDateManager DataManager { |
| | | get |
| | | { |
| | | if(_dateManager== null) |
| | | { |
| | | _dateManager = new SceneDateManager(); |
| | | } |
| | | return _dateManager; |
| | | } |
| | | } |
| | | |
| | | #region ■ 通用请求接口_______________________ |
| | | /// <summary> |
| | | /// 根椐用户账号获取注册区域 免登录 // 检测账号是否注册也用这个接口 |
| | | /// </summary> |
| | | /// <param name="account"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetRegionByAccount(string account) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RegionByAccountObj() { account = account }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson, HttpUtil.GlobalRequestHttpsHost); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新Token |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string RefreshToken() |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj() |
| | | { |
| | | refreshToken = DataManager.RefreshToken, |
| | | }); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Login, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(revertObj.Data.ToString()); |
| | | DataManager.RefreshToken = revertData.refreshToken; |
| | | DataManager.AccessToken = revertData.headerPrefix + revertData.accessToken; |
| | | } |
| | | return revertObj.Code; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 执行场景 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string ExecuteScene(string userSceneId) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DataManager.HomeId); |
| | | d.Add("userSceneIds", new List<string>() { userSceneId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome( |
| | | NewAPI.Api_Post_ExecuteSecne, requestJson).Code; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设置安防防区状态 |
| | | /// </summary> |
| | | public string SetSecurityStatus(object securityStates) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DataManager.HomeId); |
| | | d.Add("securitys", securityStates); |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome( |
| | | NewAPI.Api_Post_Security_StatusSet, requestJson); |
| | | return pack.Code; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |