Jump to content

Jroc's API Helper Library


Jroc
 Share

Recommended Posts

Introduction

I have been working on creating a C# Code Library that makes Sheepy's API sane and speeds up your development time.

 

I have nations partially working but in a few days, I will have everything working. The hardest part is parsing the Json into objects, but I got that covered.

 

So far, I am exposing an interface for Nation, called INation, you can choose to implement this interface which will auto fill your nation class that you create with the desired properties. Alternatively, you can pass in a class/type that you define. You will need to make sure it matches 100% with Sheepy's Json model (and also infer the correct types). In addition, you could also get the JSON that has been made sane instead of this. The idea is for ease of use in all use cases :).

 

I will provide documentation though with what I chose the types to be, so you will need to follow that. But, until then, since my code will be open source you can just follow the code. 

 

The benefit to the later method (defining your own type and not implementing INation), is that you won't need to implement all of INation just the tidbits you want.

 

How do you do it?

This is a bit technical and a bit less. I basically call sheepy's API with the info that you pass to it. For instance, since Nation is working, you can input an Id like 10054 (my nation Id) and it will return an object implementing INation or if you choose the one where it takes your class, your class will come back.

 

The parsing is done by digging deep down into the rendered JSON and then it knows how to translate it to an object implementing INation internally. This will be the same for others.

 

In order to return your class, I make use of automapper which maps it to your class.

 

And now you have an object with just nation data or you can get sane json. The choice is yours :)

 

License?

This library will be licensed under GPL V3

 

Release Date?

I will be releasing the first build soon, hopefully today. It will be basic and will work with Nation first. I will then add Alliance and everything else that comes from the API. This is just so that I can get feedback and start tweaking it.

 

Can I help?

Of course. It will be on github so fork it and send me a Pull Request.

 

Other platforms/languages?

I believe it is possible to use a special piece of tech to call an outside library written in C#. Not sure.

 

Why CSharp?

I write commercial software and other stuff in C# all the time. So, yeah.

Edited by Jroc
  • Upvote 1

 php882dgiAM.jpg.9136a0a695ba680a032e6cfd5880ece4.jpg

Link to comment
Share on other sites

I dont know what you are doing but it seems great. :v

x0H0NxD.jpg?1

 

01:05:55 <%fistofdoom> im out of wine

01:06:03 <%fistofdoom> i winsih i had port
01:06:39 <@JoshF{BoC}> fistofdoom: is the snowman drunk with you

01:07:32 <%fistofdoom> i knet i forgot somehnt

 

Link to comment
Share on other sites

I dont know what you are doing but it seems great. :v

 

Basically, I am wrapping sheepy's API and making it easier to use from the start so you don't have to build the infrastructure to parse his json. Basically, you could use this in your own program you write.

 

For instance if you wanted to save it to a database every hour you could do it.

Basically you would do this,

  • Create a type called Nation
  • Have it implement INation, if it implements INation than .Net will enforce that you implement all methods and properties in the interface.Its pretty simple if you have resharper to do that. If not, I think VS will do it for you as well. 
  • then have Entity Framework (or even linq to sql) save it the database for you. This is assuming you have done a code-first migration and you have a table called Nations in the database. If you have a database and want to do it the other way, you would modify your approach as necessary.
  • And, then call your code and methods to do analytical evaluation, etc... 
Edited by Jroc

 php882dgiAM.jpg.9136a0a695ba680a032e6cfd5880ece4.jpg

Link to comment
Share on other sites

Ohhhh I've been looking to migrate my tools to c# (cuz &#33;@#&#036; PHP).

 

This is awesome dude!

[22:37:51] <&Yosodog> Problem is, everyone is too busy deciding which top gun character they are that no decision has been made

 

BK in a nutshell

Link to comment
Share on other sites

Ohhhh I've been looking to migrate my tools to c# (cuz !@#$ PHP).

 

This is awesome dude!

 

Awesome man! I should also be able to nuget package it once I have everything working.

That way, all you have to do is pull down the nuget package and you are good to go.

 php882dgiAM.jpg.9136a0a695ba680a032e6cfd5880ece4.jpg

Link to comment
Share on other sites

it is

 

Why CSharp?

I write commercial software and other stuff in C# all the time. So, yeah. ALSO, I HATE LINUX

eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers.

 
 
the API for AA REALLLLLYYY needs nation numbers included
Link to comment
Share on other sites

 

eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers.

 
 
the API for AA REALLLLLYYY needs nation numbers included

 

 

R is a nice programming language. 

 

I however don't know R but I know c# so ya know,

 

And, I also run Arch Linux testing on a machine and I am a big linux guy as well. TYVM

Edited by Jroc

 php882dgiAM.jpg.9136a0a695ba680a032e6cfd5880ece4.jpg

Link to comment
Share on other sites

 

eh, I just grab stuff in R with the Jsonlite package and it nicely converts everything to R lists. The only thing I need to do is pick out the information I find relevant and feed it the nation numbers.

 
 
the API for AA REALLLLLYYY needs nation numbers included

 

 

One way to do that would be to start from the beginning of all nationId's, poll the API to get all those nations and save that to the database with a nullable FK.

And, then, poll the API to get all the alliances and save that to the database.

And, then cross-reference all the nations with the alliance names and then update the nullable FK that you created in the nations table with the ID that was created when you added the alliances to the db.

 

Now, you have an easy to use way.

Albeit, you could also do it all in memory.

 php882dgiAM.jpg.9136a0a695ba680a032e6cfd5880ece4.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and the Guidelines of the game and community.