feat: start affiliation system

This commit is contained in:
2024-02-05 21:42:50 +01:00
parent 2a59c22db6
commit 40427b8cfb
9 changed files with 403 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package fr.titionfire.ffsaf.rest;
import fr.titionfire.ffsaf.rest.client.SirenService;
import fr.titionfire.ffsaf.rest.data.UniteLegaleRoot;
import io.smallrye.mutiny.Uni;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("api/asso")
public class AssoEndpoints {
@RestClient
SirenService sirenService;
@GET
@Path("siren/{siren}")
@Produces(MediaType.APPLICATION_JSON)
public Uni<UniteLegaleRoot> getInfoSiren(@PathParam("siren") String siren) {
return sirenService.get_unite(siren).onFailure().transform(throwable -> {
if (throwable instanceof WebApplicationException exception){
if (exception.getResponse().getStatus() == 400)
return new BadRequestException("Not found");
}
return throwable;
});
}
}