//First thing you need to do before anything else will work. public void LogIn() { try { MyHttpsClientRequest LogIn = new MyHttpsClientRequest(URL, "login", LogInAuthHeader, AuthToken); LogIn.RequestType = RequestType.Get; HttpsClientResponse LogInResponse; LogInResponse = MyClient.Dispatch(LogIn); _Response = LogInResponse.ContentString; } catch (HttpsException e) { CrestronConsole.PrintLine("HTTPS Exception: {0}\n", e.Message); } catch (HttpsHeaderException e) { CrestronConsole.PrintLine("Header Execption: {0}\n", e.Message); } catch (HttpsRequestInvalidException e) { CrestronConsole.PrintLine("HTTPS Request Exception: {0}\n", e.Message); } sAuthKey = ParseForKey(); /*The Document says to make these two requests before any other calls * so here they are and they are then parsed into classes for easy access*/ try { MyHttpsClientRequest RequestRooms = new MyHttpsClientRequest(URL, "rooms", AuthHeader, sAuthKey); RequestRooms.RequestType = RequestType.Get; HttpsClientResponse RoomsResponse; RoomsResponse = MyClient.Dispatch(RequestRooms); _Rooms = RoomsResponse.ContentString; MyHttpsClientRequest RequestDevices = new MyHttpsClientRequest(URL, "devices", AuthHeader, sAuthKey); RequestDevices.RequestType = RequestType.Get; HttpsClientResponse DevicesResponse; DevicesResponse = MyClient.Dispatch(RequestDevices); _Devices = DevicesResponse.ContentString; } catch (HttpsException e) { CrestronConsole.PrintLine("HTTPS Exception: {0}\n", e.Message); } catch (HttpsHeaderException e) { CrestronConsole.PrintLine("Header Execption: {0}\n", e.Message); } catch (HttpsRequestInvalidException e) { CrestronConsole.PrintLine("HTTPS Request Exception: {0}\n", e.Message); } SerilizeFunction(); }
/*This Method will set the LIGHT at _id to any level between 0-65535 in 100 miliseconds * _id can be found in the _Devices print out. These IDs can be parsed out with this Library but * an example is not provided*/ public void LightsExample(ushort _id, ushort level) { string _Post = "{\"lights\": [ { \"" + _id + "\": 01 , \"level\": " + level + ", \"time\": 100}]}"; CrestronConsole.PrintLine(_Post); MyHttpsClientRequest LightRequest = new MyHttpsClientRequest(URL, Path, AuthHeader, sAuthKey); LightRequest.RequestType = RequestType.Post; LightRequest.ContentString = _Post; try { HttpsClientResponse PostResponse = MyClient.Dispatch(LightRequest); } catch (HttpsException e) { CrestronConsole.PrintLine("Post error: {0}\n", e.Message); } }