Esempio n. 1
0
        public ApiInteractor(HttpClient client, ApiCredentials apiCredentials)
        {
            ApiCredentials = apiCredentials;

            if (!ApiCredentials.IsValid)
            {
                throw new Exceptions.ApiCredentialException(
                          "Invalid ApiCredentials, please set credentials in configfile. See Inner Exception for details",
                          new FormatException(String.Join(", ", ApiCredentials.GetValidationErrors().ToArray()))
                          );
            }

            Client             = client;
            Client.BaseAddress = new Uri(ApiCredentials.ApiUrl);
            Client.DefaultRequestHeaders.Accept.Clear();
            Client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json")
                );
            Client.DefaultRequestHeaders.AcceptLanguage.Add(
                new StringWithQualityHeaderValue("en-US")
                );
        }