From 5f3b9b6df5769ae04d4fe93f77142e51925a38e7 Mon Sep 17 00:00:00 2001 From: Diane Huxley Date: Wed, 27 Mar 2024 22:10:46 -0700 Subject: [PATCH] Use PUT for /exchanges/:exchangeId in client --- .../src/main/kotlin/tbdex/sdk/httpclient/TbdexHttpClient.kt | 2 +- .../test/kotlin/tbdex/sdk/httpclient/TbdexHttpClientTest.kt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/httpclient/src/main/kotlin/tbdex/sdk/httpclient/TbdexHttpClient.kt b/httpclient/src/main/kotlin/tbdex/sdk/httpclient/TbdexHttpClient.kt index 995b21c8..fbdbdc9c 100644 --- a/httpclient/src/main/kotlin/tbdex/sdk/httpclient/TbdexHttpClient.kt +++ b/httpclient/src/main/kotlin/tbdex/sdk/httpclient/TbdexHttpClient.kt @@ -171,7 +171,7 @@ object TbdexHttpClient { val request = Request.Builder() .url(url) .addHeader("Content-Type", JSON_HEADER) - .post(requestBody) + .put(requestBody) .build() println("Attempting to send message to exchange ${exchangeId} to: ${request.url}") diff --git a/httpclient/src/test/kotlin/tbdex/sdk/httpclient/TbdexHttpClientTest.kt b/httpclient/src/test/kotlin/tbdex/sdk/httpclient/TbdexHttpClientTest.kt index 310c1921..0aef26b4 100644 --- a/httpclient/src/test/kotlin/tbdex/sdk/httpclient/TbdexHttpClientTest.kt +++ b/httpclient/src/test/kotlin/tbdex/sdk/httpclient/TbdexHttpClientTest.kt @@ -95,6 +95,7 @@ class TbdexHttpClientTest { assertDoesNotThrow { TbdexHttpClient.createExchange(rfq) } val request = server.takeRequest() + assertEquals(request.method, "POST") assertEquals(request.path, "/exchanges") assertEquals( Json.jsonMapper.readTree(request.body.readUtf8()), @@ -111,6 +112,7 @@ class TbdexHttpClientTest { assertDoesNotThrow { TbdexHttpClient.createExchange(rfq, replyTo) } val request = server.takeRequest() + assertEquals(request.method, "POST") assertEquals(request.path, "/exchanges") assertEquals( Json.jsonMapper.readTree(request.body.readUtf8()), @@ -195,6 +197,7 @@ class TbdexHttpClientTest { assertDoesNotThrow { TbdexHttpClient.submitOrder(order) } val request = server.takeRequest() + assertEquals(request.method, "PUT") assertEquals(request.path, "/exchanges/${order.metadata.exchangeId}") assertEquals( Json.jsonMapper.readTree(request.body.readUtf8()), @@ -253,6 +256,7 @@ class TbdexHttpClientTest { assertDoesNotThrow { TbdexHttpClient.submitClose(close) } val request = server.takeRequest() + assertEquals(request.method, "PUT") assertEquals(request.path, "/exchanges/${close.metadata.exchangeId}") assertEquals( Json.jsonMapper.readTree(request.body.readUtf8()),