From 940e2173fe9cb859c32dcd8bcc20bfd032b886bd Mon Sep 17 00:00:00 2001 From: lucasbaizer2 <62267843+lucasbaizer2@users.noreply.github.com> Date: Thu, 27 Aug 2020 13:42:11 -0700 Subject: [PATCH] Proposed fix for #96 (#97) * Proposed fix for #96 * Added unit test Co-authored-by: Lucas Baizer --- .../request/stocks/QuoteSseRequestBuilder.java | 8 +++++++- .../stocks/QuoteSseRequestBuilderTest.java | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/iextrading4j-client/src/main/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilder.java b/iextrading4j-client/src/main/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilder.java index 7cfc6608d7..1973609a12 100644 --- a/iextrading4j-client/src/main/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilder.java +++ b/iextrading4j-client/src/main/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilder.java @@ -11,16 +11,22 @@ public class QuoteSseRequestBuilder extends AbstractSymbolSseRequestBuilder, QuoteSseRequestBuilder> { private QuoteInterval quoteInterval; + private boolean noUTP; public QuoteSseRequestBuilder withQuoteInterval(final QuoteInterval quoteInterval) { this.quoteInterval = quoteInterval; return this; } + + public QuoteSseRequestBuilder withNoUTP() { + this.noUTP = true; + return this; + } @Override public SseRequest> build() { return SseRequestBuilder.>builder() - .withPath("/stocksUS{interval}") + .withPath(noUTP ? "/stocksUSNoUTP{interval}" : "/stocksUS{interval}") .addPathParam("interval", quoteInterval.getName()) .withResponse(new GenericType>() {}) .addQueryParam(SYMBOL_PARAM, getSymbol()) diff --git a/iextrading4j-client/src/test/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilderTest.java b/iextrading4j-client/src/test/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilderTest.java index b8cf4e779a..cdefe67a73 100644 --- a/iextrading4j-client/src/test/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilderTest.java +++ b/iextrading4j-client/src/test/java/pl/zankowski/iextrading4j/client/sse/request/stocks/QuoteSseRequestBuilderTest.java @@ -29,4 +29,21 @@ public void shouldSuccessfullyCreateRequest() { assertThat(request.getQueryParams()).contains(entry("nosnapshot", "false"), entry("symbols", symbol)); } + @Test + public void shouldSuccessfullyCreateRequestNoUTP() { + final String symbol = "IBM"; + + final SseRequest> request = new QuoteSseRequestBuilder() + .withQuoteInterval(QuoteInterval.REALTIME) + .withSymbol(symbol) + .withNoUTP() + .build(); + + assertThat(request.getPath()).isEqualTo("/stocksUSNoUTP{interval}"); + assertThat(request.getResponseType()).isEqualTo(new GenericType>() { + }); + assertThat(request.getPathParams()).contains(entry("interval", "")); + assertThat(request.getQueryParams()).contains(entry("nosnapshot", "false"), entry("symbols", symbol)); + } + }