/// <summary> /// Sends a single request to the Twitch-Rest-API. /// A connection will be open and close, so there is a time-delay by running this method. /// </summary> /// <param name="url">Request-URL for the Twitch-Rest-API.</param> /// <param name="version">The Twitch-Rest-API-Version. (Current stable and default is V3.)</param> /// <param name="accessToken"> /// Authentication-token to get special informations from the Twitch-Rest-API. /// Default is an empty string and is working for the most features. /// </param> /// <returns>RestResponse with the informations from the Twitch-Rest-API.</returns> /// <exception cref="RestRequestErrorException"> /// An Exception with a StreamingConnect.Api.Error to get informations in detail. /// </exception> public static RestResponse SingleRequest(string url, TwitchAPIVersion? version = null, string accessToken = "") { try { version = (!version.HasValue) ? TwitchAPIVersion.V3 : version; return RestConnection.SendSingleRequest(url, accessToken, version.Value.MIME, ""); } catch (RestRequestErrorException e) { ConvertRestRequestErrorException(ref e); throw; } }
/// <summary> /// Creates a Client-object with the Twitch-Rest-API. /// </summary> /// <param name="accessToken"> /// <param name="version">The Twitch-Rest-API-Version. (Default is V3. Changes are not recommended.)</param> /// Authentication-token to get special informations from the Twitch-Rest-API. /// Default is an empty string and is working for the most features. /// </param> public TwitchRestServiceConnection(string accessToken = "", TwitchAPIVersion? version = null) { _accessToken = string.IsNullOrWhiteSpace(accessToken) ? "" : accessToken; _version = (!version.HasValue) ? TwitchAPIVersion.V3 : version; Description = TwitchAPIDescription.Default; }