Beispiel #1
0
        public async Task <Result <bool> > GetAndSetConfigurationOnPreferences()
        {
            try
            {
                var url = URLHelper.MakeURL(ServicesResource.BaseURL, ServicesResource.Configurations, ServicesResource.API_KEY);

                var result = await _connector.GetJson(url);

                if (!result.IsValid)
                {
                    return(ResultHelper.MakeErrorMessage(result.HttpStatusCode, result.Message, false));
                }

                var configurations = JsonConvert.DeserializeObject <ConfigurationModel>(result.Content);

                MyPreferences.ImageBaseUrl      = configurations.Images.SecureBaseUrl;
                MyPreferences.PosterImageSize   = configurations.Images.PosterSizes?[2];
                MyPreferences.BackdropImageSize = configurations.Images.BackdropSizes?[1];

                return(ResultHelper.MakeResponseContentMessage(true));
            }
            catch (Exception e)
            {
                return(ResultHelper.MakeExceptionMessage <bool>(e));
            }
        }
Beispiel #2
0
        public void ServiceConnectionTest()
        {
            var url = string.Concat(Constants.ApiBaseURL, Constants.ImageConfigurationsResource);

            url = string.Format(url, Constants.API_KEY);
            var result = _connector.GetJson(url).Result;

            Assert.AreEqual(result.IsValid, true);
        }
Beispiel #3
0
        public void GetConfigurationTest()
        {
            var url = string.Concat(Constants.ApiBaseURL, Constants.ImageConfigurationsResource);

            url = string.Format(url, Constants.API_KEY);
            var result = _connector.GetJson(url).Result;

            if (result.IsValid)
            {
                var configurationModel = JsonConvert.DeserializeObject <ConfigurationModel>(result.Content);
                Assert.AreEqual(configurationModel.GetType(), typeof(ConfigurationModel));
            }
            if (result.HttpStatusCode is (int)HttpStatusCode.Unauthorized ||
                result.HttpStatusCode is (int)HttpStatusCode.NotFound)
            {
                var errorModel = JsonConvert.DeserializeObject <ErrorModel>(result.Content);
                Assert.AreEqual(errorModel.GetType(), typeof(ErrorModel));
            }
        }