示例#1
0
        public ZoomClient(ZoomClientOptions options)
        {
            if (options == null)
            {
                throw new Exception("No options provided for zoom client");
            }

            if (string.IsNullOrWhiteSpace(options.ZoomApiKey))
            {
                throw new Exception("No api key provided for zoom client");
            }

            if (string.IsNullOrWhiteSpace(options.ZoomApiSecret))
            {
                throw new Exception("No api secret provided for zoom client");
            }

            Options = options;
            if (string.IsNullOrWhiteSpace(Options.ZoomApiBaseUrl))
            {
                Options.ZoomApiBaseUrl = BASE_URL;
            }

            WebClient = new RestClient(options.ZoomApiBaseUrl);

            Groups   = new ZoomGroupsClient(Options, WebClient);
            Meetings = new ZoomMeetingsClient(Options, WebClient);
            Reports  = new ZoomReportsClient(Options, WebClient);
            Users    = new ZoomUsersClient(Options, WebClient);
            Webhooks = new ZoomWebhookClient(Options, WebClient);
        }
示例#2
0
文件: Program.cs 项目: np-at/zswap
        private static ZoomClient CreateZoomClient(string zoomApiSecret, string zoomApiKey)
        {
            var options = new ZoomClientOptions
            {
                ZoomApiKey    = zoomApiKey,
                ZoomApiSecret = zoomApiSecret,
            };

            return(new ZoomClient(options));
        }
示例#3
0
        private static void Inicializar()
        {
            var options = new ZoomClientOptions
            {
                ZoomApiKey    = "TyDrLX_3Q9OyK9fl-A1jbw",
                ZoomApiSecret = "7TiT3Vks7lOMG9ganb5itofyCbO1IphSezm0"
            };

            ZoomClient = new AndcultureCode.ZoomClient.ZoomClient(options);
        }
        public MeetingResponse Meeting([FromQuery] MeetingRequest request)
        {
            MeetingResponse output = new MeetingResponse()
            {
                Messages = new List <string>()
            };

            var options = new ZoomClientOptions
            {
                ZoomApiKey    = "TODO - SET THIS",
                ZoomApiSecret = "TODO - SET THIS"
            };

            //if (string.IsNullOrWhiteSpace(request.MeetingNumber))
            //{
            //	var client = new ZoomClient(options);
            //	var allUsers = client.Users.GetUsers(UserStatuses.Active, 30, 1);

            //	var user = allUsers.Users.Single(u => u.Email == "*****@*****.**");

            //	output.Messages.Add("Found User: "******" (" + user.FirstName + " " + user.LastName + ") - " + user.Email);

            //	var meeting = client.Meetings.CreateMeeting(user.Id, new AndcultureCode.ZoomClient.Models.Meetings.Meeting()
            //	{
            //		Topic = "string",
            //		Type = AndcultureCode.ZoomClient.Models.Meetings.MeetingTypes.Scheduled,
            //		StartTime = DateTime.Now,
            //		Duration = 30,
            //		Timezone = "America/Los_Angeles",
            //		Password = "",
            //		Agenda = "What is an agenda?",
            //		Recurrence = null,
            //		Settings = new AndcultureCode.ZoomClient.Models.Meetings.MeetingSettings() { EnableJoinBeforeHost = true }
            //	});

            //	request.MeetingNumber = meeting.Id;
            //}

            int    meetingNumber = request.MeetingNumber;
            string ts            = ToTimestamp(DateTime.UtcNow.ToUniversalTime()).ToString();
            int    role          = request.Role;
            string token         = GenerateToken(options.ZoomApiKey, options.ZoomApiSecret, meetingNumber, ts, role);

            output.ZoomToken     = token;
            output.MeetingNumber = request.MeetingNumber;
            output.ApiSecret     = options.ZoomApiSecret;
            output.ApiKey        = options.ZoomApiKey;

            return(output);
        }
示例#5
0
        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);
        }
示例#6
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);
        }
示例#7
0
        public ZoomClient(ZoomClientOptions options)
        {
            if (options == null)
            {
                throw new Exception("No options provided for zoom client");
            }

            if (string.IsNullOrWhiteSpace(options.ZoomApiKey))
            {
                throw new Exception("No api key provided for zoom client");
            }

            if (string.IsNullOrWhiteSpace(options.ZoomApiSecret))
            {
                throw new Exception("No api secret provided for zoom client");
            }

            Options = options;
            if (string.IsNullOrWhiteSpace(Options.ZoomApiBaseUrl))
            {
                Options.ZoomApiBaseUrl = BASE_URL;
            }

            WebClient = new RestClient(options.ZoomApiBaseUrl);

            // Override with Newtonsoft JSON Handler
            WebClient.AddHandler("application/json", () => NewtonsoftJsonSerializer.Default);
            WebClient.AddHandler("text/json", () => NewtonsoftJsonSerializer.Default);
            WebClient.AddHandler("text/x-json", () => NewtonsoftJsonSerializer.Default);
            WebClient.AddHandler("text/javascript", () => NewtonsoftJsonSerializer.Default);
            WebClient.AddHandler("*+json", () => NewtonsoftJsonSerializer.Default);

            Groups   = new ZoomGroupsClient(Options, WebClient);
            Meetings = new ZoomMeetingsClient(Options, WebClient);
            Reports  = new ZoomReportsClient(Options, WebClient);
            Users    = new ZoomUsersClient(Options, WebClient);
            Webhooks = new ZoomWebhookClient(Options, WebClient);
        }
 internal ZoomWebhookClient(ZoomClientOptions options, RestClient webClient)
 {
     Options   = options;
     WebClient = webClient;
 }
        public static RestRequest BuildRequestAuthorization(this RestClient webClient, ZoomClientOptions options, string resource, Method method)
        {
            var request = new RestRequest(resource, method);

            /*var payload = new Dictionary<string, object>()
             * {
             *  { "iss", options.ZoomApiKey },
             *  { "exp", new DateTimeOffset(DateTime.UtcNow.AddMinutes(1)).ToUnixTimeSeconds() }
             * };
             *
             * webClient.Authenticator = new JwtAuthenticator(JWT.Encode(payload, Encoding.UTF8.GetBytes(options.ZoomApiSecret), JwsAlgorithm.HS256));
             */
            webClient.Authenticator = new JwtAuthenticator(ZoomHandler.GetToken());
            request.JsonSerializer  = new NewtonsoftJsonSerializer();



            return(request);
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomClient"/> class with a specific http client.
 /// </summary>
 /// <param name="connectionInfo">Connection information.</param>
 /// <param name="httpClient">Allows you to inject your own HttpClient. This is useful, for example, to setup the HtppClient with a proxy.</param>
 /// <param name="options">Options for the Zoom client.</param>
 /// <param name="logger">Logger.</param>
 public ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, ZoomClientOptions options = null, ILogger logger = null)
     : this(connectionInfo, httpClient, false, options, logger)
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomClient"/> class with a specific handler.
 /// </summary>
 /// <param name="connectionInfo">Connection information.</param>
 /// <param name="handler">TThe HTTP handler stack to use for sending requests.</param>
 /// <param name="options">Options for the Zoom client.</param>
 /// <param name="logger">Logger.</param>
 public ZoomClient(IConnectionInfo connectionInfo, HttpMessageHandler handler, ZoomClientOptions options = null, ILogger logger = null)
     : this(connectionInfo, new HttpClient(handler), true, options, logger)
 {
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomClient"/> class with a specific proxy.
 /// </summary>
 /// <param name="connectionInfo">Connection information.</param>
 /// <param name="proxy">Allows you to specify a proxy.</param>
 /// <param name="options">Options for the Zoom client.</param>
 /// <param name="logger">Logger.</param>
 public ZoomClient(IConnectionInfo connectionInfo, IWebProxy proxy, ZoomClientOptions options = null, ILogger logger = null)
     : this(connectionInfo, new HttpClient(new HttpClientHandler { Proxy = proxy, UseProxy = proxy != null }), true, options, logger)
 {
 }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZoomClient"/> class.
 /// </summary>
 /// <param name="connectionInfo">Connection information.</param>
 /// <param name="options">Options for the Zoom client.</param>
 /// <param name="logger">Logger.</param>
 public ZoomClient(IConnectionInfo connectionInfo, ZoomClientOptions options = null, ILogger logger = null)
     : this(connectionInfo, new HttpClient(), true, options, logger)
 {
 }
示例#14
0
 internal ZoomUsersClient(ZoomClientOptions options, RestClient webClient)
 {
     Options   = options;
     WebClient = webClient;
 }
 internal ZoomMeetingsClient(ZoomClientOptions options, RestClient webClient)
 {
     Options   = options;
     WebClient = webClient;
 }