/*public string GetAccessToken() * { * var body = $"client_id={Config.Instance.ClientId}&client_secret={Config.Instance.ClientSecret}&grant_type=client_credentials"; * var header = new WebHeaderCollection * { * { "Content-Type", "application/x-www-form-urlencoded" } * }; * var accessToken = WebHelper.UploadJson<AccessToken>("https://api.richasy.cn/connect/token", body, header).access_token; * * Config.Instance.Last_update = DateTime.Now; * Config.Save(); * return accessToken; * } * * public void UpdateAccessToken() * { * if (isWFA && DateTime.Now - Config.Instance.Last_update > TimeSpan.FromDays(7)) * { * Config.Instance.AcessToken = GetAccessToken(); * Config.Save(); * } * }*/ /*public List<RivenInfo> GetRivenInfos(string weapon) * { * var header = new WebHeaderCollection(); * var count = Config.Instance.WFASearchCount; * var platform = Config.Instance.Platform.GetSymbols().First(); * if (Config.Instance.Platform == Platform.NS) * { * platform = "ns"; * } * header.Add("Authorization", $"Bearer {Config.Instance.AcessToken}"); * header.Add("Platform", platform); * header.Add("Weapon", weapon.ToBase64()); * return WebHelper.DownloadJson<List<RivenInfo>>($"https://api.richasy.cn/wfa/rm/riven", header).Where(info => info.isSell == 1).Take(count).ToList(); // 操 云之幻好蠢 为什么不能在请求里限制是买还是卖 * }*/ public async Task <List <Order> > GetRivenOrders(string weapon) { var option = new SearchRivenOrderOption { Category = "", IsVeiled = false, OrderType = "sell", Page = 1, PageSize = 20, Weapon = Uri.EscapeUriString(weapon) }; var orders = (await wfaClient.QueryRivenOrdersAsync(option) ?? throw new CommandException("由于未知原因, 返回的数据为空.")).Items; translator.TranslateRivenOrders(orders); return(orders); }
/*public string GetAccessToken() * { * var body = $"client_id={Config.Instance.ClientId}&client_secret={Config.Instance.ClientSecret}&grant_type=client_credentials"; * var header = new WebHeaderCollection * { * { "Content-Type", "application/x-www-form-urlencoded" } * }; * var accessToken = WebHelper.UploadJson<AccessToken>("https://api.richasy.cn/connect/token", body, header).access_token; * * Config.Instance.Last_update = DateTime.Now; * Config.Save(); * return accessToken; * } * * public void UpdateAccessToken() * { * if (isWFA && DateTime.Now - Config.Instance.Last_update > TimeSpan.FromDays(7)) * { * Config.Instance.AcessToken = GetAccessToken(); * Config.Save(); * } * }*/ /*public List<RivenInfo> GetRivenInfos(string weapon) * { * var header = new WebHeaderCollection(); * var count = Config.Instance.WFASearchCount; * var platform = Config.Instance.Platform.GetSymbols().First(); * if (Config.Instance.Platform == Platform.NS) * { * platform = "ns"; * } * header.Add("Authorization", $"Bearer {Config.Instance.AcessToken}"); * header.Add("Platform", platform); * header.Add("Weapon", weapon.ToBase64()); * return WebHelper.DownloadJson<List<RivenInfo>>($"https://api.richasy.cn/wfa/rm/riven", header).Where(info => info.isSell == 1).Take(count).ToList(); // 操 云之幻好蠢 为什么不能在请求里限制是买还是卖 * }*/ public List <WarframeAlertingPrime.SDK.Models.User.Order> GetRivenOrders(string weapon) { var option = new SearchRivenOrderOption { Category = "", IsVeiled = false, OrderType = "sell", Page = 1, PageSize = 20, Weapon = Uri.EscapeUriString(weapon) }; var orders = wfaClient.QueryRivenOrdersAsync(option).Result.Items; translator.TranslateRivenOrders(orders); return(orders); }
/// <summary> /// Query Riven Market Order /// </summary> /// <param name="option">Request parameter</param> /// <returns></returns> public async Task <OrderPackage> QueryRivenOrdersAsync(SearchRivenOrderOption option) { if (string.IsNullOrEmpty(option.Weapon) && string.IsNullOrEmpty(option.Category)) { throw new ArgumentException("must have valid weapon or category"); } string route = Statics.RIVEMMARKET_ORDER_QUERY_URL + $"?orderType={option.OrderType}&pageSize={option.PageSize}&page={option.Page}" + $"&category={option.Category}&weapon={option.Weapon}&isVeiled={option.IsVeiled}"; var orders = await NetworkTools.GetEntityAsync <OrderPackage>(route, Token, ExceptionAction); return(orders); }