示例#1
0
        /// <summary>
        /// Creates an Instance of the Helix Class.
        /// </summary>
        /// <param name="loggerFactory">Instance Of LoggerFactory, otherwise no logging is used, </param>
        /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used.</param>
        /// <param name="settings">Instance of ApiSettings, otherwise defaults used, can be changed later</param>
        /// <param name="http">Instance of HttpCallHandler, otherwise default handler used</param>
        public Helix(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IApiSettings settings = null, IHttpCallHandler http = null)
        {
            _logger     = loggerFactory?.CreateLogger <Helix>();
            rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
            http        = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
            Settings    = settings ?? new ApiSettings();

            Analytics     = new Analytics(Settings, rateLimiter, http);
            Ads           = new Ads(Settings, rateLimiter, http);
            Bits          = new Bits(Settings, rateLimiter, http);
            Chat          = new Chat(Settings, rateLimiter, http);
            Channels      = new Channels(Settings, rateLimiter, http);
            ChannelPoints = new ChannelPoints(Settings, rateLimiter, http);
            Clips         = new Clips(Settings, rateLimiter, http);
            Entitlements  = new Entitlements(Settings, rateLimiter, http);
            EventSub      = new EventSub(Settings, rateLimiter, http);
            Extensions    = new Extensions(Settings, rateLimiter, http);
            Games         = new Games(Settings, rateLimiter, http);
            HypeTrain     = new HypeTrain(Settings, rateLimiter, http);
            Moderation    = new Moderation(Settings, rateLimiter, http);
            Polls         = new Polls(Settings, rateLimiter, http);
            Predictions   = new Predictions(Settings, rateLimiter, http);
            Schedule      = new Schedule(Settings, rateLimiter, http);
            Search        = new Search(Settings, rateLimiter, http);
            Streams       = new Streams(Settings, rateLimiter, http);
            Subscriptions = new Subscriptions(Settings, rateLimiter, http);
            Tags          = new Tags(Settings, rateLimiter, http);
            Teams         = new Teams(Settings, rateLimiter, http);
            Users         = new Users(Settings, rateLimiter, http);
            Videos        = new Videos(Settings, rateLimiter, http);
            Webhooks      = new Webhooks(Settings, rateLimiter, http);
        }
示例#2
0
 /// <summary>
 /// Creates an Instance of the TwitchAPI Class.
 /// </summary>
 /// <param name="logger">Instance Of Logger, otherwise no logging is used,  </param>
 /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param>
 public TwitchAPI(ILogger <TwitchAPI> logger = null, IRateLimiter rateLimiter = null)
 {
     _logger         = logger;
     _http           = new HttpClient(new TwitchLibCustomHttpMessageHandler(new HttpClientHandler(), _logger));
     _rateLimiter    = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
     Auth            = new Auth(this);
     Blocks          = new Blocks(this);
     Badges          = new Badges(this);
     Bits            = new Bits(this);
     ChannelFeeds    = new ChannelFeeds(this);
     Channels        = new Channels(this);
     Chat            = new Chat(this);
     Clips           = new Clips(this);
     Collections     = new Collections(this);
     Communities     = new Communities(this);
     Follows         = new Follows(this);
     Games           = new Games(this);
     Ingests         = new Ingests(this);
     Root            = new Root(this);
     Search          = new Search(this);
     Streams         = new Streams(this);
     Subscriptions   = new Subscriptions(this);
     Teams           = new Teams(this);
     ThirdParty      = new ThirdParty(this);
     Undocumented    = new Undocumented(this);
     Users           = new Users(this);
     Videos          = new Videos(this);
     Webhooks        = new Webhooks(this);
     Debugging       = new Debugging();
     Settings        = new ApiSettings(this);
     _jsonSerializer = new TwitchLibJsonSerializer();
 }
示例#3
0
 /// <summary>
 /// Creates an Instance of the TwitchAPI Class.
 /// </summary>
 /// <param name="logger">Instance Of Logger, otherwise no logging is used,  </param>
 /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used. </param>
 public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IHttpCallHandler http = null)
 {
     _logger         = loggerFactory?.CreateLogger <TwitchAPI>();
     _http           = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
     _rateLimiter    = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
     Analytics       = new Analytics(this);
     Auth            = new Auth(this);
     Badges          = new Badges(this);
     Bits            = new Bits(this);
     ChannelFeeds    = new ChannelFeeds(this);
     Channels        = new Channels(this);
     Chat            = new Chat(this);
     Clips           = new Clips(this);
     Collections     = new Collections(this);
     Communities     = new Communities(this);
     Entitlements    = new Entitlements(this);
     Games           = new Games(this);
     Ingests         = new Ingests(this);
     Root            = new Root(this);
     Search          = new Search(this);
     Streams         = new Streams(this);
     Teams           = new Teams(this);
     ThirdParty      = new ThirdParty(this);
     Undocumented    = new Undocumented(this);
     Users           = new Users(this);
     Videos          = new Videos(this);
     Webhooks        = new Webhooks(this);
     Debugging       = new Debugging();
     Settings        = new ApiSettings(this);
     _jsonSerializer = new TwitchLibJsonSerializer();
 }
示例#4
0
        /// <summary>
        /// Creates an Instance of the TwitchAPI Class.
        /// </summary>
        /// <param name="loggerFactory">Instance Of LoggerFactory, otherwise no logging is used, </param>
        /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used.</param>
        /// <param name="settings">Instance of ApiSettings, otherwise defaults used, can be changed later</param>
        /// <param name="http">Instance of HttpCallHandler, otherwise default handler used</param>
        public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IApiSettings settings = null, IHttpCallHandler http = null)
        {
            _logger = loggerFactory?.CreateLogger <TwitchAPI>();
            var _rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
            var _http        = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());

            Settings = settings ?? new ApiSettings();

            Helix        = new Helix.Helix(loggerFactory, rateLimiter, Settings, _http);
            V5           = new V5.V5(loggerFactory, _rateLimiter, Settings, _http);
            ThirdParty   = new ThirdParty.ThirdParty(Settings, _rateLimiter, _http);
            Undocumented = new Undocumented(Settings, _rateLimiter, _http);
        }
示例#5
0
        /// <summary>
        /// Creates an Instance of the TwitchAPI Class.
        /// </summary>
        /// <param name="loggerFactory">Instance Of LoggerFactory, otherwise no logging is used, </param>
        /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used.</param>
        /// <param name="settings">Instance of ApiSettings, otherwise defaults used, can be changed later</param>
        /// <param name="http">Instance of HttpCallHandler, otherwise default handler used</param>
        public TwitchAPI(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IApiSettings settings = null, IHttpCallHandler http = null)
        {
            _logger     = loggerFactory?.CreateLogger <TwitchAPI>();
            rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
            http        = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
            Settings    = settings ?? new ApiSettings();

            Auth         = new Auth.Auth(Settings, rateLimiter, http);
            Helix        = new Helix.Helix(loggerFactory, rateLimiter, Settings, http);
            ThirdParty   = new ThirdParty.ThirdParty(Settings, rateLimiter, http);
            Undocumented = new Undocumented(Settings, rateLimiter, http);

            Settings.PropertyChanged += SettingsPropertyChanged;
        }
示例#6
0
        /// <summary>
        /// Creates an Instance of the Helix Class.
        /// </summary>
        /// <param name="loggerFactory">Instance Of LoggerFactory, otherwise no logging is used, </param>
        /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used.</param>
        /// <param name="settings">Instance of ApiSettings, otherwise defaults used, can be changed later</param>
        /// <param name="http">Instance of HttpCallHandler, otherwise default handler used</param>
        public Helix(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IApiSettings settings = null, IHttpCallHandler http = null)
        {
            _logger     = loggerFactory?.CreateLogger <Helix>();
            rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
            http        = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
            Settings    = settings ?? new ApiSettings();

            Analytics    = new Analytics(Settings, rateLimiter, http);
            Bits         = new Bits(Settings, rateLimiter, http);
            Clips        = new Clips(Settings, rateLimiter, http);
            Entitlements = new Entitlements(Settings, rateLimiter, http);
            Games        = new Games(Settings, rateLimiter, http);
            Streams      = new Streams(Settings, rateLimiter, http);
            Users        = new Users(Settings, rateLimiter, http);
            Videos       = new Videos(Settings, rateLimiter, http);
            Webhooks     = new Webhooks(Settings, rateLimiter, http);
        }
示例#7
0
        /// <summary>
        /// Creates an Instance of the TwitchAPI Class.
        /// </summary>
        /// <param name="clientId">Twitch Client Id.</param>
        /// <param name="accessToken">Twitch Access Token.</param>
        /// <param name="rateLimit">Should RateLimit Requests?</param>
        /// <param name="rateLimiter">Instance Of RateLimiter. Useful if using multiple API instances on one connection and you wish to share the requests ratelimiter.</param>
        /// <param name="callsPerPeriod">Number of Requests per Period to rate limit to</param>
        /// <param name="ratePeriod">Period for Rate Limit (In Seconds)</param>
        public TwitchAPI(string clientId = null, string accessToken = null, bool rateLimit = true, IRateLimiter rateLimiter = null, int callsPerPeriod = 1, int ratePeriod = 1)
        {
            _rateLimiter = rateLimit ?
                           (rateLimiter ?? TimeLimiter.GetFromMaxCountByInterval(callsPerPeriod, TimeSpan.FromSeconds(ratePeriod)))
                : BypassLimiter.CreateLimiterBypassInstance();

            Auth            = new Auth(this);
            Blocks          = new Blocks(this);
            Badges          = new Badges(this);
            Bits            = new Bits(this);
            ChannelFeeds    = new ChannelFeeds(this);
            Channels        = new Channels(this);
            Chat            = new Chat(this);
            Clips           = new Clips(this);
            Collections     = new Collections(this);
            Communities     = new Communities(this);
            Follows         = new Follows(this);
            Games           = new Games(this);
            Ingests         = new Ingests(this);
            Root            = new Root(this);
            Search          = new Search(this);
            Streams         = new Streams(this);
            Subscriptions   = new Subscriptions(this);
            Teams           = new Teams(this);
            ThirdParty      = new ThirdParty(this);
            Undocumented    = new Undocumented(this);
            Users           = new Users(this);
            Videos          = new Videos(this);
            Webhooks        = new Webhooks(this);
            Debugging       = new Debugging();
            Settings        = new ApiSettings(this);
            _jsonSerializer = new TwitchLibJsonSerializer();

            if (!string.IsNullOrWhiteSpace(clientId))
            {
                Settings.ClientId = clientId;
            }
            if (!string.IsNullOrWhiteSpace(accessToken))
            {
                Settings.AccessToken = accessToken;
            }
        }
示例#8
0
        /// <summary>
        /// Creates an Instance of the V5 Class.
        /// </summary>
        /// <param name="loggerFactory">Instance Of LoggerFactory, otherwise no logging is used, </param>
        /// <param name="rateLimiter">Instance Of RateLimiter, otherwise no ratelimiter is used.</param>
        /// <param name="settings">Instance of ApiSettings, otherwise defaults used, can be changed later</param>
        /// <param name="http">Instance of HttpCallHandler, otherwise default handler used</param>
        public V5(ILoggerFactory loggerFactory = null, IRateLimiter rateLimiter = null, IApiSettings settings = null, IHttpCallHandler http = null)
        {
            _logger     = loggerFactory?.CreateLogger <V5>();
            rateLimiter = rateLimiter ?? BypassLimiter.CreateLimiterBypassInstance();
            http        = http ?? new TwitchHttpClient(loggerFactory?.CreateLogger <TwitchHttpClient>());
            Settings    = settings ?? new ApiSettings();

            Badges      = new Badges(Settings, rateLimiter, http);
            Bits        = new Bits(Settings, rateLimiter, http);
            Channels    = new Channels(Settings, rateLimiter, http);
            Chat        = new Chat(Settings, rateLimiter, http);
            Clips       = new Clips(Settings, rateLimiter, http);
            Collections = new Collections(Settings, rateLimiter, http);
            Games       = new Games(Settings, rateLimiter, http);
            Ingests     = new Ingests(Settings, rateLimiter, http);
            Root        = new Root(Settings, rateLimiter, http);
            Search      = new Search(Settings, rateLimiter, http);
            Streams     = new Streams(Settings, rateLimiter, http);
            Teams       = new Teams(Settings, rateLimiter, http);
            Users       = new Users(Settings, rateLimiter, http);
            Videos      = new Videos(Settings, rateLimiter, http);
        }