Renamed RestService -> ApiService

This commit is contained in:
Gordon Pedersen 2024-07-16 10:45:33 +10:00
parent cee1c3dfd2
commit cc779051bf
15 changed files with 18 additions and 19 deletions

View file

@ -5,16 +5,15 @@ using System.Diagnostics;
using System.Net.Http.Json; using System.Net.Http.Json;
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.RegularExpressions;
namespace Neighbourhood.omg.lol namespace Neighbourhood.omg.lol
{ {
public class RestService { public class ApiService {
HttpClient _client; HttpClient _client;
JsonSerializerOptions _serializerOptions; JsonSerializerOptions _serializerOptions;
public const string BaseUrl = "https://api.omg.lol"; public const string BaseUrl = "https://api.omg.lol";
public RestService(string? token = null) { public ApiService(string? token = null) {
_client = new HttpClient(); _client = new HttpClient();
_client.BaseAddress = new Uri(BaseUrl); _client.BaseAddress = new Uri(BaseUrl);
_client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue(App.Name, App.Version)); _client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue(App.Name, App.Version));

View file

@ -155,9 +155,9 @@ namespace Neighbourhood.omg.lol {
} }
// api service // api service
private RestService api { get; set; } private ApiService api { get; set; }
public State(RestService restService) { public State(ApiService restService) {
api = restService; api = restService;
} }

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
<div class="overlay" data-ui="#@id"></div> <div class="overlay" data-ui="#@id"></div>
<dialog id="@id"> <dialog id="@id">

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@inject NavigationManager navigationManager @inject NavigationManager navigationManager
<div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div> <div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div>

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
<div class="overlay" data-ui="#@id"></div> <div class="overlay" data-ui="#@id"></div>
<dialog id="@id"> <dialog id="@id">

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@if(Html != null) { @if(Html != null) {
<iframe id="@id" frameborder="0" scrolling="no" srcdoc="@Html" onload="() => iframeResize({ license: 'GPLv3' })"></iframe> <iframe id="@id" frameborder="0" scrolling="no" srcdoc="@Html" onload="() => iframeResize({ license: 'GPLv3' })"></iframe>
} }

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@inject NavigationManager navigationManager @inject NavigationManager navigationManager
<div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div> <div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div>

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@inject NavigationManager navigationManager @inject NavigationManager navigationManager
<div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div> <div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div>

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@inject NavigationManager navigationManager @inject NavigationManager navigationManager
@inject NavigatorService navigatorService @inject NavigatorService navigatorService

View file

@ -1,6 +1,6 @@
@page "/editNow" @page "/editNow"
@inject NavigationManager Nav @inject NavigationManager Nav
@inject RestService api @inject ApiService api
@inject State State @inject State State
@inject IJSRuntime JS @inject IJSRuntime JS

View file

@ -1,6 +1,6 @@
@page "/editProfile" @page "/editProfile"
@inject NavigationManager Nav @inject NavigationManager Nav
@inject RestService api @inject ApiService api
@inject State State @inject State State
@inject IJSRuntime JS @inject IJSRuntime JS

View file

@ -1,6 +1,6 @@
@inject IJSRuntime JS @inject IJSRuntime JS
@inject State State @inject State State
@inject RestService api @inject ApiService api
@inject NavigationManager navigationManager @inject NavigationManager navigationManager
<div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div> <div class="overlay @(Active ? "active" : string.Empty)" data-ui="#@id"></div>

View file

@ -12,7 +12,7 @@ namespace Neighbourhood.omg.lol {
builder.Services.AddMauiBlazorWebView(); builder.Services.AddMauiBlazorWebView();
builder.Services.AddTransient<LoginWebViewPage>(); builder.Services.AddTransient<LoginWebViewPage>();
builder.Services.AddSingleton<RestService>(); builder.Services.AddSingleton<ApiService>();
builder.Services.AddSingleton<State>(); builder.Services.AddSingleton<State>();
builder.Services.AddSingleton<NavigatorService>(); builder.Services.AddSingleton<NavigatorService>();

View file

@ -13,7 +13,7 @@
public string? SampleProfile { get; set; } = string.Empty; public string? SampleProfile { get; set; } = string.Empty;
public PreviewCssData? PreviewCssData { public PreviewCssData? PreviewCssData {
get => new RestService().Deserialize<PreviewCssData>(this.PreviewCss); get => new ApiService().Deserialize<PreviewCssData>(this.PreviewCss);
} }
} }
} }

View file

@ -10,13 +10,13 @@ public partial class LoginWebViewPage : ContentPage
private AuthenticationStateProvider AuthStateProvider { get; set; } private AuthenticationStateProvider AuthStateProvider { get; set; }
private NavigatorService NavigatorService { get; set; } private NavigatorService NavigatorService { get; set; }
private IConfiguration Configuration { get; set; } private IConfiguration Configuration { get; set; }
private RestService api { get; set; } private ApiService api { get; set; }
private string? client_id; private string? client_id;
private string? client_secret; private string? client_secret;
private string? redirect_uri; private string? redirect_uri;
public LoginWebViewPage(AuthenticationStateProvider authStateProvider, NavigatorService navigatorService, IConfiguration configuration, RestService restService) public LoginWebViewPage(AuthenticationStateProvider authStateProvider, NavigatorService navigatorService, IConfiguration configuration, ApiService restService)
{ {
this.AuthStateProvider = authStateProvider; this.AuthStateProvider = authStateProvider;
this.NavigatorService = navigatorService; this.NavigatorService = navigatorService;