-
Notifications
You must be signed in to change notification settings - Fork 0
/
StockFighterFactory.cs
45 lines (40 loc) · 1.32 KB
/
StockFighterFactory.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
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace StockFighter
{
public class StockFighterFactory
{
private HttpClient Client = null;
public StockFighterFactory(string authorization)
{
this.Client = new HttpClient();
this.Client.BaseAddress = new Uri(@"https://api.stockfighter.io");
this.Client.DefaultRequestHeaders.Add(
"X-Starfighter-Authorization", authorization);
Initialize();
}
private void Initialize()
{
JsonConvert.DefaultSettings = (() =>
{
var settings = new JsonSerializerSettings();
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
settings.Converters.Add(new StringEnumConverter { CamelCaseText = false });
settings.NullValueHandling = NullValueHandling.Ignore;
return settings;
});
}
public Venue GetVenue(string venueSymbol)
{
var venue = new Venue(venueSymbol, this.Client);
return venue;
}
}
}