feat: implement ARCA integration architecture including credential, fiscal profile, and invoice models, services, and onboarding flows
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { Body, Controller, Middlewares, Post, Response, Route, SuccessResponse } from "tsoa";
|
||||
import { authenticateMiddleware } from "../../middleware/authentication";
|
||||
import { ApiValidationError } from "../../Models/Server.Error.model";
|
||||
import {
|
||||
FindOrganizationFiscalProfilesParams,
|
||||
IOrganizationFiscalProfile,
|
||||
UpsertOrganizationFiscalProfileParams,
|
||||
} from "../../Models/OrganizationFiscalProfiles/OrganizationFiscalProfiles.Interface";
|
||||
import { OrganizationFiscalProfilesService } from "./OrganizationFiscalProfiles.Service";
|
||||
|
||||
@Route("organization-fiscal-profiles/upsert")
|
||||
@Middlewares(authenticateMiddleware)
|
||||
export class OrganizationFiscalProfilesUpsertController extends Controller {
|
||||
@SuccessResponse(200, "Done")
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@Post()
|
||||
public async upsert(
|
||||
@Body() requestBody: UpsertOrganizationFiscalProfileParams
|
||||
): Promise<IOrganizationFiscalProfile | ApiValidationError> {
|
||||
try {
|
||||
const profile = await new OrganizationFiscalProfilesService().upsert(requestBody);
|
||||
this.setStatus(200);
|
||||
return profile;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Route("organization-fiscal-profiles/find")
|
||||
@Middlewares(authenticateMiddleware)
|
||||
export class OrganizationFiscalProfilesFindController extends Controller {
|
||||
@SuccessResponse(200, "Done")
|
||||
@Response<ApiValidationError>(500, "Ha ocurrido un error")
|
||||
@Post()
|
||||
public async find(
|
||||
@Body() requestBody: FindOrganizationFiscalProfilesParams
|
||||
): Promise<IOrganizationFiscalProfile[] | ApiValidationError> {
|
||||
try {
|
||||
const profiles = await new OrganizationFiscalProfilesService().find(requestBody);
|
||||
this.setStatus(200);
|
||||
return profiles;
|
||||
} catch (e) {
|
||||
const errorOccurred: Error = e as Error;
|
||||
this.setStatus(500);
|
||||
return new ApiValidationError(500, errorOccurred.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user