diff --git a/pom.xml b/pom.xml
index 6ac6648a1f51732f5fc7bb9368aab552773ab8e9..5454bbc3c7a175148ce64d50ca4d5761653a1dc5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
diff --git a/src/main/java/fr/ulille/iut/tva/Main.java b/src/main/java/fr/ulille/iut/tva/Main.java
index 62da555ebf892c9910b55e2700400f5229364411..703833577e48d1a73cd9b0c7e2eb340a7360dacd 100644
--- a/src/main/java/fr/ulille/iut/tva/Main.java
+++ b/src/main/java/fr/ulille/iut/tva/Main.java
@@ -16,7 +16,7 @@ import java.util.logging.Logger;
*/
public class Main {
// Base URI the Grizzly HTTP server will listen on
- public static final String BASE_URI = "http://localhost:8080/myapp/";
+ public static final String BASE_URI = "http://localhost:8080/api/v1";
/**
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
diff --git a/src/main/java/fr/ulille/iut/tva/ressource/NiveauTvaInexistantException.java b/src/main/java/fr/ulille/iut/tva/ressource/NiveauTvaInexistantException.java
new file mode 100644
index 0000000000000000000000000000000000000000..384820447499901ea92bafd7a3bafa9de71dc27f
--- /dev/null
+++ b/src/main/java/fr/ulille/iut/tva/ressource/NiveauTvaInexistantException.java
@@ -0,0 +1,11 @@
+package fr.ulille.iut.tva.ressource;
+
+import jakarta.ws.rs.WebApplicationException;
+import jakarta.ws.rs.core.Response;
+
+public class NiveauTvaInexistantException extends WebApplicationException {
+ private static final long serialVersionUID = 939875418210403804L;
+
+ public NiveauTvaInexistantException() {
+ super(Response.status(Response.Status.NOT_ACCEPTABLE).entity("Niveau de TVA inexistant").build());
+ }
diff --git a/src/main/java/fr/ulille/iut/tva/ressource/TvaRessource.java b/src/main/java/fr/ulille/iut/tva/ressource/TvaRessource.java
index 4c63ca69564a00810016eb92cc55ec8116b80faa..8321c1ceb07bad7f6ee95dc12179a615aec0b23d 100644
--- a/src/main/java/fr/ulille/iut/tva/ressource/TvaRessource.java
+++ b/src/main/java/fr/ulille/iut/tva/ressource/TvaRessource.java
@@ -6,7 +6,29 @@ import fr.ulille.iut.tva.service.TauxTva;
/**
* TvaRessource
*/
+@Path("tva")
public class TvaRessource {
private CalculTva calculTva = new CalculTva();
-
+
+ @GET
+ @PATH("valeur/{niveauTVA}")
+ public double getValeurTauxParDefaut(@PathParam("niveauTVA") String niveau) {
+ try {
+ return TauxTva.valueOf((niveau.toUpperCase())).taux;
+ }
+ catch(Exception e) {
+ throw new NiveauTvaInexistantException();
+ }
+ }
+
+ @GET
+ @PATH("reduit?{somme}")
+ public double getMontantTotal(@PathParam("somme") double somme) {
+ try {
+ return TauxTva.REDUIT.taux * somme;
+ }
+ catch (Exception e){
+ throw new NiveauTvaInexistantException();
+ }
+ }
}