-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added and removed a few files. The two APi now works, and can output …
…data as required.
- Loading branch information
Showing
21 changed files
with
412 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Alertnity | ||
{ | ||
internal class ApiMethods | ||
{ | ||
public static PostcodeApiResponse PostcodeApiReturnJson(string Url) | ||
{ | ||
using (var client = new HttpClient()) | ||
{ | ||
var endpoint = new Uri(Url); | ||
var result = client.GetAsync(endpoint).Result; | ||
var json = result.Content.ReadAsStringAsync().Result; | ||
var postcodeApiResponseValue = JsonSerializer.Deserialize<PostcodeApiResponse>(json, new JsonSerializerOptions | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase | ||
}); | ||
return postcodeApiResponseValue; | ||
} | ||
} | ||
|
||
public static List<PostcodeConverter> SavePostcodeApiResponse(PostcodeApiResponse postcodeApiResponseValue) | ||
{ | ||
|
||
List<PostcodeConverter> converters = new List<PostcodeConverter>(); | ||
|
||
if (postcodeApiResponseValue != null && postcodeApiResponseValue.Result != null) | ||
{ | ||
foreach (var result in postcodeApiResponseValue.Result) | ||
{ | ||
PostcodeConverter converter = new PostcodeConverter | ||
{ | ||
Latitude = result.Latitude, | ||
Longitude = result.Longitude | ||
}; | ||
converters.Add(converter); | ||
|
||
Console.WriteLine("Longitude: " + result.Longitude); | ||
Console.WriteLine("Latitude: " + result.Latitude); | ||
Console.WriteLine("............................"); | ||
} | ||
|
||
} | ||
else | ||
{ | ||
Console.WriteLine("Response is null or nothing contained in the api."); | ||
} | ||
return converters; | ||
} | ||
|
||
public static string CreatePolyParameter(List<PostcodeConverter> converters) | ||
{ | ||
var polyParts = converters.Select(c => $"{c.Latitude},{c.Longitude}"); | ||
return string.Join(":", polyParts); | ||
} | ||
|
||
public static Outcome[] PoliceApiReturnJson(string Url) | ||
{ | ||
|
||
using (var client = new HttpClient()) | ||
{ | ||
var endpoint = new Uri(Url); | ||
var result = client.GetAsync(endpoint).Result; | ||
|
||
var json = result.Content.ReadAsStringAsync().Result; | ||
|
||
var crimeIncidents = JsonSerializer.Deserialize<Outcome[]>(json, new JsonSerializerOptions | ||
{ | ||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, | ||
}); | ||
return crimeIncidents; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alertnity | ||
{ | ||
public class Codes | ||
{ | ||
public string AdminDistrict { get; set; } | ||
public string AdminCounty { get; set; } | ||
public string AdminWard { get; set; } | ||
public string Parish { get; set; } | ||
public string ParliamentaryConstituency { get; set; } | ||
public string ParliamentaryConstituency2024 { get; set; } | ||
public string Ccg { get; set; } | ||
public string CcgId { get; set; } | ||
public string Ced { get; set; } | ||
public string Nuts { get; set; } | ||
public string Lsoa { get; set; } | ||
public string Msoa { get; set; } | ||
public string Lau2 { get; set; } | ||
public string Pfa { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace Alertnity | ||
{ | ||
public class Location | ||
{ | ||
public string latitude { get; set; } | ||
public Street street { get; set; } | ||
public string longitude { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static Alertnity.Program; | ||
|
||
namespace Alertnity | ||
{ | ||
public class Outcome | ||
{ | ||
public string category { get; set; } | ||
public string location_type { get; set; } | ||
public Location location { get; set; } | ||
public string context { get; set; } | ||
public Outcome_Status outcome_status { get; set; } | ||
public string persistent_id { get; set; } | ||
public int id { get; set; } | ||
public string location_subtype { get; set; } | ||
public string month { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Alertnity | ||
{ | ||
public class Outcome_Status | ||
{ | ||
|
||
|
||
public string Category { get; set; } | ||
public string Month{ get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static Alertnity.Program; | ||
|
||
namespace Alertnity | ||
{ | ||
public class PoliceApiResponse | ||
{ | ||
public List<Outcome> outcome { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace Alertnity | ||
{ | ||
internal class Post | ||
{ | ||
public int ID { get; set; } | ||
|
||
public UserInfo User { get; set; } | ||
|
||
public string Title { get; set; } | ||
public string Content { get; set; } | ||
public DateTime Timestamp { get; set; } | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static Alertnity.Program; | ||
|
||
namespace Alertnity | ||
{ | ||
public class PostcodeApiResponse | ||
{ | ||
public int Status { get; set; } | ||
public Result[] Result { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.