From 958d920de02ec9fcf07922828ba7121815914491 Mon Sep 17 00:00:00 2001 From: onyxcoyote Date: Mon, 24 Dec 2018 09:58:31 -0700 Subject: [PATCH] allow using it as a library without spring framework (change to GdaxExchangeImpl) --- .../api/exchange/GdaxExchangeImpl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/coinbase/exchange/api/exchange/GdaxExchangeImpl.java b/src/main/java/com/coinbase/exchange/api/exchange/GdaxExchangeImpl.java index e236b4c..150496b 100644 --- a/src/main/java/com/coinbase/exchange/api/exchange/GdaxExchangeImpl.java +++ b/src/main/java/com/coinbase/exchange/api/exchange/GdaxExchangeImpl.java @@ -1,5 +1,6 @@ package com.coinbase.exchange.api.exchange; +import com.coinbase.exchange.api.config.GdaxConfiguration; import com.google.gson.Gson; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -49,6 +50,23 @@ public GdaxExchangeImpl(@Value("${gdax.key}") String publicKey, this.restTemplate = restTemplate; } + //Constructor that can be used without needing spring library in calling program + public GdaxExchangeImpl(@Value("${gdax.key}") String publicKey, + @Value("${gdax.passphrase}") String passphrase, + @Value("${gdax.api.baseUrl}") String baseUrl, + Signature signature) { + + this.publicKey = publicKey; + this.passphrase = passphrase; + this.baseUrl = baseUrl; + this.signature = signature; + if(restTemplate == null) + { + restTemplate = new GdaxConfiguration().restTemplate(); + } + this.restTemplate = restTemplate; + } + @Override public T get(String resourcePath, ParameterizedTypeReference responseType) { try {