Skip to content

Commit 2a79612

Browse files
Update host (#59)
* Run scalafmt and scalafix * Removed virtual host
1 parent b570077 commit 2a79612

15 files changed

+1
-62
lines changed

src/main/scala/org/hatdex/dex/api/DexClient.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ package org.hatdex.dex.api
1212
import play.api.Logger
1313
import play.api.libs.ws.WSClient
1414

15-
import java.net.URL
16-
1715
class DexClient(
1816
val ws: WSClient,
1917
val dexAddress: String)
@@ -22,6 +20,5 @@ class DexClient(
2220
with DexDataPlugs
2321
with DexStats {
2422

25-
override val dexHost: String = new URL(dexAddress).getHost
26-
val logger: Logger = play.api.Logger(this.getClass)
23+
val logger: Logger = play.api.Logger(this.getClass)
2724
}

src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ trait DexDataPlugs {
1111
val logger: Logger
1212
val ws: WSClient
1313
val dexAddress: String
14-
val dexHost: String
1514

1615
def dataplugConnectHat(
1716
access_token: String,
@@ -22,7 +21,6 @@ trait DexDataPlugs {
2221

2322
val request: WSRequest = ws
2423
.url(s"$dexAddress/api/dataplugs/$dataplugId/connect")
25-
.withVirtualHost(dexHost)
2624
.withQueryStringParameters(("hat", hatAddress))
2725
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
2826

src/main/scala/org/hatdex/dex/api/DexNotices.scala

-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ trait DexNotices {
1313
val logger: Logger
1414
val ws: WSClient
1515
val dexAddress: String
16-
val dexHost: String
1716

1817
import DexJsonFormats._
1918

@@ -25,7 +24,6 @@ trait DexNotices {
2524

2625
val request: WSRequest = ws
2726
.url(s"$dexAddress/api/notices")
28-
.withVirtualHost(dexHost)
2927
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
3028

3129
val futureResponse: Future[WSResponse] = request.post(Json.toJson(notice))

src/main/scala/org/hatdex/dex/api/DexOffers.scala

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ trait DexOffers {
1212
val logger: Logger
1313
val ws: WSClient
1414
val dexAddress: String
15-
val dexHost: String
1615

1716
import io.dataswift.models.dex.json.DexJsonFormats._
1817

@@ -27,7 +26,6 @@ trait DexOffers {
2726

2827
val request: WSRequest = ws
2928
.url(s"$dexAddress/api/offer/$offerId/claims")
30-
.withVirtualHost(dexHost)
3129
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
3230

3331
val futureResponse: Future[WSResponse] = request.get()

src/main/scala/org/hatdex/dex/api/DexStats.scala

-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ trait DexStats {
1515
val logger: Logger
1616
val ws: WSClient
1717
val dexAddress: String
18-
val dexHost: String
1918

2019
def postStats(
2120
access_token: String,
2221
stats: Seq[DataStats]
2322
)(implicit ec: ExecutionContext): Future[Unit] = {
2423
val request: WSRequest = ws
2524
.url(s"$dexAddress/stats/report")
26-
.withVirtualHost(dexHost)
2725
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
2826

2927
val futureResponse: Future[WSResponse] = request.post(Json.toJson(stats))

src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala

-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ trait DexApplications {
1515
protected val logger: Logger
1616
protected val ws: WSClient
1717
protected val dexAddress: String
18-
protected val dexHost: String
1918
protected val apiVersion: String
2019

2120
implicit protected val applicationFormat: Format[Application] =
@@ -28,7 +27,6 @@ trait DexApplications {
2827
def applications(includeUnpublished: Boolean = false)(implicit ec: ExecutionContext): Future[Seq[Application]] = {
2928
val request: WSRequest = ws
3029
.url(s"$dexAddress/api/$apiVersion/applications")
31-
.withVirtualHost(dexHost)
3230
.withQueryStringParameters("unpublished" -> includeUnpublished.toString)
3331
.withHttpHeaders("Accept" -> "application/json")
3432

@@ -59,7 +57,6 @@ trait DexApplications {
5957
val requestedLanguage = lang.getOrElse("en")
6058
val request: WSRequest = ws
6159
.url(s"$dexAddress/api/$apiVersion/applications/$applicationId")
62-
.withVirtualHost(dexHost)
6360
.withQueryStringParameters("lang" -> requestedLanguage)
6461
.withHttpHeaders("Accept" -> "application/json")
6562

@@ -92,7 +89,6 @@ trait DexApplications {
9289
)(implicit ec: ExecutionContext): Future[Seq[ApplicationHistory]] = {
9390
val request: WSRequest = ws
9491
.url(s"$dexAddress/api/$apiVersion/applications-history")
95-
.withVirtualHost(dexHost)
9692
.withQueryStringParameters("unpublished" -> includeUnpublished.toString)
9793
.withHttpHeaders("Accept" -> "application/json")
9894

@@ -124,7 +120,6 @@ trait DexApplications {
124120

125121
val request: WSRequest = ws
126122
.url(s"$dexAddress/api/$apiVersion/applications")
127-
.withVirtualHost(dexHost)
128123
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
129124

130125
val futureResponse: Future[WSResponse] = request.post(Json.toJson(application))
@@ -162,7 +157,6 @@ trait DexApplications {
162157

163158
val request: WSRequest = ws
164159
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}")
165-
.withVirtualHost(dexHost)
166160
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
167161

168162
val futureResponse: Future[WSResponse] = request.put(Json.toJson(application))
@@ -200,7 +194,6 @@ trait DexApplications {
200194

201195
val request: WSRequest = ws
202196
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/publish")
203-
.withVirtualHost(dexHost)
204197
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
205198

206199
val futureResponse: Future[WSResponse] = request.get()
@@ -231,7 +224,6 @@ trait DexApplications {
231224

232225
val request: WSRequest = ws
233226
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/suspend")
234-
.withVirtualHost(dexHost)
235227
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
236228

237229
val futureResponse: Future[WSResponse] = request.get()
@@ -259,7 +251,6 @@ trait DexApplications {
259251

260252
val request: WSRequest = ws
261253
.url(s"$dexAddress/api/$apiVersion/applications/$applicationId")
262-
.withVirtualHost(dexHost)
263254
.withHttpHeaders("Accept" -> "application/json")
264255

265256
val futureResponse: Future[WSResponse] = request.get()
@@ -297,7 +288,6 @@ trait DexApplications {
297288

298289
val request: WSRequest = ws
299290
.url(s"$dexAddress/api/$apiVersion/applications/developer")
300-
.withVirtualHost(dexHost)
301291
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
302292

303293
val futureResponse: Future[WSResponse] = request.put(Json.toJson(developer))
@@ -335,7 +325,6 @@ trait DexApplications {
335325

336326
val request: WSRequest = ws
337327
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/versions")
338-
.withVirtualHost(dexHost)
339328
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
340329

341330
val futureResponse: Future[WSResponse] = request.post(Json.toJson(application))

src/main/scala/org/hatdex/dex/apiV2/DexClient.scala

-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import org.hatdex.dex.api.{ DexDataPlugs, DexNotices }
1313
import play.api.Logger
1414
import play.api.libs.ws.WSClient
1515

16-
import java.net.URL
17-
1816
class DexClient(
1917
val ws: WSClient,
2018
val dexAddress: String)
@@ -26,6 +24,5 @@ class DexClient(
2624
with DexApplications {
2725

2826
override val apiVersion: String = "v2"
29-
override val dexHost: String = new URL(dexAddress).getHost
3027
val logger: Logger = play.api.Logger(this.getClass)
3128
}

src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala

-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ trait DexOffers {
1313
protected val logger: Logger
1414
protected val ws: WSClient
1515
protected val dexAddress: String
16-
protected val dexHost: String
1716
protected val apiVersion: String
1817

1918
import io.dataswift.models.dex.json.DexJsonFormats._
@@ -23,7 +22,6 @@ trait DexOffers {
2322

2423
val request: WSRequest = ws
2524
.url(s"$dexAddress/api/v2/offers")
26-
.withVirtualHost(dexHost)
2725
.withHttpHeaders("Accept" -> "application/json")
2826

2927
val futureResponse: Future[WSResponse] = request.get()
@@ -54,7 +52,6 @@ trait DexOffers {
5452

5553
val request: WSRequest = ws
5654
.url(s"$dexAddress/api/v2/offer")
57-
.withVirtualHost(dexHost)
5855
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
5956

6057
val futureResponse: Future[WSResponse] = request.post(Json.toJson(offer))
@@ -92,7 +89,6 @@ trait DexOffers {
9289

9390
val request: WSRequest = ws
9491
.url(s"$dexAddress/api/v2/offer/$offerId/claims")
95-
.withVirtualHost(dexHost)
9692
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
9793

9894
val futureResponse: Future[WSResponse] = request.get()
@@ -132,7 +128,6 @@ trait DexOffers {
132128

133129
val request: WSRequest = ws
134130
.url(s"$dexAddress/api/v2/offer/$offerId/registerClaim")
135-
.withVirtualHost(dexHost)
136131
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
137132
.withQueryStringParameters(("hat", hat))
138133

@@ -184,7 +179,6 @@ trait DexOffers {
184179

185180
val request: WSRequest = ws
186181
.url(s"$dexAddress/api/v2/offer/$offerId")
187-
.withVirtualHost(dexHost)
188182
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
189183
.withQueryStringParameters(("status", status))
190184

src/main/scala/org/hatdex/dex/apiV2/DexStats.scala

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ trait DexStats {
1616
protected val logger: Logger
1717
protected val ws: WSClient
1818
protected val dexAddress: String
19-
protected val dexHost: String
2019
protected val apiVersion: String
2120

2221
implicit protected val dataStatsFormat: Format[DataStats] =
@@ -30,7 +29,6 @@ trait DexStats {
3029
)(implicit ec: ExecutionContext): Future[Unit] = {
3130
val request: WSRequest = ws
3231
.url(s"$dexAddress/stats/report")
33-
.withVirtualHost(dexHost)
3432
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
3533

3634
val futureResponse: Future[WSResponse] = request.post(Json.toJson(stats))
@@ -48,7 +46,6 @@ trait DexStats {
4846
def availableData()(implicit ec: ExecutionContext): Future[Seq[NamespaceStructure]] = {
4947
val request: WSRequest = ws
5048
.url(s"$dexAddress/stats/available-data")
51-
.withVirtualHost(dexHost)
5249
.withHttpHeaders("Accept" -> "application/json")
5350

5451
val futureResponse: Future[WSResponse] = request.get()

src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ trait DexUsers {
1414
protected val logger: Logger
1515
protected val ws: WSClient
1616
protected val dexAddress: String
17-
protected val dexHost: String
1817
protected val apiVersion: String
1918

2019
def registerHat(
@@ -43,7 +42,6 @@ trait DexUsers {
4342
)(implicit ec: ExecutionContext): Future[Done] = {
4443
val request: WSRequest = ws
4544
.url(s"$dexAddress/api/users/register-consent/$applicationId")
46-
.withVirtualHost(dexHost)
4745
.withRequestTimeout(2500.millis)
4846
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)
4947

src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala

-11
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ trait DexApplications {
2929
protected val logger: Logger
3030
protected val ws: WSClient
3131
protected val dexAddress: String
32-
protected val dexHost: String
3332
protected val apiVersion: String
3433

3534
private def optionalParam[T](
@@ -58,7 +57,6 @@ trait DexApplications {
5857

5958
val request: WSRequest = ws
6059
.url(s"$dexAddress/api/$apiVersion/applications")
61-
.withVirtualHost(dexHost)
6260
.withQueryStringParameters(queryParams(unpublished, kind, startId, limit): _*)
6361
.withHttpHeaders("Accept" -> "application/json")
6462

@@ -89,7 +87,6 @@ trait DexApplications {
8987
val requestedLanguage = lang.getOrElse("en")
9088
val request: WSRequest = ws
9189
.url(s"$dexAddress/api/$apiVersion/applications/$applicationId")
92-
.withVirtualHost(dexHost)
9390
.withQueryStringParameters("lang" -> requestedLanguage)
9491
.withHttpHeaders("Accept" -> "application/json")
9592

@@ -126,7 +123,6 @@ trait DexApplications {
126123

127124
val request: WSRequest = ws
128125
.url(s"$dexAddress/api/$apiVersion/applications-history")
129-
.withVirtualHost(dexHost)
130126
.withQueryStringParameters(queryParams(unpublished, kind, startId, limit): _*)
131127
.withHttpHeaders("Accept" -> "application/json")
132128

@@ -158,7 +154,6 @@ trait DexApplications {
158154

159155
val request: WSRequest = ws
160156
.url(s"$dexAddress/api/$apiVersion/applications")
161-
.withVirtualHost(dexHost)
162157
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
163158

164159
val futureResponse: Future[WSResponse] = request.post(Json.toJson(application))
@@ -196,7 +191,6 @@ trait DexApplications {
196191

197192
val request: WSRequest = ws
198193
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}")
199-
.withVirtualHost(dexHost)
200194
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
201195

202196
val futureResponse: Future[WSResponse] = request.put(Json.toJson(application))
@@ -234,7 +228,6 @@ trait DexApplications {
234228

235229
val request: WSRequest = ws
236230
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/publish")
237-
.withVirtualHost(dexHost)
238231
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
239232

240233
val futureResponse: Future[WSResponse] = request.get()
@@ -265,7 +258,6 @@ trait DexApplications {
265258

266259
val request: WSRequest = ws
267260
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/suspend")
268-
.withVirtualHost(dexHost)
269261
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
270262

271263
val futureResponse: Future[WSResponse] = request.get()
@@ -293,7 +285,6 @@ trait DexApplications {
293285

294286
val request: WSRequest = ws
295287
.url(s"$dexAddress/api/$apiVersion/applications/$applicationId")
296-
.withVirtualHost(dexHost)
297288
.withHttpHeaders("Accept" -> "application/json")
298289

299290
val futureResponse: Future[WSResponse] = request.get()
@@ -331,7 +322,6 @@ trait DexApplications {
331322

332323
val request: WSRequest = ws
333324
.url(s"$dexAddress/api/$apiVersion/applications/developer")
334-
.withVirtualHost(dexHost)
335325
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
336326

337327
val futureResponse: Future[WSResponse] = request.put(Json.toJson(developer))
@@ -369,7 +359,6 @@ trait DexApplications {
369359

370360
val request: WSRequest = ws
371361
.url(s"$dexAddress/api/$apiVersion/applications/${application.id}/versions")
372-
.withVirtualHost(dexHost)
373362
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
374363

375364
val futureResponse: Future[WSResponse] = request.post(Json.toJson(application))

src/main/scala/org/hatdex/dex/apiV3/DexClient.scala

-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import org.hatdex.dex.api.{ DexDataPlugs, DexNotices }
1313
import play.api.Logger
1414
import play.api.libs.ws.WSClient
1515

16-
import java.net.URL
17-
1816
class DexClient(
1917
val ws: WSClient,
2018
val dexAddress: String)
@@ -26,6 +24,5 @@ class DexClient(
2624
with DexApplications {
2725

2826
override val apiVersion: String = "v3"
29-
override val dexHost: String = new URL(dexAddress).getHost
3027
val logger: Logger = play.api.Logger(this.getClass)
3128
}

0 commit comments

Comments
 (0)