Skip to content

Commit

Permalink
Update host (#59)
Browse files Browse the repository at this point in the history
* Run scalafmt and scalafix

* Removed virtual host
  • Loading branch information
whiteshadow-gr authored Aug 2, 2021
1 parent b570077 commit 2a79612
Show file tree
Hide file tree
Showing 15 changed files with 1 addition and 62 deletions.
5 changes: 1 addition & 4 deletions src/main/scala/org/hatdex/dex/api/DexClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
2 changes: 0 additions & 2 deletions src/main/scala/org/hatdex/dex/api/DexDataPlugs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ trait DexDataPlugs {
val logger: Logger
val ws: WSClient
val dexAddress: String
val dexHost: String

def dataplugConnectHat(
access_token: String,
Expand All @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/org/hatdex/dex/api/DexNotices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ trait DexNotices {
val logger: Logger
val ws: WSClient
val dexAddress: String
val dexHost: String

import DexJsonFormats._

Expand All @@ -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))
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/org/hatdex/dex/api/DexOffers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._

Expand All @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/org/hatdex/dex/api/DexStats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ trait DexStats {
val logger: Logger
val ws: WSClient
val dexAddress: String
val dexHost: String

def postStats(
access_token: String,
stats: Seq[DataStats]
)(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))
Expand Down
11 changes: 0 additions & 11 deletions src/main/scala/org/hatdex/dex/apiV2/DexApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand All @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/org/hatdex/dex/apiV2/DexClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
6 changes: 0 additions & 6 deletions src/main/scala/org/hatdex/dex/apiV2/DexOffers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand All @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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))

Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/org/hatdex/dex/apiV2/DexStats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] =
Expand All @@ -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))
Expand All @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions src/main/scala/org/hatdex/dex/apiV2/DexUsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)

Expand Down
11 changes: 0 additions & 11 deletions src/main/scala/org/hatdex/dex/apiV3/DexApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 0 additions & 3 deletions src/main/scala/org/hatdex/dex/apiV3/DexClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Loading

0 comments on commit 2a79612

Please sign in to comment.