/
Schema.cs
84 lines (63 loc) · 2.12 KB
/
Schema.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using Newtonsoft.Json;
namespace SteamBot
{
public class Schema
{
public static Schema FetchSchema (string apiKey)
{
var url = "http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=" + apiKey;
string result = SteamWeb.Fetch (url, "GET");
SchemaResult schemaResult = JsonConvert.DeserializeObject<SchemaResult> (result);
return schemaResult.result ?? null;
}
[JsonProperty("status")]
public int Status { get; set; }
[JsonProperty("items_game_url")]
public string ItemsGameUrl { get; set; }
[JsonProperty("items")]
public Item[] Items { get; set; }
[JsonProperty("originNames")]
public ItemOrigin[] OriginNames { get; set; }
/// <summary>
/// Find an SchemaItem by it's defindex.
/// </summary>
public Item GetItem (int defindex)
{
foreach (Item item in Items)
{
if (item.Defindex == defindex)
return item;
}
return null;
}
public class ItemOrigin
{
[JsonProperty("origin")]
public int Origin { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
public class Item
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("defindex")]
public ushort Defindex { get; set; }
[JsonProperty("item_class")]
public string ItemClass { get; set; }
[JsonProperty("item_type_name")]
public string ItemTypeName { get; set; }
[JsonProperty("item_name")]
public string ItemName { get; set; }
[JsonProperty("craft_material_type")]
public string CraftMaterialType { get; set; }
[JsonProperty("used_by_classes")]
public string[] UsableByClasses { get; set; }
}
protected class SchemaResult
{
public Schema result { get; set; }
}
}
}