예제 #1
0
 public ApiController(string apiVersion, IndividualApiConfig apiConfig = null)
 {
     this.apiVersion = apiVersion;
     this._apiConfig = apiConfig;
     this.CheckState();
     this.hostUrl = _apiConfig?.GetLiveUrl() ?? ApiConfig.GetLiveUrl();
     if (_apiConfig?.IsSandbox() ?? ApiConfig.IsSandbox())
     {
         this.hostUrl = _apiConfig?.GetSandboxUrl() ?? ApiConfig.GetSandboxUrl();
     }
 }
예제 #2
0
 private void CheckState()
 {
     if ((_apiConfig?.GetAuthentication() ?? ApiConfig.GetAuthentication()) == null)
     {
         throw new InvalidOperationException("No ApiConfig.authentication has been configured");
     }
     try {
         new Uri(_apiConfig?.GetLiveUrl() ?? ApiConfig.GetLiveUrl());
     } catch (UriFormatException innerException) {
         throw new InvalidOperationException("Invalid URL supplied for API_BASE_LIVE_URL", innerException);
     }
     try {
         new Uri(_apiConfig?.GetSandboxUrl() ?? ApiConfig.GetSandboxUrl());
     } catch (UriFormatException innerException2) {
         throw new InvalidOperationException("Invalid URL supplied for API_BASE_SANDBOX_URL", innerException2);
     }
 }