コード例 #1
0
 public async static Task <T> PostGenericModelAsync <T>(string url, Models.API.RequestModel model, string accessToken = null, API api = API.v5, string clientId = null)
 {
     if (model != null)
     {
         return(JsonConvert.DeserializeObject <T>(await generalRequestAsync(url, "POST", TwitchLibJsonSerializer.SerializeObject(model), accessToken, api, clientId), TwitchLibJsonDeserializer));
     }
     else
     {
         return(JsonConvert.DeserializeObject <T>(await generalRequestAsync(url, "POST", "", accessToken, api), TwitchLibJsonDeserializer));
     }
 }
コード例 #2
0
 public async static Task PostModelAsync(string url, Models.API.RequestModel model, string accessToken = null, API api = API.v5, string clientId = null)
 {
     await generalRequestAsync(url, "POST", TwitchLibJsonSerializer.SerializeObject(model), accessToken, api, clientId);
 }
コード例 #3
0
        protected Task <T> TwitchPostGenericModelAsync <T>(string resource, ApiVersion api, RequestModel model, string accessToken = null, string clientId = null, string customBase = null)
        {
            var url = ConstructResourceUrl(resource, api: api, overrideUrl: customBase);

            if (string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(Settings.ClientId))
            {
                clientId = Settings.ClientId;
            }

            accessToken = GetAccessToken(accessToken);
            ForceAccessTokenAndClientIdForHelix(clientId, accessToken, api);

            return(_rateLimiter.Perform(async() => await Task.Run(() => JsonConvert.DeserializeObject <T>(_http.GeneralRequest(url, "POST", model != null ? _jsonSerializer.SerializeObject(model) : "", api, clientId, accessToken).Value, _twitchLibJsonDeserializer)).ConfigureAwait(false)));
        }