private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient, ZoomClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient; var options1 = options ?? GetDefaultOptions(); _fluentClient = new FluentClient(new Uri(ZoomV2BaseUri), httpClient) .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)"); _fluentClient.Filters.Remove <DefaultErrorFilter>(); switch (connectionInfo) { // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler. case JwtConnectionInfo jwtConnectionInfo: { var tokenHandler = new JwtTokenHandler(jwtConnectionInfo); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); break; } case OAuthConnectionInfo oauthConnectionInfo: { var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); break; } default: throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null); } // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(options1.LogLevelSuccessfulCalls, options1.LogLevelFailedCalls)); _fluentClient.Filters.Add(new ZoomErrorHandler()); Meetings = new Meetings(_fluentClient); PastMeetings = new PastMeetings(_fluentClient); PastWebinars = new PastWebinars(_fluentClient); Users = new Users(_fluentClient); Webinars = new Webinars(_fluentClient); }
private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient, ZoomClientOptions options, ILogger logger = null) { _mustDisposeHttpClient = disposeClient; _httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient)); _options = options ?? GetDefaultOptions(); _logger = logger ?? NullLogger.Instance; _fluentClient = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpClient) .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)"); _fluentClient.Filters.Remove <DefaultErrorFilter>(); // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler. if (connectionInfo is JwtConnectionInfo jwtConnectionInfo) { var tokenHandler = new JwtTokenHandler(jwtConnectionInfo); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); } else if (connectionInfo is OAuthConnectionInfo oauthConnectionInfo) { var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient); _fluentClient.Filters.Add(tokenHandler); _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler)); } else { throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null, null, null); } // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project. _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger)); _fluentClient.Filters.Add(new ZoomErrorHandler()); Accounts = new Accounts(_fluentClient); Chat = new Chat(_fluentClient); CloudRecordings = new CloudRecordings(_fluentClient); Contacts = new Contacts(_fluentClient); DataCompliance = new DataCompliance(_fluentClient); Meetings = new Meetings(_fluentClient); PastMeetings = new PastMeetings(_fluentClient); PastWebinars = new PastWebinars(_fluentClient); Users = new Users(_fluentClient); Webinars = new Webinars(_fluentClient); Dashboards = new Dashboards(_fluentClient); }