Ejemplo n.º 1
0
 public JToken RequestAsJson(TwitchAPIRequest apiRequest, string errorKey = null)
 {
     using (var response = this.Request(apiRequest))
     {
         return(this.ReadAsJsonThrowIfError(response, errorKey));
     }
 }
Ejemplo n.º 2
0
        public WebRequestParameter CreateWebRequest(TwitchAPIRequest apiRequest)
        {
            var baseUri     = this.GetBaseUri(apiRequest.BaseUrl, apiRequest.Version, apiRequest.Path);
            var queryValues = new QueryValues();

            queryValues.AddRange(QueryValues.Parse(baseUri.Query));
            queryValues.AddRange(apiRequest.QueryValues);

            var request = new WebRequestParameter();

            request.RetryCount     = 0;
            request.Uri            = $"{baseUri.Scheme}{Uri.SchemeDelimiter}{baseUri.Host}{baseUri.LocalPath}{queryValues.ToString(false)}";
            request.Method         = apiRequest.Method;
            request.WriteParameter = apiRequest.PostData;
            request.ContentType    = apiRequest.ContentType ?? request.ContentType;
            this.SetupRequest(request, apiRequest.Version);

            return(request);
        }
Ejemplo n.º 3
0
        public HttpWebResponse Request(TwitchAPIRequest apiRequest)
        {
            var webRequest = this.CreateWebRequest(apiRequest);

            return(this.Web.Request(webRequest));
        }