roles endpoints clients

This commit is contained in:
2024-10-06 23:16:53 +02:00
Unverified
parent eb8d87dfe6
commit dcc86b4e9e
11 changed files with 261 additions and 14 deletions

View File

@@ -37,6 +37,7 @@ public class RolesController : ControllerBase
[HttpGet("actor/{id}")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<ActorRoleResponse>), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> GetActorRole([FromRoute]Guid id) => await _rolesControllerService.GetActorRole(id);
[HttpPut("actor/{id}")]

View File

@@ -18,4 +18,8 @@ public class Media
public string GetMediaPhotos { get; set; }
public string GetMediaPhotoRandomBackground { get; set; }
public string PostMediaPhoto { get; set; }
public string GetMediaAllActorRoles { get; set; }
public string PostMediaActorRole { get; set; }
public string GetMediaAllCreatorRoles { get; set; }
public string PostMediaCreatorRole { get; set; }
}

View File

@@ -12,4 +12,8 @@ public class Persons
public string GetPersonPhoto { get; set; }
public string PutPersonPhoto { get; set; }
public string DeletePersonPhoto { get; set; }
public string GetPersonAllActorRoles { get; set; }
public string PostPersonActorRole { get; set; }
public string GetPersonAllCreatorRoles { get; set; }
public string PostPersonCreatorRole { get; set; }
}

View File

@@ -3,10 +3,16 @@ namespace WatchIt.Website.Services.Utility.Configuration.Model;
public class Roles
{
public string Base { get; set; }
public string GetActorRole { get; set; }
public string PutActorRole { get; set; }
public string DeleteActorRole { get; set; }
public string GetAllActorRoleTypes { get; set; }
public string GetActorRoleType { get; set; }
public string PostActorRoleType { get; set; }
public string DeleteActorRoleType { get; set; }
public string GetCreatorRole { get; set; }
public string PutCreatorRole { get; set; }
public string DeleteCreatorRole { get; set; }
public string GetAllCreatorRoleTypes { get; set; }
public string GetCreatorRoleType { get; set; }
public string PostCreatorRoleType { get; set; }

View File

@@ -2,6 +2,7 @@
using WatchIt.Common.Model.Media;
using WatchIt.Common.Model.Photos;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Model.Roles;
namespace WatchIt.Website.Services.WebAPI.Media;
@@ -27,4 +28,9 @@ public interface IMediaWebAPIService
Task GetMediaPhotos(long mediaId, PhotoQueryParameters? query = null, Action<IEnumerable<PhotoResponse>>? successAction = null, Action? notFoundAction = null);
Task GetMediaPhotoRandomBackground(long mediaId, Action<PhotoResponse>? successAction = null, Action? notFoundAction = null);
Task PostMediaPhoto(long mediaId, MediaPhotoRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
Task PostMediaActorRole(long id, IActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
Task PostMediaCreatorRole(long id, ICreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
}

View File

@@ -2,6 +2,7 @@
using WatchIt.Common.Model.Media;
using WatchIt.Common.Model.Photos;
using WatchIt.Common.Model.Rating;
using WatchIt.Common.Model.Roles;
using WatchIt.Common.Services.HttpClient;
using WatchIt.Website.Services.Utility.Configuration;
using WatchIt.Website.Services.Utility.Configuration.Model;
@@ -258,6 +259,64 @@ public class MediaWebAPIService : BaseWebAPIService, IMediaWebAPIService
#endregion
#region Roles
public async Task GetMediaAllActorRoles(long id, ActorRoleMediaQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null)
{
string url = GetUrl(EndpointsConfiguration.Media.GetMediaAllActorRoles, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
request.Query = query;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.ExecuteAction();
}
public async Task PostMediaActorRole(long id, IActorRoleMediaRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Media.PostMediaActorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
public async Task GetMediaAllCreatorRoles(long id, CreatorRoleMediaQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null)
{
string url = GetUrl(EndpointsConfiguration.Media.GetMediaAllCreatorRoles, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
request.Query = query;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.ExecuteAction();
}
public async Task PostMediaCreatorRole(long id, ICreatorRoleMediaRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Media.PostMediaCreatorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
#endregion
#endregion

View File

@@ -1,4 +1,5 @@
using WatchIt.Common.Model.Persons;
using WatchIt.Common.Model.Roles;
namespace WatchIt.Website.Services.WebAPI.Persons;
@@ -15,4 +16,9 @@ public interface IPersonsWebAPIService
Task GetPersonPhoto(long id, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? notFoundAction = null);
Task PutPersonPhoto(long id, PersonPhotoRequest data, Action<PersonPhotoResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task DeletePersonPhoto(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null);
Task PostPersonActorRole(long id, IActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null);
Task PostPersonCreatorRole(long id, ICreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
}

View File

@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Primitives;
using WatchIt.Common.Model.Persons;
using WatchIt.Common.Model.Roles;
using WatchIt.Common.Services.HttpClient;
using WatchIt.Website.Services.Utility.Configuration;
using WatchIt.Website.Services.WebAPI.Common;
@@ -185,6 +186,64 @@ public class PersonsWebAPIService : BaseWebAPIService, IPersonsWebAPIService
.ExecuteAction();
}
#endregion
#region Roles
public async Task GetPersonAllActorRoles(long id, ActorRolePersonQueryParameters? query = null, Action<IEnumerable<ActorRoleResponse>>? successAction = null)
{
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonAllActorRoles, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
request.Query = query;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.ExecuteAction();
}
public async Task PostPersonActorRole(long id, IActorRolePersonRequest data, Action<ActorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonActorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
public async Task GetPersonAllCreatorRoles(long id, CreatorRolePersonQueryParameters? query = null, Action<IEnumerable<CreatorRoleResponse>>? successAction = null)
{
string url = GetUrl(EndpointsConfiguration.Persons.GetPersonAllCreatorRoles, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
request.Query = query;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.ExecuteAction();
}
public async Task PostPersonCreatorRole(long id, ICreatorRolePersonRequest data, Action<CreatorRoleResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Persons.PostPersonCreatorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Post, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
#endregion
#endregion

View File

@@ -4,12 +4,18 @@ namespace WatchIt.Website.Services.WebAPI.Roles;
public interface IRolesWebAPIService
{
Task GetActorRole(Guid id, Action<ActorRoleResponse>? successAction = null, Action? notFoundAction = null);
Task PutActorRole(Guid id, ActorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
Task GetActorRoleType(long id, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
Task GetActorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
Task PostActorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task DeleteActorRoleType(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetCreatorRole(Guid id, Action<CreatorRoleResponse>? successAction = null, Action? notFoundAction = null);
Task PutCreatorRole(Guid id, CreatorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null);
Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null);
Task GetCreatorRoleType(long id, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null);
Task PostCreatorRoleType(RoleTypeRequest data, Action<RoleTypeResponse>? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task DeleteCreatorRoleType(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
Task DeleteCreatorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null);
}

View File

@@ -29,6 +29,47 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
#region PUBLIC METHODS
#region Actor
public async Task GetActorRole(Guid id, Action<ActorRoleResponse>? successAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.GetActorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor404NotFound(notFoundAction)
.ExecuteAction();
}
public async Task PutActorRole(Guid id, ActorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.PutActorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.RegisterActionFor404NotFound(notFoundAction)
.ExecuteAction();
}
public async Task DeleteActorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
public async Task GetAllActorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null)
{
@@ -42,9 +83,9 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
.ExecuteAction();
}
public async Task GetActorRoleType(long id, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null)
public async Task GetActorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.GetActorRoleType, id);
string url = GetUrl(EndpointsConfiguration.Roles.GetActorRoleType, typeId);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
@@ -69,9 +110,9 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
.ExecuteAction();
}
public async Task DeleteActorRoleType(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
public async Task DeleteActorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRoleType, id);
string url = GetUrl(EndpointsConfiguration.Roles.DeleteActorRoleType, typeId);
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
@@ -86,6 +127,47 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
#region Creator
public async Task GetCreatorRole(Guid id, Action<CreatorRoleResponse>? successAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor404NotFound(notFoundAction)
.ExecuteAction();
}
public async Task PutCreatorRole(Guid id, CreatorRoleRequest data, Action? successAction = null, Action<IDictionary<string, string[]>>? badRequestAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.PutCreatorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Put, url);
request.Body = data;
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor400BadRequest(badRequestAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.RegisterActionFor404NotFound(notFoundAction)
.ExecuteAction();
}
public async Task DeleteCreatorRole(Guid id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRole, id);
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);
HttpResponse response = await _httpClientService.SendRequestAsync(request);
response.RegisterActionFor2XXSuccess(successAction)
.RegisterActionFor401Unauthorized(unauthorizedAction)
.RegisterActionFor403Forbidden(forbiddenAction)
.ExecuteAction();
}
public async Task GetAllCreatorRoleTypes(RoleTypeQueryParameters? query = null, Action<IEnumerable<RoleTypeResponse>>? successAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.GetAllCreatorRoleTypes);
@@ -98,9 +180,9 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
.ExecuteAction();
}
public async Task GetCreatorRoleType(long id, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null)
public async Task GetCreatorRoleType(long typeId, Action<RoleTypeResponse>? successAction = null, Action? notFoundAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRoleType, id);
string url = GetUrl(EndpointsConfiguration.Roles.GetCreatorRoleType, typeId);
HttpRequest request = new HttpRequest(HttpMethodType.Get, url);
@@ -125,9 +207,9 @@ public class RolesWebAPIService : BaseWebAPIService, IRolesWebAPIService
.ExecuteAction();
}
public async Task DeleteCreatorRoleType(long id, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
public async Task DeleteCreatorRoleType(long typeId, Action? successAction = null, Action? unauthorizedAction = null, Action? forbiddenAction = null)
{
string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRoleType, id);
string url = GetUrl(EndpointsConfiguration.Roles.DeleteCreatorRoleType, typeId);
HttpRequest request = new HttpRequest(HttpMethodType.Delete, url);

View File

@@ -51,7 +51,11 @@
"DeleteMediaPoster": "/{0}/poster",
"GetMediaPhotos": "/{0}/photos",
"GetMediaPhotoRandomBackground": "/{0}/photos/random_background",
"PostMediaPhoto": "/{0}/photos"
"PostMediaPhoto": "/{0}/photos",
"GetMediaAllActorRoles": "/{0}/roles/actor",
"PostMediaActorRole": "/{0}/roles/actor",
"GetMediaAllCreatorRoles": "/{0}/roles/creator",
"PostMediaCreatorRole": "/{0}/roles/creator"
},
"Movies": {
"Base": "/movies",
@@ -88,14 +92,24 @@
"GetPersonsViewRank": "/view",
"GetPersonPhoto": "/{0}/photo",
"PutPersonPhoto": "/{0}/photo",
"DeletePersonPhoto": "/{0}/photo"
"DeletePersonPhoto": "/{0}/photo",
"GetPersonAllActorRoles": "/{0}/roles/actor",
"PostPersonActorRole": "/{0}/roles/actor",
"GetPersonAllCreatorRoles": "/{0}/roles/creator",
"PostPersonCreatorRole": "/{0}/roles/creator"
},
"Roles": {
"Base": "/roles",
"GetActorRole": "/actor/{0}",
"PutActorRole": "/actor/{0}",
"DeleteActorRole": "/actor/{0}",
"GetAllActorRoleTypes": "/actor/type",
"GetActorRoleType": "/actor/type/{0}",
"PostActorRoleType": "/actor/type",
"DeleteActorRoleType": "/actor/type/{0}",
"GetCreatorRole": "/creator/{0}",
"PutCreatorRole": "/creator/{0}",
"DeleteCreatorRole": "/creator/{0}",
"GetAllCreatorRoleTypes": "/creator/type",
"GetCreatorRoleType": "/creator/type/{0}",
"PostCreatorRoleType": "/creator/type",