public static async Task <T> ExecuteGet <T>(RestRequest request) where T : new() { request.Method = Method.GET; request.AddParameter("Content-Type", "application/json", ParameterType.HttpHeader); if (AppUtility.IsConnectedToInternet()) { try { PrintRequest(request); var response = await _restClient.Execute(request); switch (response.StatusCode) { case HttpStatusCode.OK: { JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; PrintResponce(response.Content); var result = JsonConvert.DeserializeObject <BaseResponse>(response.Content, settings); if (result.Code == 401) { UserDialogs.Instance.Alert(response.StatusDescription + " " + response.StatusCode); } return(JsonConvert.DeserializeObject <T>(response.Content, settings)); } case HttpStatusCode.Gone: { UserDialogs.Instance.Alert(response.StatusDescription + " " + response.StatusCode); } break; case HttpStatusCode.Unauthorized: { UserDialogs.Instance.Alert(response.StatusDescription + " " + ""); } break; case HttpStatusCode.InternalServerError: { UserDialogs.Instance.Alert(response.StatusDescription); } break; case HttpStatusCode.BadRequest: { return(JsonConvert.DeserializeObject <T>(response.Content)); } case HttpStatusCode.NotFound: { } break; case HttpStatusCode.RequestTimeout: { UserDialogs.Instance.Alert(response.StatusDescription + " " + response.StatusCode); } break; } } catch (WebException ex) { UserDialogs.Instance.Alert(ex.Message, null, AppResources.Lbl_OK); } catch (Exception ex) { UserDialogs.Instance.Alert(ex.Message, null, AppResources.Lbl_OK); } } else { UserDialogs.Instance.Alert(AppResources.Lbl_NoInternet, null, AppResources.Lbl_OK); } return(default(T)); }