diff --git a/src/main/java/de/rwu/easydrop/api/client/PurchaserFactory.java b/src/main/java/de/rwu/easydrop/api/client/PurchaserFactory.java new file mode 100644 index 0000000..24242e4 --- /dev/null +++ b/src/main/java/de/rwu/easydrop/api/client/PurchaserFactory.java @@ -0,0 +1,55 @@ +package de.rwu.easydrop.api.client; + +import javax.naming.ConfigurationException; + +import de.rwu.easydrop.util.Config; + +/** + * Factory for Buyer API accessors. + * + * @since 0.3.0 + */ +public class PurchaserFactory { + + /** + * The data source config. + */ + private Config config; + + /** + * @param newConfig the config to set + */ + public void setConfig(final Config newConfig) throws ConfigurationException { + this.config = newConfig; + this.config.loadConfig(); + } + + /** + * @param newConfig + */ + public PurchaserFactory(final Config newConfig) throws ConfigurationException { + this.setConfig(newConfig); + } + + /** + * Creates an Amazon purchaser. + * + * @return AmazonPurchaser + */ + public AmazonPurchaser createAmazonPurchaser() { + String apiUrl = config.getProperty("AMAZON_API_URL"); + String apiKey = config.getProperty("AMAZON_API_KEY"); + return new AmazonPurchaser(apiUrl, apiKey); + } + + /** + * Creates an eBay purchaser. + * + * @return EbayPurchaser + */ + public EbayPurchaser createEbayPurchaser() { + String apiUrl = config.getProperty("EBAY_API_URL"); + String apiKey = config.getProperty("EBAY_API_KEY"); + return new EbayPurchaser(apiUrl, apiKey); + } +} diff --git a/src/main/java/de/rwu/easydrop/api/client/SellerFactory.java b/src/main/java/de/rwu/easydrop/api/client/SellerFactory.java new file mode 100644 index 0000000..df64a3f --- /dev/null +++ b/src/main/java/de/rwu/easydrop/api/client/SellerFactory.java @@ -0,0 +1,55 @@ +package de.rwu.easydrop.api.client; + +import javax.naming.ConfigurationException; + +import de.rwu.easydrop.util.Config; + +/** + * Factory for Sales API accessors. + * + * @since 0.3.0 + */ +public class SellerFactory { + + /** + * The data source config. + */ + private Config config; + + /** + * @param newConfig the config to set + */ + public void setConfig(final Config newConfig) throws ConfigurationException { + this.config = newConfig; + this.config.loadConfig(); + } + + /** + * @param newConfig + */ + public SellerFactory(final Config newConfig) throws ConfigurationException { + this.setConfig(newConfig); + } + + /** + * Creates an Amazon Seller. + * + * @return AmazonSeller + */ + public AmazonSeller createAmazonSeller() { + String apiUrl = config.getProperty("AMAZON_API_URL"); + String apiKey = config.getProperty("AMAZON_API_KEY"); + return new AmazonSeller(apiUrl, apiKey); + } + + /** + * Creates an eBay Seller. + * + * @return EbaySeller + */ + public EbaySeller createEbaySeller() { + String apiUrl = config.getProperty("EBAY_API_URL"); + String apiKey = config.getProperty("EBAY_API_KEY"); + return new EbaySeller(apiUrl, apiKey); + } +}