Amazon and eBay Buy/Sell APIs

This commit is contained in:
Marvin Scham
2023-06-22 16:31:54 +00:00
parent a86ed4c5e0
commit 0be5a5ad40
21 changed files with 980 additions and 7 deletions
@@ -0,0 +1,67 @@
package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
/**
* Sends a buy request to the Amazon API.
*
* @since 0.3.0
*/
public final class AmazonPurchaser extends AbstractPurchaser {
/**
* Name of this data source.
*/
private static final String DATA_TARGET = "Amazon";
/**
* Base URL to the Amazon Purchase API.
*/
private String baseUrl;
/**
* Access credential.
*/
private String apiKey;
/**
* Product region parameter required for data writes.
*/
private static final String PRODUCT_REGION = "DE";
/**
* Locale parameter required for data writes.
*/
private static final String LOCALE = "de_DE";
/**
* Sets up instance with Base URL and API Key.
*
* @param newBaseUrl
* @param newApiKey
*/
public AmazonPurchaser(final String newBaseUrl, final String newApiKey) {
this.baseUrl = newBaseUrl;
this.apiKey = newApiKey;
}
/**
* @param productId ASIN
*/
@Override
protected URL createApiUrl(final String productId) throws MalformedURLException {
return new URL(baseUrl
+ "/products/2020-08-26/products/"
+ productId
+ "/buy?productRegion="
+ PRODUCT_REGION
+ "&locale="
+ LOCALE);
}
@Override
protected String getApiKey() {
return this.apiKey;
}
@Override
protected String getDataTarget() {
return DATA_TARGET;
}
}