Files
EasyDrop/src/main/java/de/rwu/easydrop/api/client/EbayPurchaser.java
2023-06-27 06:45:00 +02:00

55 lines
1.1 KiB
Java

package de.rwu.easydrop.api.client;
import java.net.MalformedURLException;
import java.net.URL;
import de.rwu.easydrop.model.Webshop;
/**
* Sends a buy request to the eBay API.
*
* @since 0.3.0
*/
public final class EbayPurchaser extends AbstractPurchaser {
/**
* Name of this data source.
*/
private static final Webshop DATA_TARGET = Webshop.EBAY;
/**
* Base URL to the eBay Purchase API.
*/
private String baseUrl;
/**
* Access credential.
*/
private String apiKey;
/**
* Sets up instance with Base URL and API Key.
*
* @param newBaseUrl
* @param newApiKey
*/
public EbayPurchaser(final String newBaseUrl, final String newApiKey) {
this.baseUrl = newBaseUrl;
this.apiKey = newApiKey;
}
@Override
protected URL createApiUrl(final String searchQuery) throws MalformedURLException {
return new URL(baseUrl
+ "/buy/"
+ searchQuery);
}
@Override
protected String getApiKey() {
return apiKey;
}
@Override
protected Webshop getDataTarget() {
return DATA_TARGET;
}
}