Exemplo n.º 1
0
        public async Task GetRecordingsForUserAsync()
        {
            // Arrange
            var userId         = "uET9c2fCR06UoPbeqKed4A";
            var from           = new DateTime(2021, 2, 10, 0, 0, 0, DateTimeKind.Utc);
            var to             = new DateTime(2021, 2, 11, 0, 0, 0, DateTimeKind.Utc);
            var recordsPerPage = 30;

            var mockHttp = new MockHttpMessageHandler();

            mockHttp.Expect(HttpMethod.Get, Utils.GetZoomApiUri("users", userId, "recordings")).Respond("application/json", MULTIPLE_CLOUD_RECORDINGS_JSON);

            var client     = Utils.GetFluentClient(mockHttp);
            var recordings = new CloudRecordings(client);

            // Act
            var result = await recordings.GetRecordingsForUserAsync(userId, false, from, to, recordsPerPage, null, CancellationToken.None).ConfigureAwait(false);

            // Assert
            mockHttp.VerifyNoOutstandingExpectation();
            mockHttp.VerifyNoOutstandingRequest();
            result.ShouldNotBeNull();
            result.PageSize.ShouldBe(recordsPerPage);
            result.NextPageToken.ShouldBeEmpty();
            result.MoreRecordsAvailable.ShouldBeFalse();
            result.TotalRecords.ShouldBe(10);
            result.From.ShouldBe(from);
            result.To.ShouldBe(to);
            result.Records.ShouldNotBeNull();
            result.Records.Length.ShouldBe(10);
        }
Exemplo n.º 2
0
        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);
        }