diff --git a/Bet.cs b/Data/Bet.cs similarity index 97% rename from Bet.cs rename to Data/Bet.cs index ca6977e..e1c45d9 100644 --- a/Bet.cs +++ b/Data/Bet.cs @@ -1,7 +1,8 @@ using System; using Newtonsoft.Json; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class Bet { diff --git a/BetAmount.cs b/Data/BetAmount.cs similarity index 89% rename from BetAmount.cs rename to Data/BetAmount.cs index 1cc04ce..1e0ccc9 100644 --- a/BetAmount.cs +++ b/Data/BetAmount.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] public class BetAmount diff --git a/ClientBalance.cs b/Data/ClientBalance.cs similarity index 93% rename from ClientBalance.cs rename to Data/ClientBalance.cs index e1fd269..89d7079 100644 --- a/ClientBalance.cs +++ b/Data/ClientBalance.cs @@ -1,6 +1,6 @@ using Newtonsoft.Json; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class ClientBalance { diff --git a/CurrenciesResponse.cs b/Data/CurrenciesResponse.cs similarity index 90% rename from CurrenciesResponse.cs rename to Data/CurrenciesResponse.cs index 73b1443..0ec5248 100644 --- a/CurrenciesResponse.cs +++ b/Data/CurrenciesResponse.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("rsp")] diff --git a/Currency.cs b/Data/Currency.cs similarity index 89% rename from Currency.cs rename to Data/Currency.cs index 354b868..eb9cb03 100644 --- a/Currency.cs +++ b/Data/Currency.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("currency")] diff --git a/Event.cs b/Data/Event.cs similarity index 96% rename from Event.cs rename to Data/Event.cs index 7520ba2..be07233 100644 --- a/Event.cs +++ b/Data/Event.cs @@ -1,8 +1,9 @@ using System; using System.Collections.Generic; using System.Xml.Serialization; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("event")] diff --git a/FeedResponse.cs b/Data/FeedResponse.cs similarity index 87% rename from FeedResponse.cs rename to Data/FeedResponse.cs index d5973ad..a42b3a3 100644 --- a/FeedResponse.cs +++ b/Data/FeedResponse.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("rsp")] diff --git a/FeedSport.cs b/Data/FeedSport.cs similarity index 91% rename from FeedSport.cs rename to Data/FeedSport.cs index e9d3a31..b6c1541 100644 --- a/FeedSport.cs +++ b/Data/FeedSport.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("sport")] diff --git a/GetBetsResponse.cs b/Data/GetBetsResponse.cs similarity index 85% rename from GetBetsResponse.cs rename to Data/GetBetsResponse.cs index 928bd2b..cf1e647 100644 --- a/GetBetsResponse.cs +++ b/Data/GetBetsResponse.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class GetBetsResponse { diff --git a/GetInRunningResponse.cs b/Data/GetInRunningResponse.cs similarity index 83% rename from GetInRunningResponse.cs rename to Data/GetInRunningResponse.cs index 9a39df0..a1cc492 100644 --- a/GetInRunningResponse.cs +++ b/Data/GetInRunningResponse.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class GetInRunningResponse { diff --git a/GetLineResponse.cs b/Data/GetLineResponse.cs similarity index 96% rename from GetLineResponse.cs rename to Data/GetLineResponse.cs index 5a959e9..b25748c 100644 --- a/GetLineResponse.cs +++ b/Data/GetLineResponse.cs @@ -1,7 +1,8 @@ using System; using Newtonsoft.Json; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class GetLineResponse { diff --git a/League.cs b/Data/League.cs similarity index 91% rename from League.cs rename to Data/League.cs index 391bc93..4a9c7dd 100644 --- a/League.cs +++ b/Data/League.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("league")] diff --git a/LeaguesResponse.cs b/Data/LeaguesResponse.cs similarity index 90% rename from LeaguesResponse.cs rename to Data/LeaguesResponse.cs index da6ccdc..0be4521 100644 --- a/LeaguesResponse.cs +++ b/Data/LeaguesResponse.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("rsp")] diff --git a/MoneyLine.cs b/Data/MoneyLine.cs similarity index 90% rename from MoneyLine.cs rename to Data/MoneyLine.cs index cc6444a..78f34e1 100644 --- a/MoneyLine.cs +++ b/Data/MoneyLine.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("moneyLine")] diff --git a/Period.cs b/Data/Period.cs similarity index 96% rename from Period.cs rename to Data/Period.cs index 933299e..3b5689b 100644 --- a/Period.cs +++ b/Data/Period.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("period")] diff --git a/PlaceBetRequest.cs b/Data/PlaceBetRequest.cs similarity index 95% rename from PlaceBetRequest.cs rename to Data/PlaceBetRequest.cs index e7e16c1..e06403c 100644 --- a/PlaceBetRequest.cs +++ b/Data/PlaceBetRequest.cs @@ -1,7 +1,8 @@ using System; using Newtonsoft.Json; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class PlaceBetRequest { @@ -14,7 +15,7 @@ public class PlaceBetRequest [JsonProperty(PropertyName = "customerReference")] // not required public string CustomerReference; - [JsonProperty(PropertyName = "ODDS_FORMAT")] + [JsonProperty(PropertyName = "oddsFormat")] public OddsFormat OddsFormat; [JsonProperty(PropertyName = "stake")] diff --git a/PlaceBetResponse.cs b/Data/PlaceBetResponse.cs similarity index 88% rename from PlaceBetResponse.cs rename to Data/PlaceBetResponse.cs index 5f85d9e..1ca7191 100644 --- a/PlaceBetResponse.cs +++ b/Data/PlaceBetResponse.cs @@ -1,7 +1,8 @@ using System; using Newtonsoft.Json; +using PinnacleWrapper.Enums; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { public class PlaceBetResponse { @@ -9,7 +10,7 @@ public class PlaceBetResponse public PlaceBetResponseStatus Status; [JsonProperty(PropertyName = "errorCode")] // If Status is PROCESSED_WITH_ERROR, errorCode will be in the response. - public PlaceBetErrorCode ErrorCode; + public PlaceBetErrorCode? ErrorCode; [JsonProperty(PropertyName = "betId")] // The bet ID of the new bet. May be empty on failure. public int? BetId; diff --git a/ResponseError.cs b/Data/ResponseError.cs similarity index 89% rename from ResponseError.cs rename to Data/ResponseError.cs index d89f088..947ad53 100644 --- a/ResponseError.cs +++ b/Data/ResponseError.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("err")] diff --git a/Sport.cs b/Data/Sport.cs similarity index 91% rename from Sport.cs rename to Data/Sport.cs index 1b2c53a..1a1c640 100644 --- a/Sport.cs +++ b/Data/Sport.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("sport")] diff --git a/SportsResponse.cs b/Data/SportsResponse.cs similarity index 90% rename from SportsResponse.cs rename to Data/SportsResponse.cs index a987c6b..e06f51b 100644 --- a/SportsResponse.cs +++ b/Data/SportsResponse.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("rsp")] diff --git a/Spread.cs b/Data/Spread.cs similarity index 93% rename from Spread.cs rename to Data/Spread.cs index 85a972c..876298e 100644 --- a/Spread.cs +++ b/Data/Spread.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("spread")] diff --git a/Team.cs b/Data/Team.cs similarity index 91% rename from Team.cs rename to Data/Team.cs index bb75ae4..5557c4d 100644 --- a/Team.cs +++ b/Data/Team.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] public class Team diff --git a/XmlResponse.cs b/Data/XmlResponse.cs similarity index 94% rename from XmlResponse.cs rename to Data/XmlResponse.cs index 601a9ee..ab6a118 100644 --- a/XmlResponse.cs +++ b/Data/XmlResponse.cs @@ -1,7 +1,7 @@ using System; using System.Xml.Serialization; -namespace PinnacleWrapper +namespace PinnacleWrapper.Data { [Serializable] [XmlRoot("rsp")] diff --git a/BetListType.cs b/Enums/BetListType.cs similarity index 68% rename from BetListType.cs rename to Enums/BetListType.cs index e88f1e0..d48c7e5 100644 --- a/BetListType.cs +++ b/Enums/BetListType.cs @@ -1,4 +1,4 @@ -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { public enum BetListType { diff --git a/BetStatus.cs b/Enums/BetStatus.cs similarity index 89% rename from BetStatus.cs rename to Enums/BetStatus.cs index 847cd98..c066774 100644 --- a/BetStatus.cs +++ b/Enums/BetStatus.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum BetStatus diff --git a/BetType.cs b/Enums/BetType.cs similarity index 87% rename from BetType.cs rename to Enums/BetType.cs index dfd793f..fbeea08 100644 --- a/BetType.cs +++ b/Enums/BetType.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum BetType diff --git a/GetLineResponseStatus.cs b/Enums/GetLineResponseStatus.cs similarity index 88% rename from GetLineResponseStatus.cs rename to Enums/GetLineResponseStatus.cs index 3aab3a7..5828508 100644 --- a/GetLineResponseStatus.cs +++ b/Enums/GetLineResponseStatus.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum GetLineResponseStatus diff --git a/InRunningState.cs b/Enums/InRunningState.cs similarity index 91% rename from InRunningState.cs rename to Enums/InRunningState.cs index 9280bfa..d426376 100644 --- a/InRunningState.cs +++ b/Enums/InRunningState.cs @@ -1,4 +1,4 @@ -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { public enum InRunningState { diff --git a/OddsFormat.cs b/Enums/OddsFormat.cs similarity index 58% rename from OddsFormat.cs rename to Enums/OddsFormat.cs index 8aeda4a..2c5e6d9 100644 --- a/OddsFormat.cs +++ b/Enums/OddsFormat.cs @@ -1,16 +1,16 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum OddsFormat { - American, - Decimal, - HongKong, - Indonesian, - Malay, + AMERICAN, + DECIMAL, + HONGKONG, + INDONESIAN, + MALAY, Fraction } } diff --git a/PlaceBetErrorCode.cs b/Enums/PlaceBetErrorCode.cs similarity index 98% rename from PlaceBetErrorCode.cs rename to Enums/PlaceBetErrorCode.cs index 626c43c..983ef2c 100644 --- a/PlaceBetErrorCode.cs +++ b/Enums/PlaceBetErrorCode.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum PlaceBetErrorCode diff --git a/PlaceBetResponseStatus.cs b/Enums/PlaceBetResponseStatus.cs similarity index 89% rename from PlaceBetResponseStatus.cs rename to Enums/PlaceBetResponseStatus.cs index 8b22657..12c2cd4 100644 --- a/PlaceBetResponseStatus.cs +++ b/Enums/PlaceBetResponseStatus.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum PlaceBetResponseStatus diff --git a/SideType.cs b/Enums/SideType.cs similarity index 84% rename from SideType.cs rename to Enums/SideType.cs index 82663ff..d28cc26 100644 --- a/SideType.cs +++ b/Enums/SideType.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum SideType diff --git a/Status.cs b/Enums/Status.cs similarity index 95% rename from Status.cs rename to Enums/Status.cs index 7dabc15..605a96b 100644 --- a/Status.cs +++ b/Enums/Status.cs @@ -1,4 +1,4 @@ -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { public enum Status { diff --git a/TeamType.cs b/Enums/TeamType.cs similarity index 85% rename from TeamType.cs rename to Enums/TeamType.cs index 651daa0..a2c9c64 100644 --- a/TeamType.cs +++ b/Enums/TeamType.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum TeamType diff --git a/WinRiskType.cs b/Enums/WinRiskType.cs similarity index 72% rename from WinRiskType.cs rename to Enums/WinRiskType.cs index 3258570..6456f67 100644 --- a/WinRiskType.cs +++ b/Enums/WinRiskType.cs @@ -1,12 +1,12 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -namespace PinnacleWrapper +namespace PinnacleWrapper.Enums { [JsonConverter(typeof(StringEnumConverter))] public enum WinRiskType { - Win, - Risk + Risk, + Win } } diff --git a/Feed.cs b/Feed.cs index c3e6c57..b7c892f 100644 --- a/Feed.cs +++ b/Feed.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Xml.Serialization; +using PinnacleWrapper.Data; namespace PinnacleWrapper { diff --git a/FeedLeague.cs b/FeedLeague.cs index e1fd9ac..7e2433e 100644 --- a/FeedLeague.cs +++ b/FeedLeague.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Xml.Serialization; +using PinnacleWrapper.Data; namespace PinnacleWrapper { diff --git a/PinnacleClient.cs b/PinnacleClient.cs index 2211a6e..e289e6f 100644 --- a/PinnacleClient.cs +++ b/PinnacleClient.cs @@ -6,6 +6,8 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; +using PinnacleWrapper.Data; +using PinnacleWrapper.Enums; namespace PinnacleWrapper { @@ -38,8 +40,7 @@ public PinnacleClient(string clientId, string password, string currencyCode, Odd // put auth header into httpclient _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String( - Encoding.ASCII.GetBytes(string.Format("{0}:{1}", - , _password)))); + Encoding.ASCII.GetBytes(string.Format("{0}:{1}", _clientId, _password)))); } protected T GetXmlAsync(string requestType, params object[] values) @@ -161,7 +162,7 @@ public Feed GetFeed(int sportId, int[] leagueIds, OddsFormat format, string curr #endregion - protected T GetJsonAsync(string requestType, params object[] values) + protected async Task GetJsonAsync(string requestType, params object[] values) { var response = _httpClient.GetAsync(string.Format(requestType, values)).Result; @@ -170,31 +171,31 @@ protected T GetJsonAsync(string requestType, params object[] values) var json = response.Content.ReadAsStringAsync().Result; // deserialise json async - var apiResponse = Task.Factory.StartNew(() => JsonConvert.DeserializeObject(json)).Result; + var apiResponse = Task.Factory.StartNew(() => JsonConvert.DeserializeObject(json)); - return apiResponse; + return await apiResponse; } // ToDo: replace requestData object type with "IJsonSerialisable" - protected T PostJsonAsync(string requestType, object requestData) + protected async Task PostJsonAsync(string requestType, object requestData) { var requestPostData = JsonConvert.SerializeObject(requestData); - var response = _httpClient.PostAsync(requestType, - new StringContent(requestPostData, Encoding.UTF8, "application/json")).Result; + var response = await _httpClient.PostAsync(requestType, + new StringContent(requestPostData, Encoding.UTF8, "application/json")); response.EnsureSuccessStatusCode(); // throw if web request failed - var json = response.Content.ReadAsStringAsync().Result; + var json = await response.Content.ReadAsStringAsync(); // deserialise async - return Task.Factory.StartNew(() => JsonConvert.DeserializeObject(json)).Result; + return await Task.Factory.StartNew(() => JsonConvert.DeserializeObject(json)); } public ClientBalance GetClientBalance() { const string uri = "client/balance"; - return GetJsonAsync(uri); + return GetJsonAsync(uri).Result; } public GetBetsResponse GetBets(BetListType type, DateTime startDate, DateTime endDate) @@ -207,7 +208,7 @@ public GetBetsResponse GetBets(BetListType type, DateTime startDate, DateTime en var uri = sb.ToString(); - return GetJsonAsync(uri); + return GetJsonAsync(uri).Result; } public GetBetsResponse GetBets(List betIds) @@ -219,12 +220,12 @@ public GetBetsResponse GetBets(List betIds) var uri = sb.ToString(); - return GetJsonAsync(uri); + return GetJsonAsync(uri).Result; } public PlaceBetResponse PlaceBet(PlaceBetRequest placeBetRequest) { - return PostJsonAsync("bets/place", placeBetRequest); + return PostJsonAsync("bets/place", placeBetRequest).Result; } /// @@ -281,13 +282,13 @@ public GetLineResponse GetLine(int sportId, int leagueId, long eventId, int peri var uri = sb.ToString(); - return GetJsonAsync(uri); + return GetJsonAsync(uri).Result; } public GetInRunningResponse GetInRunning() { const string uri = "inrunning"; - return GetJsonAsync(uri); + return GetJsonAsync(uri).Result; } } } diff --git a/PinnacleWrapper.csproj b/PinnacleWrapper.csproj index 5ab59a6..06f8b23 100644 --- a/PinnacleWrapper.csproj +++ b/PinnacleWrapper.csproj @@ -47,45 +47,45 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + +