view rank get endpoint client service method for movies added
This commit is contained in:
@@ -5,6 +5,7 @@ public class Endpoints
|
||||
public string Base { get; set; }
|
||||
public Accounts Accounts { get; set; }
|
||||
public Genres Genres { get; set; }
|
||||
public Movies Movies { get; set; }
|
||||
public Media Media { get; set; }
|
||||
public Movies Movies { get; set; }
|
||||
public Series Series { get; set; }
|
||||
}
|
||||
@@ -3,9 +3,10 @@
|
||||
public class Movies
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string GetAll { get; set; }
|
||||
public string Get { get; set; }
|
||||
public string Post { get; set; }
|
||||
public string Put { get; set; }
|
||||
public string Delete { get; set; }
|
||||
public string GetAllMovies { get; set; }
|
||||
public string GetMovie { get; set; }
|
||||
public string PostMovie { get; set; }
|
||||
public string PutMovie { get; set; }
|
||||
public string DeleteMovie { get; set; }
|
||||
public string GetMoviesViewRank { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace WatchIt.Website.Services.Utility.Configuration.Model;
|
||||
|
||||
public class Series
|
||||
{
|
||||
public string Base { get; set; }
|
||||
public string GetAllSeries { get; set; }
|
||||
public string GetSeries { get; set; }
|
||||
public string PostSeries { get; set; }
|
||||
public string PutSeries { get; set; }
|
||||
public string DeleteSeries { get; set; }
|
||||
public string GetSeriesViewRank { get; set; }
|
||||
}
|
||||
@@ -4,9 +4,9 @@ namespace WatchIt.Website.Services.WebAPI.Movies;
|
||||
|
||||
public interface IMoviesWebAPIService
|
||||
{
|
||||
Task GetAll(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null);
|
||||
Task Post(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task Get(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task Put(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task Delete(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetAllMovies(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null);
|
||||
Task PostMovie(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task GetMovie(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null);
|
||||
Task PutMovie(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
Task DeleteMovie(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using WatchIt.Common.Model.Movies;
|
||||
using WatchIt.Common.Services.HttpClient;
|
||||
using WatchIt.Website.Services.Utility.Configuration;
|
||||
@@ -28,11 +30,14 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
#region Main
|
||||
|
||||
public async Task GetAll(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null)
|
||||
public async Task GetAllMovies(MovieQueryParameters? query = null, Action<IEnumerable<MovieResponse>>? successAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetAll);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetAllMovies);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
request.Query = query;
|
||||
@@ -42,9 +47,21 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Post(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
public async Task GetMovie(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Post);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task PostMovie(MovieRequest data, Action<MovieResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.PostMovie);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
|
||||
request.Body = data;
|
||||
@@ -57,21 +74,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Get(long id, Action<MovieResponse>? successAction = null, Action? notFoundAction = null)
|
||||
public async Task PutMovie(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Get, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor404NotFound(notFoundAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Put(long id, MovieRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Put, id);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.PutMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
|
||||
request.Body = data;
|
||||
@@ -84,9 +89,9 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
public async Task Delete(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
public async Task DeleteMovie(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.Delete, id);
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.DeleteMovie, id);
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
|
||||
|
||||
@@ -96,6 +101,44 @@ public class MoviesWebAPIService : BaseWebAPIService, IMoviesWebAPIService
|
||||
.RegisterActionFor403Forbidden(forbiddenAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region View count
|
||||
|
||||
public async Task GetMoviesViewRank(int? first = null, int? days = null, Action<IEnumerable<MovieResponse>>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null)
|
||||
{
|
||||
string url = GetUrl(EndpointsConfiguration.Movies.GetMoviesViewRank);
|
||||
if (first.HasValue || days.HasValue)
|
||||
{
|
||||
StringBuilder urlBuilder = new StringBuilder(url);
|
||||
urlBuilder.Append('?');
|
||||
bool firstParameter = true;
|
||||
if (first.HasValue)
|
||||
{
|
||||
urlBuilder.Append($"first={first.Value}");
|
||||
firstParameter = false;
|
||||
}
|
||||
if (days.HasValue)
|
||||
{
|
||||
if (!firstParameter)
|
||||
{
|
||||
urlBuilder.Append('&');
|
||||
}
|
||||
urlBuilder.Append($"days={days.Value}");
|
||||
}
|
||||
url = urlBuilder.ToString();
|
||||
}
|
||||
|
||||
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
|
||||
|
||||
HttpResponse response = await _httpClientService.SendRequestAsync(request);
|
||||
response.RegisterActionFor2XXSuccess(successAction)
|
||||
.RegisterActionFor400BadRequest(badRequestAction)
|
||||
.ExecuteAction();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user