예제 #1
0
        public async Task <LoginResponse> LoginAsync(LoginRequest connexion)
        {
            try
            {
                if (!string.IsNullOrEmpty(UserProperties.GetApiKey()) && !client.DefaultRequestHeaders.Contains("X-Api-Key"))
                {
                    client.DefaultRequestHeaders.Add("X-Api-Key", UserProperties.GetApiKey());
                }

                var uri = new Uri(string.Format(Constants.BASE_URL + UserProperties.GetLocalIP() + Constants.API_LOGIN, string.Empty));

                var json    = JsonConvert.SerializeObject(connexion);
                var payload = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(uri, payload);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    var result = JsonConvert.DeserializeObject <LoginResponse>(content);
                    return(result);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            return(null);
        }
예제 #2
0
 public OctoService()
 {
     client = new HttpClient();
     //client.MaxResponseContentBufferSize = 256000;
     if (!string.IsNullOrEmpty(UserProperties.GetApiKey()))
     {
         client.DefaultRequestHeaders.Add("X-Api-Key", UserProperties.GetApiKey());
     }
 }
예제 #3
0
 public async override void ViewAppeared()
 {
     base.ViewAppeared();
     if (!string.IsNullOrEmpty(UserProperties.GetLocalIP()) && !string.IsNullOrEmpty(UserProperties.GetApiKey()))
     {
         await _navigationService.Navigate <MainViewModel>();
     }
 }