Skip to content

Commit

Permalink
Added World Assembly API, raw access only atm
Browse files Browse the repository at this point in the history
  • Loading branch information
kolya5544 committed Oct 28, 2021
1 parent 159dfe1 commit b1f2880
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,5 +631,28 @@ public static DailyDataDump GetDump(this DotNS api, CardSeason season)
};
return ddd;
}

public static XmlNodeList GetWorld(this DotNS api, Shards.World shard, WorldAssembly council = WorldAssembly.GeneralAssembly, int resolutionID = -1)
{
var nvc = new NameValueCollection();
nvc.Add("wa", ((int)council).ToString());
string add = "";
switch (shard)
{
case Shards.World.Voters:
case Shards.World.VoteTrack:
case Shards.World.DelLog:
case Shards.World.DelVotes:
add = "+resolution"; break;
}
nvc.Add("q", $"{shard}{add}");
if (resolutionID != -1)
{
nvc.Add("id", resolutionID.ToString());
}
var resp = api.API(nvc);
string xml = Utilities.StrResp(resp);
return Utilities.Parse(xml, "/*");
}
}
}
12 changes: 12 additions & 0 deletions ClassHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ public enum PrivateShard
{
Dossier, Issues, IssueSummary, NextIssue, NextIssueTime, Notices, Packs, Ping, RDossier, Unread
}

public enum World
{
//World Assembly API
NumNations, NumDelegates, Delegates, Members, Happenings, Proposals, Resultion, Voters, VoteTrack, DelLog, DelVotes, LastResolution
}
}

public class CensusNode
Expand Down Expand Up @@ -134,6 +140,12 @@ public enum Census
FoodQuality = 88
}

public enum WorldAssembly
{
GeneralAssembly = 1,
SecurityCouncil = 2
}

public enum RequestType
{
Nation, Region
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ or after initialization
```cs
api.UserAgent = "UserAgent";
```

Also, to disable our API ratelimiting feature (enabled by default), use
```cs
api.RateLimit = false;
```

### High level API example
#### Get basic nation information
```cs
Expand Down Expand Up @@ -241,6 +247,19 @@ foreach (string n in RegionNations)
Console.WriteLine(n);
}
```
#### Using World API
```cs
using dotNS;
using dotNS.Classes;
using System.Xml;
<...>
// Create an API wrapper
DotNS api = new DotNS();
// Get number of nations in the world
XmlNodeList nodes = bot.GetWorld(Shards.World.NumNations);
string amount = Utilities.FindProperty(nodes, "numnations");
Console.WriteLine($"There are {amount} nations in the world!");
```
#### Using API directly
```cs
using dotNS;
Expand Down

0 comments on commit b1f2880

Please sign in to comment.