Grobkonstrukt Klasse Preisentnahme der AmazonAPI
This commit is contained in:
49
src/main/java/de/rwu/easydrop/api/Preisentnahme.java
Normal file
49
src/main/java/de/rwu/easydrop/api/Preisentnahme.java
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package de.rwu.easydrop.api.client;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import com.jayway.jsonpath.PathNotFoundException;
|
||||||
|
import com.jayway.jsonpath.ReadContext;
|
||||||
|
|
||||||
|
import de.rwu.easydrop.api.dto.ProductDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Klasse AmazonPriceFetcher enthält die Methode getProductPrice,
|
||||||
|
* die den Preis eines Produkts von der Amazon API abruft.
|
||||||
|
* Die Methode verwendet die Base URL, den API-Schlüssel und die Produkt-ID,
|
||||||
|
* um die API-URL zu erstellen und die Daten von der API abzurufen.
|
||||||
|
* Anschließend wird der Preis aus der JSON-Antwort extrahiert und zurückgegeben.
|
||||||
|
*/
|
||||||
|
public final class AmazonPriceFetcher {
|
||||||
|
/**
|
||||||
|
* URL zur Amazon API.
|
||||||
|
*/
|
||||||
|
private String baseUrl;
|
||||||
|
/**
|
||||||
|
* API-Schlüssel zur Autorisierung.
|
||||||
|
*/
|
||||||
|
private String apiKey;
|
||||||
|
/**
|
||||||
|
* Produktregion für den Datenzugriff.
|
||||||
|
*/
|
||||||
|
private static final String PRODUCT_REGION = "DE";
|
||||||
|
/**
|
||||||
|
* Sprachparameter für den Datenzugriff.
|
||||||
|
*/
|
||||||
|
private static final String LOCALE = "de_DE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialisiert die Klasse mit der Base URL und dem API-Schlüssel.
|
||||||
|
*
|
||||||
|
* @param newBaseUrl Die Base URL zur Amazon API.
|
||||||
|
* @param newApiKey Der API-Schlüssel zur Autorisierung.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public AmazonPriceFetcher(final String newBaseUrl, final String newApiKey) {
|
||||||
|
this.baseUrl = newBaseUrl;
|
||||||
|
this.apiKey = newApiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user