From 2a79612dc612e9d2965053311746fc5f937ef643 Mon Sep 17 00:00:00 2001 From: Marios Tsekis Date: Mon, 2 Aug 2021 18:58:44 +0100 Subject: [PATCH] Update host (#59) * Run scalafmt and scalafix * Removed virtual host --- src/main/scala/org/hatdex/dex/api/DexClient.scala | 5 +---- src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala | 2 -- src/main/scala/org/hatdex/dex/api/DexNotices.scala | 2 -- src/main/scala/org/hatdex/dex/api/DexOffers.scala | 2 -- src/main/scala/org/hatdex/dex/api/DexStats.scala | 2 -- .../scala/org/hatdex/dex/apiV2/DexApplications.scala | 11 ----------- src/main/scala/org/hatdex/dex/apiV2/DexClient.scala | 3 --- src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala | 6 ------ src/main/scala/org/hatdex/dex/apiV2/DexStats.scala | 3 --- src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala | 2 -- .../scala/org/hatdex/dex/apiV3/DexApplications.scala | 11 ----------- src/main/scala/org/hatdex/dex/apiV3/DexClient.scala | 3 --- src/main/scala/org/hatdex/dex/apiV3/DexOffers.scala | 6 ------ src/main/scala/org/hatdex/dex/apiV3/DexStats.scala | 3 --- src/main/scala/org/hatdex/dex/apiV3/DexUsers.scala | 2 -- 15 files changed, 1 insertion(+), 62 deletions(-) diff --git a/src/main/scala/org/hatdex/dex/api/DexClient.scala b/src/main/scala/org/hatdex/dex/api/DexClient.scala index 34f5d4d..f2d1425 100644 --- a/src/main/scala/org/hatdex/dex/api/DexClient.scala +++ b/src/main/scala/org/hatdex/dex/api/DexClient.scala @@ -12,8 +12,6 @@ package org.hatdex.dex.api import play.api.Logger import play.api.libs.ws.WSClient -import java.net.URL - class DexClient( val ws: WSClient, val dexAddress: String) @@ -22,6 +20,5 @@ class DexClient( with DexDataPlugs with DexStats { - override val dexHost: String = new URL(dexAddress).getHost - val logger: Logger = play.api.Logger(this.getClass) + val logger: Logger = play.api.Logger(this.getClass) } diff --git a/src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala b/src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala index 7735215..c769a8b 100644 --- a/src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala +++ b/src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala @@ -11,7 +11,6 @@ trait DexDataPlugs { val logger: Logger val ws: WSClient val dexAddress: String - val dexHost: String def dataplugConnectHat( access_token: String, @@ -22,7 +21,6 @@ trait DexDataPlugs { val request: WSRequest = ws .url(s"$dexAddress/api/dataplugs/$dataplugId/connect") - .withVirtualHost(dexHost) .withQueryStringParameters(("hat", hatAddress)) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) diff --git a/src/main/scala/org/hatdex/dex/api/DexNotices.scala b/src/main/scala/org/hatdex/dex/api/DexNotices.scala index d67de7b..d5bb25b 100644 --- a/src/main/scala/org/hatdex/dex/api/DexNotices.scala +++ b/src/main/scala/org/hatdex/dex/api/DexNotices.scala @@ -13,7 +13,6 @@ trait DexNotices { val logger: Logger val ws: WSClient val dexAddress: String - val dexHost: String import DexJsonFormats._ @@ -25,7 +24,6 @@ trait DexNotices { val request: WSRequest = ws .url(s"$dexAddress/api/notices") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(notice)) diff --git a/src/main/scala/org/hatdex/dex/api/DexOffers.scala b/src/main/scala/org/hatdex/dex/api/DexOffers.scala index 555833c..088e477 100644 --- a/src/main/scala/org/hatdex/dex/api/DexOffers.scala +++ b/src/main/scala/org/hatdex/dex/api/DexOffers.scala @@ -12,7 +12,6 @@ trait DexOffers { val logger: Logger val ws: WSClient val dexAddress: String - val dexHost: String import io.dataswift.models.dex.json.DexJsonFormats._ @@ -27,7 +26,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/offer/$offerId/claims") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() diff --git a/src/main/scala/org/hatdex/dex/api/DexStats.scala b/src/main/scala/org/hatdex/dex/api/DexStats.scala index 872ca87..f080796 100644 --- a/src/main/scala/org/hatdex/dex/api/DexStats.scala +++ b/src/main/scala/org/hatdex/dex/api/DexStats.scala @@ -15,7 +15,6 @@ trait DexStats { val logger: Logger val ws: WSClient val dexAddress: String - val dexHost: String def postStats( access_token: String, @@ -23,7 +22,6 @@ trait DexStats { )(implicit ec: ExecutionContext): Future[Unit] = { val request: WSRequest = ws .url(s"$dexAddress/stats/report") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(stats)) diff --git a/src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala b/src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala index de0dd90..f57e844 100644 --- a/src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala +++ b/src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala @@ -15,7 +15,6 @@ trait DexApplications { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String implicit protected val applicationFormat: Format[Application] = @@ -28,7 +27,6 @@ trait DexApplications { def applications(includeUnpublished: Boolean = false)(implicit ec: ExecutionContext): Future[Seq[Application]] = { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications") - .withVirtualHost(dexHost) .withQueryStringParameters("unpublished" -> includeUnpublished.toString) .withHttpHeaders("Accept" -> "application/json") @@ -59,7 +57,6 @@ trait DexApplications { val requestedLanguage = lang.getOrElse("en") val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/$applicationId") - .withVirtualHost(dexHost) .withQueryStringParameters("lang" -> requestedLanguage) .withHttpHeaders("Accept" -> "application/json") @@ -92,7 +89,6 @@ trait DexApplications { )(implicit ec: ExecutionContext): Future[Seq[ApplicationHistory]] = { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications-history") - .withVirtualHost(dexHost) .withQueryStringParameters("unpublished" -> includeUnpublished.toString) .withHttpHeaders("Accept" -> "application/json") @@ -124,7 +120,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(application)) @@ -162,7 +157,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.put(Json.toJson(application)) @@ -200,7 +194,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/publish") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -231,7 +224,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/suspend") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -259,7 +251,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/$applicationId") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() @@ -297,7 +288,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/developer") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.put(Json.toJson(developer)) @@ -335,7 +325,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/versions") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(application)) diff --git a/src/main/scala/org/hatdex/dex/apiV2/DexClient.scala b/src/main/scala/org/hatdex/dex/apiV2/DexClient.scala index a2f5b61..0ff9b6b 100644 --- a/src/main/scala/org/hatdex/dex/apiV2/DexClient.scala +++ b/src/main/scala/org/hatdex/dex/apiV2/DexClient.scala @@ -13,8 +13,6 @@ import org.hatdex.dex.api.{ DexDataPlugs, DexNotices } import play.api.Logger import play.api.libs.ws.WSClient -import java.net.URL - class DexClient( val ws: WSClient, val dexAddress: String) @@ -26,6 +24,5 @@ class DexClient( with DexApplications { override val apiVersion: String = "v2" - override val dexHost: String = new URL(dexAddress).getHost val logger: Logger = play.api.Logger(this.getClass) } diff --git a/src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala b/src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala index 8832000..5c1ee85 100644 --- a/src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala +++ b/src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala @@ -13,7 +13,6 @@ trait DexOffers { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String import io.dataswift.models.dex.json.DexJsonFormats._ @@ -23,7 +22,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/v2/offers") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() @@ -54,7 +52,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/v2/offer") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(offer)) @@ -92,7 +89,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/v2/offer/$offerId/claims") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -132,7 +128,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/v2/offer/$offerId/registerClaim") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) .withQueryStringParameters(("hat", hat)) @@ -184,7 +179,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/v2/offer/$offerId") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) .withQueryStringParameters(("status", status)) diff --git a/src/main/scala/org/hatdex/dex/apiV2/DexStats.scala b/src/main/scala/org/hatdex/dex/apiV2/DexStats.scala index 0f3fa26..94b8f07 100644 --- a/src/main/scala/org/hatdex/dex/apiV2/DexStats.scala +++ b/src/main/scala/org/hatdex/dex/apiV2/DexStats.scala @@ -16,7 +16,6 @@ trait DexStats { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String implicit protected val dataStatsFormat: Format[DataStats] = @@ -30,7 +29,6 @@ trait DexStats { )(implicit ec: ExecutionContext): Future[Unit] = { val request: WSRequest = ws .url(s"$dexAddress/stats/report") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(stats)) @@ -48,7 +46,6 @@ trait DexStats { def availableData()(implicit ec: ExecutionContext): Future[Seq[NamespaceStructure]] = { val request: WSRequest = ws .url(s"$dexAddress/stats/available-data") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() diff --git a/src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala b/src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala index aa553ef..50e6913 100644 --- a/src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala +++ b/src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala @@ -14,7 +14,6 @@ trait DexUsers { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String def registerHat( @@ -43,7 +42,6 @@ trait DexUsers { )(implicit ec: ExecutionContext): Future[Done] = { val request: WSRequest = ws .url(s"$dexAddress/api/users/register-consent/$applicationId") - .withVirtualHost(dexHost) .withRequestTimeout(2500.millis) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken) diff --git a/src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala b/src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala index a3cb70b..a7ddf56 100644 --- a/src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala +++ b/src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala @@ -29,7 +29,6 @@ trait DexApplications { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String private def optionalParam[T]( @@ -58,7 +57,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications") - .withVirtualHost(dexHost) .withQueryStringParameters(queryParams(unpublished, kind, startId, limit): _*) .withHttpHeaders("Accept" -> "application/json") @@ -89,7 +87,6 @@ trait DexApplications { val requestedLanguage = lang.getOrElse("en") val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/$applicationId") - .withVirtualHost(dexHost) .withQueryStringParameters("lang" -> requestedLanguage) .withHttpHeaders("Accept" -> "application/json") @@ -126,7 +123,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications-history") - .withVirtualHost(dexHost) .withQueryStringParameters(queryParams(unpublished, kind, startId, limit): _*) .withHttpHeaders("Accept" -> "application/json") @@ -158,7 +154,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(application)) @@ -196,7 +191,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.put(Json.toJson(application)) @@ -234,7 +228,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/publish") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -265,7 +258,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/suspend") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -293,7 +285,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/$applicationId") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() @@ -331,7 +322,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/developer") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.put(Json.toJson(developer)) @@ -369,7 +359,6 @@ trait DexApplications { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/applications/${application.id}/versions") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(application)) diff --git a/src/main/scala/org/hatdex/dex/apiV3/DexClient.scala b/src/main/scala/org/hatdex/dex/apiV3/DexClient.scala index e3427d1..4b0bb55 100644 --- a/src/main/scala/org/hatdex/dex/apiV3/DexClient.scala +++ b/src/main/scala/org/hatdex/dex/apiV3/DexClient.scala @@ -13,8 +13,6 @@ import org.hatdex.dex.api.{ DexDataPlugs, DexNotices } import play.api.Logger import play.api.libs.ws.WSClient -import java.net.URL - class DexClient( val ws: WSClient, val dexAddress: String) @@ -26,6 +24,5 @@ class DexClient( with DexApplications { override val apiVersion: String = "v3" - override val dexHost: String = new URL(dexAddress).getHost val logger: Logger = play.api.Logger(this.getClass) } diff --git a/src/main/scala/org/hatdex/dex/apiV3/DexOffers.scala b/src/main/scala/org/hatdex/dex/apiV3/DexOffers.scala index b60235f..cd35f36 100644 --- a/src/main/scala/org/hatdex/dex/apiV3/DexOffers.scala +++ b/src/main/scala/org/hatdex/dex/apiV3/DexOffers.scala @@ -13,7 +13,6 @@ trait DexOffers { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String import io.dataswift.models.dex.json.DexJsonFormats._ @@ -23,7 +22,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/offers") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() @@ -54,7 +52,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/offer") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(offer)) @@ -92,7 +89,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/offer/$offerId/claims") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.get() @@ -132,7 +128,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/offer/$offerId/registerClaim") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) .withQueryStringParameters(("hat", hat)) @@ -184,7 +179,6 @@ trait DexOffers { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/offer/$offerId") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) .withQueryStringParameters(("status", status)) diff --git a/src/main/scala/org/hatdex/dex/apiV3/DexStats.scala b/src/main/scala/org/hatdex/dex/apiV3/DexStats.scala index 70575c8..0a2c08d 100644 --- a/src/main/scala/org/hatdex/dex/apiV3/DexStats.scala +++ b/src/main/scala/org/hatdex/dex/apiV3/DexStats.scala @@ -16,7 +16,6 @@ trait DexStats { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String implicit protected val dataStatsFormat: Format[DataStats] = @@ -29,7 +28,6 @@ trait DexStats { )(implicit ec: ExecutionContext): Future[Unit] = { val request: WSRequest = ws .url(s"$dexAddress/stats/report") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token) val futureResponse: Future[WSResponse] = request.post(Json.toJson(stats)) @@ -47,7 +45,6 @@ trait DexStats { def availableData()(implicit ec: ExecutionContext): Future[Seq[NamespaceStructure]] = { val request: WSRequest = ws .url(s"$dexAddress/stats/available-data") - .withVirtualHost(dexHost) .withHttpHeaders("Accept" -> "application/json") val futureResponse: Future[WSResponse] = request.get() diff --git a/src/main/scala/org/hatdex/dex/apiV3/DexUsers.scala b/src/main/scala/org/hatdex/dex/apiV3/DexUsers.scala index 1ed985b..3000192 100644 --- a/src/main/scala/org/hatdex/dex/apiV3/DexUsers.scala +++ b/src/main/scala/org/hatdex/dex/apiV3/DexUsers.scala @@ -14,7 +14,6 @@ trait DexUsers { protected val logger: Logger protected val ws: WSClient protected val dexAddress: String - protected val dexHost: String protected val apiVersion: String def registerHat( @@ -43,7 +42,6 @@ trait DexUsers { )(implicit ec: ExecutionContext): Future[Done] = { val request: WSRequest = ws .url(s"$dexAddress/api/$apiVersion/users/register-consent/$applicationId") - .withVirtualHost(dexHost) .withRequestTimeout(2500.millis) .withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)