Beispiel #1
0
        private static WebApiAdvancedResponse <TContent, TErrorContent> WrapAdvancedRestResponse <TContent, TErrorContent>(RestClient client, RestRequest request, IRestResponse response)
        {
            WebApiAdvancedResponse <TContent, TErrorContent> result = new WebApiAdvancedResponse <TContent, TErrorContent>();

            Uri requestUri = client.BuildUri(request);

            if (response.IsSuccessful)
            {
                result.Successful = true;
                result.Content    = ParseRestResponse <TContent>(client, response);
            }
            else if (response.ErrorException != null)
            {
                Log.Error("Network/framework exception on REST request '{0}'", requestUri);
                Log.Ex(response.ErrorException);
                result.ErrorException = response.ErrorException;
            }
            else
            {
                Log.Error("Error {1} ({2}) on REST request '{0}'", requestUri, (int)response.StatusCode, response.StatusDescription);
                result.ErrorStatusCode = response.StatusCode;
                result.ErrorContent    = ParseRestResponse <TErrorContent>(client, response);
            }
            return(result);
        }
Beispiel #2
0
        public static CheckForUpdatesResponse CheckForUpdates(string sdkTableRevision)
        {
            CheckForUpdatesRequest dto = new CheckForUpdatesRequest
            {
                CurrentVersion   = Assembly.GetEntryAssembly().GetProductVersion(),
                OS               = Utilities.OperatingSystem.IsMacOS() ? 1 : 0,
                Is64BitOS        = Utilities.OperatingSystem.Is64Bit,
                SdkTableRevision = sdkTableRevision
            };

            RestClient client = new RestClient(VersionBaseUri);

            RestRequest request = new RestRequest("check-updates", Method.POST);

            request.AddJsonBody(dto);

            WebApiAdvancedResponse <CheckForUpdatesResponse, ApiError> response = MakeRequest <CheckForUpdatesResponse, ApiError>(client, request);

            ThrowIfNotSuccessful(response);
            return(response.Content);
        }