-
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.
Move to new api. Migrate virtual tables and lines.
- Loading branch information
Showing
30 changed files
with
384 additions
and
261 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
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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace SkgtService.Models.Json; | ||
|
||
public class Arrival | ||
{ | ||
public string Time { get; set; } | ||
[JsonProperty("t")] | ||
public int Minutes { get; set; } | ||
public bool AC { get; set; } | ||
public bool Bikes { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/TramlineFive/SkgtService/Models/Json/LineArrivalInfo.cs
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,19 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Text; | ||
|
||
namespace SkgtService.Models.Json; | ||
|
||
public class LineArrivalInfo | ||
{ | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public TransportType Type { get; set; } | ||
[JsonProperty("route_name")] | ||
public string RouteName { get; set; } | ||
[JsonProperty("st_name")] | ||
public string StName { get; set; } | ||
public List<Arrival> Details { 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 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
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 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,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SkgtService.Parsers | ||
{ | ||
public class SofiaHttpClient | ||
{ | ||
private HttpClient httpClient; | ||
private HttpClientHandler clientHandler; | ||
private CookieContainer cookies; | ||
|
||
private const string BASE_URL = "https://sofiatraffic.bg"; | ||
|
||
public SofiaHttpClient() | ||
{ | ||
cookies = new CookieContainer(); | ||
clientHandler = new HttpClientHandler() { CookieContainer = cookies }; | ||
httpClient = new HttpClient(clientHandler); | ||
} | ||
|
||
public async Task<HttpResponseMessage> PostAsync(string url, HttpContent content) | ||
{ | ||
if (cookies.Count == 0) | ||
{ | ||
await httpClient.GetAsync(BASE_URL); | ||
} | ||
|
||
Cookie token = cookies.GetAllCookies()["XSRF-TOKEN"]; | ||
if (token == null) | ||
{ | ||
return null; | ||
} | ||
|
||
HttpRequestMessage request = new HttpRequestMessage() | ||
{ | ||
Method = HttpMethod.Post, | ||
Content = content, | ||
RequestUri = new Uri(url) | ||
}; | ||
|
||
|
||
request.Headers.Add("X-Xsrf-Token", Uri.UnescapeDataString(token.Value)); | ||
return await httpClient.SendAsync(request); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.