Exemplo n.º 1
0
        public async Task Logout()
        {
            try
            {
                var client = WebRequestHelper.GetClient();

                var response = await client.GetAsync(URLs.Logout());

                response.EnsureSuccessStatusCode();

                WebRequestHelper.ClearCookies();
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task DeleteClip(int id)
        {
            Logger.Log("DeleteClip: Creating client...");
            using (var c = WebRequestHelper.GetClient())
            {
                try
                {
                    Logger.Log("GetClips: Requesting delete...");
                    var response = await c.DeleteAsync(URLs.GetClip(id));

                    response.EnsureSuccessStatusCode();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    throw;
                }
            }
        }
Exemplo n.º 3
0
        public async Task <byte[]> GetCameraImage(CameraInformation cameraInformation)
        {
            try
            {
                var url = URLs.GetImage(cameraInformation);

                Logger.Log("GetCameraImage: Creating Client...");
                var client = WebRequestHelper.GetClient();

                Logger.Log("GetCameraImage: Getting response...");
                var response = await client.GetAsync(url);

                response.EnsureSuccessStatusCode();

                Logger.Log("GetCameraImage: Getting body...");
                return(await response.Content.ReadAsByteArrayAsync());
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
                throw;
            }
        }
Exemplo n.º 4
0
        public async Task <ClipInfo> GetClipInfo(int id)
        {
            Logger.Log("GetClipInfo: Creating client...");
            using (var c = WebRequestHelper.GetClient())
            {
                try
                {
                    Logger.Log("GetClipInfo: Making request...");
                    var response = await c.GetAsync(URLs.GetClip(id));

                    response.EnsureSuccessStatusCode();
                    var responseBody = await response.Content.ReadAsStringAsync();

                    Logger.Log("GetClipInfo: Deserializing...");
                    var item = JsonConvert.DeserializeObject <ClipInfo[]>(responseBody);
                    return(item.FirstOrDefault());
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                    throw;
                }
            }
        }