Exemplo n.º 1
0
 private HotelApiClient(HotelApiVersion version, string apiKey, string sharedSecret, Boolean validate)
 {
     this.timeout      = GetTimeoutFromConfig();
     this.apiKey       = apiKey;
     this.sharedSecret = sharedSecret;
     this.version      = version;
     config.Environment currentEnvironment = GetEnvironment();
     if (currentEnvironment != null)
     {
         this.basePath       = currentEnvironment.BaseUrl;
         this.baseSecurePath = (currentEnvironment.BaseSecureUrl != null) ? currentEnvironment.BaseSecureUrl : currentEnvironment.BaseUrl;
     }
     if (validate)
     {
         CheckHotelApiClientConfig();
     }
 }
Exemplo n.º 2
0
 private config.Environment GetEnvironment()
 {
     try
     {
         config.Environment returnValue     = null;
         String             environmentName = ConfigurationManager.AppSettings.Get("ENVIRONMENT");
         if (!String.IsNullOrEmpty(environmentName))
         {
             EnvironmentsSection       environmentsSection = (EnvironmentsSection)ConfigurationManager.GetSection("environments");
             List <config.Environment> environments        = new List <config.Environment>(environmentsSection.Environments);
             returnValue = environments.Find(x => x.Name == environmentName);
         }
         return(returnValue);
     } catch (Exception e)
     {
         throw e;
     }
 }