public bool ContainsApiName(LolApiName name, LolApiMethodName method) { bool q1 = ApiMethods.Contains(method); bool q2 = Names.Contains(name); return(q1 && q2); }
public LolApiUrl AddApi(LolApiName suffix1, double version) { LolApiUrl sff1 = new LolApiUrl(suffix1, version); this.RiotGamesApiUrls.Add(sff1); return(sff1); }
/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="name"> /// </param> /// <param name="limits"> /// </param> /// <param name="methods"> /// </param> /// <returns> /// </returns> public RateLimitBuilder AddRateLimitFor(LolUrlType type, LolApiName name, List <ApiLimit> limits, params LolApiMethodName[] methods) { return(AddRateLimitFor(type, new List <LolApiName>() { name }, limits, methods)); }
public void Add(LolApiName name, params LolApiMethodName[] val) { Add(new List <LolApiName>() { name }, val); }
/// <exception cref="OverflowException"> /// The dictionary already contains the maximum number of elements ( <see cref="F:System.Int32.MaxValue" />). /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="key" /> is null. /// </exception> public void Add(string region, LolUrlType type, LolApiName name, List <LolApiMethodName> apiMethods, List <ApiLimit> limits) { var rut = new RUrlType(); rut.Add(type, new RLolApiMethodName(name, apiMethods, limits.ToArray())); Add(region, rut); }
/// <exception cref="KeyNotFoundException"> /// The property is retrieved and <paramref name="key" /> does not exist in the collection. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="key" /> is null. /// </exception> public RLolApiMethodName Find(string region, LolUrlType type, LolApiName name, LolApiMethodName method) { var rut = Find(region); var rla = rut?.Find(type); var rlan = rla?.Find(name, method); return(rlan); }
/// <summary> /// get data from Retry-After /// </summary> /// <param name="prop"> /// </param> /// <param name="name"> /// </param> /// <param name="limitType"> /// </param> /// <param name="retryAfterSeconds"> /// value of Retry-After /// </param> /// <param name="region"> /// </param> /// <param name="type"> /// </param> /// <exception cref="RiotGamesApiException"> /// Condition. /// </exception> public void SetRetryTime(string region, LolUrlType type, LolApiName name, RateLimitType limitType, LolApiMethodName method, int retryAfterSeconds) { var regionLimit = Rates.Find(region, type, name, method); if (regionLimit == null) { throw new RiotGamesApiException($"Undefined {limitType} limit type for region:{region},type:{type},name:{name}"); } regionLimit.RetryAfter = DateTime.Now.AddSeconds(retryAfterSeconds); regionLimit.UsedRateLimitType = limitType; }
/// <exception cref="RiotGamesApiException"> /// UrlTypeAttribute not found /// </exception> /// <exception cref="AmbiguousMatchException"> /// More than one of the requested attributes was found. /// </exception> /// <exception cref="TypeLoadException"> /// A custom attribute type cannot be loaded. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="source" /> or <paramref name="predicate" /> is null. /// </exception> /// <exception cref="InvalidOperationException"> /// No element satisfies the condition in <paramref name="predicate" />.-or-The source /// sequence is empty. /// </exception> /// <exception cref="NotSupportedException"> /// <paramref name="element" /> is not a constructor, method, property, event, type, or field. /// </exception> public static LolUrlType GetUrlType(this LolApiName enumVal) { var typeInfo = enumVal.GetType().GetTypeInfo(); var v = typeInfo.DeclaredMembers.First(x => x.Name == enumVal.ToString()); var attr = v?.GetCustomAttribute <UrlTypeAttribute>(); if (attr == null) { throw new RiotGamesApiException("UrlTypeAttribute not found"); } return(attr.ApiType); }
/// <summary> /// easy api requester /// </summary> /// <typeparam name="T"> /// returns Type of Value /// </typeparam> /// <param name="apiType"> /// specify api type version /// </param> /// <param name="version"> /// specify api version /// </param> /// <returns> /// </returns> /// <exception cref="RiotGamesApiException"> /// Condition. /// </exception> public IFor <T> SelectApi <T>(LolApiName apiType, double version = 3.0) where T : new() { var rit = new LolApiRequest <T> { UrlType = apiType.GetUrlType() }; rit.BaseUrl = ApiSettings.ApiOptions.RiotGamesApis[rit.UrlType].ApiUrl; rit.ApiList = ApiSettings.ApiOptions.RiotGamesApis[rit.UrlType].RiotGamesApiUrls .FirstOrDefault(p => p.ApiName == apiType && p.CompareVersion(version)); if (rit.ApiList == null) { throw new RiotGamesApiException($"{rit.UrlType} is not defined in RiotGamesApiBuilder or selected version:{version} is not defined"); } return(rit); }
/// <summary> /// add cache rule for non-static api /// </summary> /// <param name="urlType"> /// api url type /// </param> /// <param name="apiName"> /// api method name /// </param> /// <param name="expiryTime"> /// expiry time (max-limit: 1 hour) /// </param> public void AddCacheRule(LolUrlType urlType, LolApiName apiName, TimeSpan expiryTime) { if (urlType != LolUrlType.Static) { if (expiryTime.Hours >= 1) { expiryTime = new TimeSpan(1, 0, 0); } var found = FindCacheRule(urlType, apiName); if (found != null) { CustomCacheRules.Remove(found); } CustomCacheRules.Add(new CustomCacheRule(urlType, apiName, expiryTime)); } }
public CustomCacheRule(LolUrlType urlType, LolApiName apiName, TimeSpan expiryTime) { this.UrlType = urlType; this.ApiName = apiName; this.ExpiryTime = expiryTime; }
public LolApiRateUrl For(LolApiName api) { LolApiRateUrl url = new LolApiRateUrl(); return(url); }
public RLolApiMethodName(LolApiName name, List <LolApiMethodName> methods, params ApiLimit[] limits) : this(new List <LolApiName>() { name }, methods, limits) { }
/// <summary> /// finds exists cache rules /// </summary> /// <param name="urlType"> /// </param> /// <param name="apiName"> /// </param> /// <returns> /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="source" /> or <paramref name="predicate" /> is null. /// </exception> public CustomCacheRule FindCacheRule(LolUrlType urlType, LolApiName apiName) { var found = CustomCacheRules.FirstOrDefault(p => p.UrlType == urlType && p.ApiName == apiName); return(found); }
/// <summary> /// removs cache rule /// </summary> /// <param name="urlType"> /// </param> /// <param name="apiName"> /// </param> public void RemoveCacheRule(LolUrlType urlType, LolApiName apiName) { CustomCacheRules.RemoveAll(p => p.UrlType == urlType && p.ApiName == apiName); }
public LolRateLimit(LolApiName name) { ApiName = name; ApiMethods = new List <LolApiMethodName>(); }
public RLolApiMethodName Find(LolApiName name, LolApiMethodName method) { return(Names.FirstOrDefault <RLolApiMethodName>(p => p.ContainsApiName(name, method))); }
public void Add(LolApiName name, RLolApiMethodName val) { Names.Add(val); }
public RLolApiMethodName FindRate(string platform, LolUrlType type, LolApiName apiName, LolApiMethodName method) { return(Rates.Find(platform, type, apiName, method)); }
/// <summary> /// lol apiurl creator /// </summary> /// <param name="_newApiUrl"> /// name of apiMethod /// </param> /// <param name="_version"> /// version of Method /// </param> public LolApiUrl(LolApiName _newApiUrl, double _version) { ApiMethods = new List <LolApiMethod>(); SetVersion(_version); ApiName = _newApiUrl; }