public void Join_Triple_Inside() { var request = new DataRequest("character"); request.Parameters.Add("name.first_lower", "krusen"); // Join character with outfit_member var join = new Join("outfit_member"); join.InjectAt = "outfit"; join.Show.Add("member_since_date", "rank", "rank_ordinal", "outfit_id"); // Join outfit_member with outfit var join2 = new Join("outfit"); join2.InjectAt = "outfit_info"; join2.Show.Add("name", "alias", "member_count", "leader_character_id"); // Join outfit with character var join3 = new Join("character"); join3.InjectAt = "leader_profile"; join3.Show.Add("name", "battle_rank"); join3.On = "leader_character_id"; join3.To = "character_id"; request.JoinWith(join.JoinWith(join2.JoinWith(join3))); var expected = "?name.first_lower=krusen&c:join=outfit_member^inject_at:outfit^show:member_since_date'rank'rank_ordinal'outfit_id(outfit^inject_at:outfit_info^show:name'alias'member_count'leader_character_id(character^on:leader_character_id^to:character_id^inject_at:leader_profile^show:name'battle_rank))"; var actual = request.QueryString; Assert.AreEqual(expected, actual); }
// Expected result: // http://census.soe.com/s:soe/json/get/ps2:v2/character/?name.first_lower=krusen&c:join=outfit_member^inject_at:outfit^show:member_since_date'rank'rank_ordinal'outfit_id(outfit^show:name'alias'member_count'leader_character_id^inject_at:outfit_info(character^on:leader_character_id^to:character_id^inject_at:leader_profile^show:name'battle_rank)) public static dynamic JoinTest() { // TODO: Test with 2 joins on same collection instead of just nested joins var api = new CensusApi("ps2:v2"); var request = new DataRequest("character"); request.Parameters.Add("name.first_lower", "krusen"); // Join character with outfit_member var join = new Join("outfit_member"); join.InjectAt = "outfit"; join.Show.Add("member_since_date", "rank", "rank_ordinal", "outfit_id"); // Join outfit_member with outfit var join2 = new Join("outfit"); join2.InjectAt = "outfit_info"; join2.Show.Add("name", "alias", "member_count", "leader_character_id"); // Join outfit with character var join3 = new Join("character"); join3.InjectAt = "leader_profile"; join3.Show.Add("name", "battle_rank"); join3.On = "leader_character_id"; join3.To = "character_id"; request.JoinWith(join.JoinWith(join2.JoinWith(join3))); return api.Execute(request); }
// Exptected result: // http://census.soe.com/get/ps2:v2/vehicle?c:limit=5&c:lang=en&cost=%3E300&c:tree=cost^prefix:cost_^list:1 public static dynamic TreeTest() { var api = new CensusApi("ps2:v2"); var request = new DataRequest("vehicle"); request.Parameters.Add("cost", ">300"); request.Tree = new Tree("cost", "cost_"); request.Limit = 5; request.Language = "en"; return api.Execute(request); }
public void Join_Single() { var request = new DataRequest("character"); request.Parameters.Add("name.first_lower", "krusen"); // Join character with outfit_member var join = new Join("outfit_member"); join.InjectAt = "outfit"; join.Show.Add("member_since_date", "rank", "rank_ordinal", "outfit_id"); request.JoinWith(join); var expected = "?name.first_lower=krusen&c:join=outfit_member^inject_at:outfit^show:member_since_date'rank'rank_ordinal'outfit_id"; var actual = request.QueryString; Assert.AreEqual(expected, actual); }
public bool? IsCharacterOnline(long id) { var request = new DataRequest("characters_online_status"); request.Parameters.Add("id", id); //request.Language = Language; // TODO dynamic data = Api.Execute(request); var charId = data.characters_online_status_list[0].character_id; var status = data.characters_online_status_list[0].online_status; return status != "0"; }
private DataRequest GetCharacterRequest() { var request = new DataRequest("character"); var faction = new Join("faction"); faction.InjectAt = "faction"; var outfit = new Join("outfit_member_extended"); outfit.InjectAt = "outfit_info"; var outfitLeader = new Join("character"); outfitLeader.Show.Add("name.first", "character_id"); outfitLeader.On = "leader_character_id"; outfitLeader.To = "character_id"; outfitLeader.InjectAt = "leader"; var online = new Join("characters_online_status"); online.InjectAt = "online_status"; var world = new Join("characters_world"); world.InjectAt = "world"; var worldInfo = new Join("world"); worldInfo.InjectAt = "info"; var currency = new Join("characters_currency"); currency.InjectAt = "currency"; // request.JoinWith("collection").On("char_id").To("char_id").InjectAt("collection_name").JoinWith(.... request.JoinWith(world.JoinWith(worldInfo)); request.JoinWith(outfit.JoinWith(outfitLeader)); request.JoinWith(online); request.JoinWith(currency); request.JoinWith(faction); return request; }
public bool? IsCharacterOnline(string name) { var request = new DataRequest("character"); //request.ManualQuery = string.Format("?name.first={0}&c:resolve=online_status&c:show=name,id&c:case=false", name.ToLower()); //request.Language = Language; // TODO request.Parameters.Add("name.first_lower", name.ToLower()); request.IsCaseSensitive = true; request.Resolves.Add("online_status"); request.Show.Add("name", "character_id"); dynamic data = Api.Execute(request); if (data.returned == 0) return null; if (data.returned > 1) throw new Exception("Request returned more than 1 result. I don't know how to handle this."); var charName = data.character_list[0].name.first; var charId = data.character_list[0].character_id; var status = data.character_list[0].online_status; return status != "0"; }