@@ -15,7 +15,12 @@ namespace NetrunnerDb.Net.Tests
|
|||||||
[Ignore]
|
[Ignore]
|
||||||
public void Tst()
|
public void Tst()
|
||||||
{
|
{
|
||||||
var cool = new Repository().GetRequest<Cards>("tsb");
|
// var t = new BaseRequest();
|
||||||
|
var cool = new Repository().GetRequest<Decklist>("20850");
|
||||||
|
foreach (var x in cool[0].Cards)
|
||||||
|
{
|
||||||
|
Console.WriteLine(new Repository().GetRequest<OneCard>(x.Key)[0].Title + " x " + x.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,15 +65,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\NetrunnerDb.Net\NetrunnerDb.Net.csproj">
|
<ProjectReference Include="..\NetrunnerDb.Net\NetrunnerDb.Net.csproj">
|
||||||
<Project>{1b508dcb-3207-4597-b938-9218d32a41a4}</Project>
|
<Project>{1b508dcb-3207-4597-b938-9218d32a41a4}</Project>
|
||||||
<Name>NetrunnerDb.Net</Name>
|
<Name>NetrunnerDb.Net</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
@@ -47,10 +47,13 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Responses\BaseRequest.cs" />
|
||||||
<Compile Include="Responses\Cards.cs" />
|
<Compile Include="Responses\Cards.cs" />
|
||||||
|
<Compile Include="Responses\Decklist.cs" />
|
||||||
<Compile Include="Responses\IRequest.cs" />
|
<Compile Include="Responses\IRequest.cs" />
|
||||||
<Compile Include="Repository.cs" />
|
<Compile Include="Repository.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Responses\OneCard.cs" />
|
||||||
<Compile Include="Responses\Set.cs" />
|
<Compile Include="Responses\Set.cs" />
|
||||||
<Compile Include="Responses\Sets.cs" />
|
<Compile Include="Responses\Sets.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -27,7 +27,12 @@ namespace NetrunnerDb.Net
|
|||||||
var client = new RestClient("http://netrunnerdb.com");
|
var client = new RestClient("http://netrunnerdb.com");
|
||||||
var response = client.Execute(request);
|
var response = client.Execute(request);
|
||||||
if (response.StatusCode != HttpStatusCode.OK) return null;
|
if (response.StatusCode != HttpStatusCode.OK) return null;
|
||||||
return JsonConvert.DeserializeObject<IList<TResult>>(response.Content);
|
if (s.IsArray)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<IList<TResult>>(response.Content);
|
||||||
|
}
|
||||||
|
var t = new List<TResult> {JsonConvert.DeserializeObject<TResult>(response.Content)};
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// /api/sets/ returns data about all the sets in the database.
|
/// /api/sets/ returns data about all the sets in the database.
|
||||||
|
|||||||
14
src/NetrunnerDb.Net/Responses/BaseRequest.cs
Normal file
14
src/NetrunnerDb.Net/Responses/BaseRequest.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NetrunnerDb.Net.Responses
|
||||||
|
{
|
||||||
|
public abstract class BaseRequest : IRequest
|
||||||
|
{
|
||||||
|
public virtual bool IsArray { get { return true; }}
|
||||||
|
public abstract string EndPoint(string parameter = "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace NetrunnerDb.Net.Responses
|
namespace NetrunnerDb.Net.Responses
|
||||||
{
|
{
|
||||||
public class Cards : IRequest
|
public class Cards : BaseRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("last-modified")]
|
[JsonProperty("last-modified")]
|
||||||
@@ -111,7 +111,7 @@ namespace NetrunnerDb.Net.Responses
|
|||||||
[JsonProperty("trash")]
|
[JsonProperty("trash")]
|
||||||
public int? Trash { get; set; }
|
public int? Trash { get; set; }
|
||||||
|
|
||||||
public string EndPoint(string parameter = "")
|
public override string EndPoint(string parameter = "")
|
||||||
{
|
{
|
||||||
//this endpoint should not be passed a parameter
|
//this endpoint should not be passed a parameter
|
||||||
if (!string.IsNullOrWhiteSpace(parameter))
|
if (!string.IsNullOrWhiteSpace(parameter))
|
||||||
|
|||||||
45
src/NetrunnerDb.Net/Responses/Decklist.cs
Normal file
45
src/NetrunnerDb.Net/Responses/Decklist.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NetrunnerDb.Net.Responses
|
||||||
|
{
|
||||||
|
public class Decklist : BaseRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("creation")]
|
||||||
|
public string Creation { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("cards")]
|
||||||
|
public Dictionary<string, string> Cards { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public override bool IsArray { get { return false; }}
|
||||||
|
|
||||||
|
public override string EndPoint(string parameter = "")
|
||||||
|
{
|
||||||
|
//we should be passed an actual param
|
||||||
|
if (string.IsNullOrWhiteSpace(parameter))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("parameter");
|
||||||
|
}
|
||||||
|
return string.Format("/api/decklist/{0}", parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
{
|
{
|
||||||
public interface IRequest
|
public interface IRequest
|
||||||
{
|
{
|
||||||
|
bool IsArray { get; }
|
||||||
|
|
||||||
string EndPoint(string parameter = "");
|
string EndPoint(string parameter = "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
102
src/NetrunnerDb.Net/Responses/OneCard.cs
Normal file
102
src/NetrunnerDb.Net/Responses/OneCard.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NetrunnerDb.Net.Responses
|
||||||
|
{
|
||||||
|
public class OneCard : BaseRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("last-modified")]
|
||||||
|
public DateTime LastModified { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("code")]
|
||||||
|
public string Code { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("title")]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("type_code")]
|
||||||
|
public string TypeCode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("subtype")]
|
||||||
|
public string Subtype { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("subtype_code")]
|
||||||
|
public string SubtypeCode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("text")]
|
||||||
|
public string Text { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("advancementcost")]
|
||||||
|
public int Advancementcost { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("agendapoints")]
|
||||||
|
public int Agendapoints { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("faction")]
|
||||||
|
public string Faction { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("faction_code")]
|
||||||
|
public string FactionCode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("faction_letter")]
|
||||||
|
public string FactionLetter { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("illustrator")]
|
||||||
|
public string Illustrator { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("number")]
|
||||||
|
public int Number { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("quantity")]
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("setname")]
|
||||||
|
public string Setname { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("set_code")]
|
||||||
|
public string SetCode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("side")]
|
||||||
|
public string Side { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("side_code")]
|
||||||
|
public string SideCode { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("uniqueness")]
|
||||||
|
public bool Uniqueness { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("limited")]
|
||||||
|
public bool Limited { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("cyclenumber")]
|
||||||
|
public int Cyclenumber { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("ancurLink")]
|
||||||
|
public string AncurLink { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("imagesrc")]
|
||||||
|
public string Imagesrc { get; set; }
|
||||||
|
|
||||||
|
public override string EndPoint(string parameter = "")
|
||||||
|
{
|
||||||
|
//we should be passed an actual param
|
||||||
|
if (string.IsNullOrWhiteSpace(parameter))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("parameter");
|
||||||
|
}
|
||||||
|
return string.Format("/api/card/{0}", parameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace NetrunnerDb.Net.Responses
|
namespace NetrunnerDb.Net.Responses
|
||||||
{
|
{
|
||||||
public class Set : IRequest
|
public class Set : BaseRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("last-modified")]
|
[JsonProperty("last-modified")]
|
||||||
@@ -102,7 +102,7 @@ namespace NetrunnerDb.Net.Responses
|
|||||||
[JsonProperty("trash")]
|
[JsonProperty("trash")]
|
||||||
public int? Trash { get; set; }
|
public int? Trash { get; set; }
|
||||||
|
|
||||||
public string EndPoint(string parameter = "")
|
public override string EndPoint(string parameter = "")
|
||||||
{
|
{
|
||||||
//we should be passed an actual param
|
//we should be passed an actual param
|
||||||
if (string.IsNullOrWhiteSpace(parameter))
|
if (string.IsNullOrWhiteSpace(parameter))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace NetrunnerDb.Net.Responses
|
namespace NetrunnerDb.Net.Responses
|
||||||
{
|
{
|
||||||
public class Sets : IRequest
|
public class Sets : BaseRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
@@ -30,7 +30,7 @@ namespace NetrunnerDb.Net.Responses
|
|||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
public string EndPoint(string parameter = "")
|
public override string EndPoint(string parameter = "")
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(parameter))
|
if (!string.IsNullOrWhiteSpace(parameter))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user