-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/fix technical debt and add missing payroll classes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Anidem1995
wants to merge
11
commits into
master
Choose a base branch
from
fix/FixTechnicalDebtAndAddMissingPayrollClasses
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
978df34
Added interfaces for Employee and Employer services
Anidem1995 a2c4fe8
Updated Employer and Employee service references in IPersonService
Anidem1995 ca03a24
Added missing stock options class in payroll earning
Anidem1995 2ae3bb3
Removed hardcoded api version from Employee and Employer services, up…
Anidem1995 f221478
Added request validation for Employee and Employer services
Anidem1995 eb40a70
Added request validation for Stamp Service
Anidem1995 ee2242d
Updated readme.md
Anidem1995 3fc78c6
Updated package version
Anidem1995 5ac9c15
Added missing imports
Anidem1995 30cb22d
Removed duplicated entry for stamps management
Anidem1995 ee9032d
Removed duplicated entry for stamps
Anidem1995 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
| using System.Threading.Tasks; | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Models; | ||
|
|
||
| namespace Fiscalapi.Abstractions | ||
| { | ||
| /// <summary> | ||
| /// Interfaz para el servicio de Empleado — gestiona los datos del empleado anidados bajo una Persona. | ||
| /// Patrón de endpoint: api/{version}/people/{personId}/employee | ||
| /// </summary> | ||
| public interface IEmployeeService | ||
| { | ||
| Task<ApiResponse<EmployeeData>> GetByIdAsync(string id); | ||
| Task<ApiResponse<EmployeeData>> CreateAsync(EmployeeData requestModel); | ||
| Task<ApiResponse<EmployeeData>> UpdateAsync(EmployeeData requestModel); | ||
| Task<ApiResponse<bool>> DeleteAsync(string id); | ||
| } | ||
| } |
This file contains hidden or 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,18 @@ | ||
| using System.Threading.Tasks; | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Models; | ||
|
|
||
| namespace Fiscalapi.Abstractions | ||
| { | ||
| /// <summary> | ||
| /// Interfaz para el servicio de Empleador — gestiona los datos del empleador anidados bajo una Persona. | ||
| /// Patrón de endpoint: api/{version}/people/{personId}/employer | ||
| /// </summary> | ||
| public interface IEmployerService | ||
| { | ||
| Task<ApiResponse<EmployerData>> GetByIdAsync(string id); | ||
| Task<ApiResponse<EmployerData>> CreateAsync(EmployerData requestModel); | ||
| Task<ApiResponse<EmployerData>> UpdateAsync(EmployerData requestModel); | ||
| Task<ApiResponse<bool>> DeleteAsync(string id); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,50 +1,63 @@ | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Abstractions; | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Http; | ||
| using Fiscalapi.Models; | ||
| using System; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Fiscalapi.Services | ||
| { | ||
| public class EmployeeService | ||
| public class EmployeeService : IEmployeeService | ||
| { | ||
| private IFiscalApiHttpClient HttpClient { get; } | ||
| private string baseEndpoint = "api/v4/people"; | ||
| private readonly string _baseEndpoint; | ||
|
|
||
| public EmployeeService(IFiscalApiHttpClient fiscalApiHttpClient) | ||
| public EmployeeService(IFiscalApiHttpClient fiscalApiHttpClient, string apiVersion) | ||
| { | ||
| HttpClient = fiscalApiHttpClient; | ||
| _baseEndpoint = $"api/{apiVersion}/people"; | ||
| } | ||
|
|
||
| // GET /api/v4/people/{personId}/employee | ||
| private string BuildEndpoint(string personId) | ||
| => $"{_baseEndpoint}/{personId}/employee"; | ||
|
|
||
| // GET /api/{version}/people/{personId}/employee | ||
| public async Task<ApiResponse<EmployeeData>> GetByIdAsync(string id) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{id}/employee"; | ||
|
|
||
| return await HttpClient.GetAsync<EmployeeData>(endpoint); | ||
| if (string.IsNullOrWhiteSpace(id)) | ||
| throw new ArgumentException("Employee person ID is required to build endpoint", nameof(id)); | ||
| return await HttpClient.GetAsync<EmployeeData>(BuildEndpoint(id)); | ||
| } | ||
|
|
||
| //POST /api/v4/people/{personId}/employee | ||
| // POST /api/{version}/people/{personId}/employee | ||
| public async Task<ApiResponse<EmployeeData>> CreateAsync(EmployeeData requestModel) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{requestModel.EmployeePersonId}/employee"; | ||
|
|
||
| return await HttpClient.PostAsync<EmployeeData>(endpoint, requestModel); | ||
| ValidateRequestModel(requestModel); | ||
| return await HttpClient.PostAsync<EmployeeData>(BuildEndpoint(requestModel.EmployeePersonId), requestModel); | ||
| } | ||
|
|
||
| // PUT /api/v4/people/{personId}/employee | ||
| // PUT /api/{version}/people/{personId}/employee | ||
| public async Task<ApiResponse<EmployeeData>> UpdateAsync(EmployeeData requestModel) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{requestModel.EmployeePersonId}/employee"; | ||
|
|
||
| return await HttpClient.PutAsync<EmployeeData>(endpoint, requestModel); | ||
| ValidateRequestModel(requestModel); | ||
| return await HttpClient.PutAsync<EmployeeData>(BuildEndpoint(requestModel.EmployeePersonId), requestModel); | ||
| } | ||
|
|
||
| // DELETE /api/v4/people/{personId}/employee | ||
| // DELETE /api/{version}/people/{personId}/employee | ||
| public async Task<ApiResponse<bool>> DeleteAsync(string id) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{id}/employee"; | ||
| if (string.IsNullOrWhiteSpace(id)) | ||
| throw new ArgumentException("El ID de la persona requerido", nameof(id)); | ||
| return await HttpClient.DeleteAsync(BuildEndpoint(id)); | ||
| } | ||
|
|
||
| private void ValidateRequestModel(EmployeeData requestModel) | ||
| { | ||
| if (requestModel == null) | ||
| throw new ArgumentNullException(nameof(requestModel), "El modelo de solicitud no puede ser nulo"); | ||
|
|
||
| return await HttpClient.DeleteAsync(endpoint); | ||
| if (string.IsNullOrWhiteSpace(requestModel.EmployeePersonId)) | ||
| throw new ArgumentException("Se requiere el ID de la persona para crear o actualizar los datos del empleado", nameof(requestModel.EmployeePersonId)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,50 +1,63 @@ | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Abstractions; | ||
| using Fiscalapi.Common; | ||
| using Fiscalapi.Http; | ||
| using Fiscalapi.Models; | ||
| using System; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Fiscalapi.Services | ||
| { | ||
| public class EmployerService | ||
| public class EmployerService : IEmployerService | ||
| { | ||
| private IFiscalApiHttpClient HttpClient { get; } | ||
| private string baseEndpoint = "api/v4/people"; | ||
| private readonly string _baseEndpoint; | ||
|
|
||
| public EmployerService(IFiscalApiHttpClient fiscalApiHttpClient) | ||
| public EmployerService(IFiscalApiHttpClient fiscalApiHttpClient, string apiVersion) | ||
| { | ||
| HttpClient = fiscalApiHttpClient; | ||
| _baseEndpoint = $"api/{apiVersion}/people"; | ||
| } | ||
|
|
||
| // GET /api/v4/people/{personId}/employer | ||
| private string BuildEndpoint(string personId) | ||
| => $"{_baseEndpoint}/{personId}/employer"; | ||
|
|
||
| // GET /api/{version}/people/{personId}/employer | ||
| public async Task<ApiResponse<EmployerData>> GetByIdAsync(string id) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{id}/employer"; | ||
|
|
||
| return await HttpClient.GetAsync<EmployerData>(endpoint); | ||
| if (string.IsNullOrWhiteSpace(id)) | ||
| throw new ArgumentException("Person ID is required to build endpoint", nameof(id)); | ||
| return await HttpClient.GetAsync<EmployerData>(BuildEndpoint(id)); | ||
| } | ||
|
|
||
| //POST /api/v4/people/{personId}/employer | ||
| // POST /api/{version}/people/{personId}/employer | ||
| public async Task<ApiResponse<EmployerData>> CreateAsync(EmployerData requestModel) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{requestModel.PersonId}/employer"; | ||
|
|
||
| return await HttpClient.PostAsync<EmployerData>(endpoint, requestModel); | ||
| ValidateRequestModel(requestModel); | ||
| return await HttpClient.PostAsync<EmployerData>(BuildEndpoint(requestModel.PersonId), requestModel); | ||
| } | ||
|
|
||
| // PUT /api/v4/people/{personId}/employer | ||
| // PUT /api/{version}/people/{personId}/employer | ||
| public async Task<ApiResponse<EmployerData>> UpdateAsync(EmployerData requestModel) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{requestModel.PersonId}/employer"; | ||
|
|
||
| return await HttpClient.PutAsync<EmployerData>(endpoint, requestModel); | ||
| ValidateRequestModel(requestModel); | ||
| return await HttpClient.PutAsync<EmployerData>(BuildEndpoint(requestModel.PersonId), requestModel); | ||
| } | ||
|
|
||
| // DELETE /api/v4/people/{personId}/employer | ||
| // DELETE /api/{version}/people/{personId}/employer | ||
| public async Task<ApiResponse<bool>> DeleteAsync(string id) | ||
| { | ||
| string endpoint = $"{baseEndpoint}/{id}/employer"; | ||
| if (string.IsNullOrWhiteSpace(id)) | ||
| throw new ArgumentException("El ID de la persona requerido", nameof(id)); | ||
| return await HttpClient.DeleteAsync(BuildEndpoint(id)); | ||
| } | ||
|
|
||
| private void ValidateRequestModel(EmployerData requestModel) | ||
| { | ||
| if (requestModel == null) | ||
| throw new ArgumentNullException(nameof(requestModel), "El modelo de solicitud no puede ser nulo"); | ||
|
|
||
| return await HttpClient.DeleteAsync(endpoint); | ||
| if (string.IsNullOrWhiteSpace(requestModel.PersonId)) | ||
| throw new ArgumentException("Se requiere el ID de la persona para crear o actualizar los datos del empleador", nameof(requestModel.PersonId)); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parenthetical label "CFDI Nómina" reads as a detached fragment.
Both lines use the pattern
a una persona. CFDI Nómina)— a full stop inside the parentheses followed by a bare noun phrase, which creates an awkward sentence fragment. Replacing the period with a conjunction keeps the parenthetical cohesive:✏️ Suggested wording
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~39-~39: Aquí puede haber un error.
Context: ... de empleado a una persona. CFDI Nómina) - Datos de empleador (agrega/actualiza/e...
(QB_NEW_ES)
🤖 Prompt for AI Agents