Add docs, fix tests for user plan

This commit is contained in:
Tim Clem
2012-04-28 15:29:49 -07:00
parent f9232a76dd
commit 2fb5d45bdd
5 changed files with 182 additions and 41 deletions
+15 -2
View File
@@ -47,7 +47,7 @@ namespace Burr
public static User JObjectToUser(JObject jObj)
{
return new User
var user = new User
{
Followers = (int)jObj["followers"],
Type = (string)jObj["type"],
@@ -66,8 +66,21 @@ namespace Burr
Location = (string)jObj["location"],
Id = (int)jObj["id"],
Email = (string)jObj["email"],
Login = (string)jObj["login"]
Login = (string)jObj["login"],
};
if(jObj.ObjectValue.ContainsKey("plan"))
{
user.Plan = new Plan
{
Collaborators = (int)jObj["plan"]["collaborators"],
Name = (string)jObj["plan"]["name"],
Space = (int)jObj["plan"]["space"],
PrivateRepos = (int)jObj["plan"]["private_repos"],
};
}
return user;
}
}
}
+1 -1
View File
@@ -63,7 +63,7 @@
<Compile Include="SimpleJSON\JObject.cs" />
<Compile Include="SimpleJSON\JSONDecoder.cs" />
<Compile Include="SimpleJSON\JSONEncoder.cs" />
<Compile Include="User.cs" />
<Compile Include="Entities.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+162
View File
@@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Burr
{
/// <summary>
/// A user on GitHub
/// </summary>
[DebuggerDisplay("{Login} ({Name})")]
public class User
{
/// <summary>
/// URL for this user's avatar.
/// </summary>
public string AvatarUrl { get; set; }
/// <summary>
/// This user's bio.
/// </summary>
public string Bio { get; set; }
/// <summary>
/// URL for this user's blog.
/// </summary>
public string Blog { get; set; }
/// <summary>
/// Number of collaborators this user has on their account.
/// </summary>
public int Collaborators { get; set; }
/// <summary>
/// The company this user's works for.
/// </summary>
public string Company { get; set; }
/// <summary>
/// The date this user account was create.
/// </summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>
/// The amout of disk space this user is currently using.
/// </summary>
public int DiskUsage { get; set; }
/// <summary>
/// This user's email.
/// </summary>
public string Email { get; set; }
/// <summary>
/// Number of follwers this user has.
/// </summary>
public int Followers { get; set; }
/// <summary>
/// Number of other users this user is following.
/// </summary>
public int Following { get; set; }
/// <summary>
/// Tells if this user is currently hireable.
/// </summary>
public bool Hireable { get; set; }
/// <summary>
/// The HTML URL for this user on github.com.
/// </summary>
public string HtmlUrl { get; set; }
/// <summary>
/// The system-wide unique Id for this user.
/// </summary>
public int Id { get; set; }
/// <summary>
/// The geographic location of this user.
/// </summary>
public string Location { get; set; }
/// <summary>
/// This user's login.
/// </summary>
public string Login { get; set; }
/// <summary>
/// This user's full name.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Number of private repos owned by this user.
/// </summary>
public int OwnedPrivateRepos { get; set; }
/// <summary>
/// The plan this user pays for.
/// </summary>
public Plan Plan { get; set; }
/// <summary>
/// The number of private gists this user has created.
/// </summary>
public int PrivateGists { get; set; }
/// <summary>
/// The number of public gists this user has created.
/// </summary>
public int PublicGists { get; set; }
/// <summary>
/// The number of public repos owned by this user.
/// </summary>
public int PublicRepos { get; set; }
/// <summary>
/// The total number of private repos this user owns.
/// </summary>
public int TotalPrivateRepos { get; set; }
/// <summary>
/// The type of this record. (User for user account, Organization for org account)
/// </summary>
public string Type { get; set; }
/// <summary>
/// The api URL for this user.
/// </summary>
public string Url { get; set; }
}
/// <summary>
/// A plan (either paid or free) for a particular user
/// </summary>
public class Plan
{
/// <summary>
/// The number of collaborators allowed with this plan.
/// </summary>
public int Collaborators { get; set; }
/// <summary>
/// The name of the plan.
/// </summary>
public string Name { get; set; }
/// <summary>
/// The number of private repositories allowed with this plan.
/// </summary>
public int PrivateRepos { get; set; }
/// <summary>
/// The amount of disk space allowed with this plan.
/// </summary>
public long Space { get; set; }
}
}
+4
View File
@@ -46,6 +46,10 @@ namespace Burr
}
IConnection connection;
/// <summary>
/// Provides a client connection to make rest requests to HTTP endpoints.
/// </summary>
public IConnection Connection
{
get
-38
View File
@@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Burr
{
[DebuggerDisplay("{Login}")]
public class User
{
public string AvatarUrl { get; set; }
public string Bio { get; set; }
public string Blog { get; set; }
public int Collaborators { get; set; }
public string Company { get; set; }
public DateTimeOffset CreatedAt { get; set; }
public int DiskUsage { get; set; }
public string Email { get; set; }
public int Followers { get; set; }
public int Following { get; set; }
public bool Hireable { get; set; }
public string HtmlUrl { get; set; }
public int Id { get; set; }
public string Location { get; set; }
public string Login { get; set; }
public string Name { get; set; }
public int OwnedPrivateRepos { get; set; }
//public GitHubUserPlan Plan { get; set; }
public int PrivateGists { get; set; }
public int PublicGists { get; set; }
public int PublicRepos { get; set; }
public int TotalPrivateRepos { get; set; }
public string Type { get; set; }
public string Url { get; set; }
}
}