Skip to content

Commit

Permalink
[FIXED] if statement issue with SSO Logic
Browse files Browse the repository at this point in the history
[UPDATED] Four end points to new versions
* /alliance/{alliance_id}/ from v3 to v4
* /characters/{character_id}/clones/ from v3 to v4
* /characters/{character_id}/implants/ from v1 to v2
* /status/ from v1 to v2
[UPDATED] Status ServerVersion property from `int` to `string`
[UPDATED] Alliance DateFounded propert from `string` to `DateTime`
[UPDATED] Added gzip decompression headers
  • Loading branch information
rburke-orthofi committed Jul 23, 2020
2 parents 1e4e96f + cedfe71 commit a3e01f8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ESI.NET/ESI.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.0;net461;net462;net47;net471</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2020.7.6</Version>
<Version>2020.7.22</Version>
<Authors>Psianna Archeia</Authors>
<Company>Sukebe Corporation</Company>
<Description>.NET Wrapper for the Eve Online API</Description>
Expand Down
11 changes: 10 additions & 1 deletion ESI.NET/EsiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using ESI.NET.Models.SSO;
using Microsoft.Extensions.Options;
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;

namespace ESI.NET
{
Expand All @@ -18,14 +20,21 @@ public class EsiClient : IEsiClient
public EsiClient(IOptions<EsiConfig> _config)
{
config = _config.Value;
client = new HttpClient();
client = new HttpClient(new HttpClientHandler
{
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
});

// Enforce user agent value
if (string.IsNullOrEmpty(config.UserAgent))
throw new ArgumentException("For your protection, please provide an X-User-Agent value. This can be your character name and/or project name. CCP will be more likely to contact you rather than just cut off access to ESI if you provide something that can identify you within the New Eden galaxy.");
else
client.DefaultRequestHeaders.Add("X-User-Agent", config.UserAgent);

client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));

SSO = new SsoLogic(client, config);
Alliance = new AllianceLogic(client, config);
Assets = new AssetsLogic(client, config);
Expand Down
8 changes: 4 additions & 4 deletions ESI.NET/EsiRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public enum RequestMethod
private static readonly ImmutableDictionary<string, string> EndpointVersion = new Dictionary<string, string>()
{
{"Get|/alliances/", "v2"},
{"Get|/alliances/{alliance_id}/", "v3"},
{"Get|/alliances/{alliance_id}/", "v4"},
{"Get|/alliances/{alliance_id}/contacts/", "v2"},
{"Get|/alliances/{alliance_id}/contacts/labels/", "v1"},
{"Get|/alliances/{alliance_id}/corporations/", "v2"},
Expand All @@ -113,7 +113,7 @@ public enum RequestMethod
{"Get|/characters/{character_id}/calendar/{event_id}/", "v4"},
{"Put|/characters/{character_id}/calendar/{event_id}/", "v4"},
{"Get|/characters/{character_id}/calendar/{event_id}/attendees/", "v2"},
{"Get|/characters/{character_id}/clones/", "v3"},
{"Get|/characters/{character_id}/clones/", "v4"},
{"Get|/characters/{character_id}/contacts/", "v2"},
{"Post|/characters/{character_id}/contacts/", "v2"},
{"Put|/characters/{character_id}/contacts/", "v2"},
Expand All @@ -130,7 +130,7 @@ public enum RequestMethod
{"Delete|/characters/{character_id}/fittings/{fitting_id}/", "v1"},
{"Get|/characters/{character_id}/fleet/", "v1"},
{"Get|/characters/{character_id}/fw/stats/", "v2"},
{"Get|/characters/{character_id}/implants/", "v1"},
{"Get|/characters/{character_id}/implants/", "v2"},
{"Get|/characters/{character_id}/industry/jobs/", "v1"},
{"Get|/characters/{character_id}/killmails/recent/", "v1"},
{"Get|/characters/{character_id}/location/", "v2"},
Expand Down Expand Up @@ -259,7 +259,7 @@ public enum RequestMethod
{"Get|/sovereignty/campaigns/", "v1"},
{"Get|/sovereignty/map/", "v1"},
{"Get|/sovereignty/structures/", "v1"},
{"Get|/status/", "v1"},
{"Get|/status/", "v2"},
{"Post|/ui/autopilot/waypoint/", "v2"},
{"Post|/ui/openwindow/contract/", "v1"},
{"Post|/ui/openwindow/information/", "v1"},
Expand Down
2 changes: 1 addition & 1 deletion ESI.NET/EsiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public EsiResponse(HttpResponseMessage response, string path, string version)
{"Put|/corporations/{corporation_id}/structures/{structure_id}/", "Structure vulnerability window updated"},

//Fittings
{"Delete|/characters/{character_id}/fittings/{fitting_id}/", ""},
{"Delete|/characters/{character_id}/fittings/{fitting_id}/", "Fitting deleted"},

//Fleets
{"Put|/fleets/{fleet_id}/", "Fleet updated"},
Expand Down
2 changes: 1 addition & 1 deletion ESI.NET/Logic/_SSOLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<SsoToken> GetToken(GrantType grantType, string code, string co

var response = await responseBase.Content.ReadAsStringAsync();

if (responseBase.StatusCode == HttpStatusCode.OK)
if (responseBase.StatusCode != HttpStatusCode.OK)
{
var error = JsonConvert.DeserializeAnonymousType(response, new { error_description = string.Empty }).error_description;
throw new ArgumentException(error);
Expand Down
3 changes: 2 additions & 1 deletion ESI.NET/Models/Alliance/Alliance.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Newtonsoft.Json;
using System;

namespace ESI.NET.Models.Alliance
{
Expand All @@ -11,7 +12,7 @@ public class Alliance
public int CreatorId { get; set; }

[JsonProperty("date_founded")]
public string DateFounded { get; set; }
public DateTime DateFounded { get; set; }

[JsonProperty("executor_corporation_id")]
public int ExecutorCorporationId { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion ESI.NET/Models/Status/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Status
public int Players { get; set; }

[JsonProperty("server_version")]
public int ServerVersion { get; set; }
public string ServerVersion { get; set; }

[JsonProperty("start_time")]
public DateTime StartTime { get; set; }
Expand Down

0 comments on commit a3e01f8

Please sign in to comment.