Skip to content

Commit

Permalink
Merge pull request #74 from dataswift/remove-schema-config
Browse files Browse the repository at this point in the history
Removing the schema configuration
  • Loading branch information
whiteshadow-gr authored Jul 28, 2021
2 parents 5e610bf + 97e426d commit 9e70629
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tmp
.history
dist
/.idea
/.bsp/
/*.iml
/out
/.idea_modules
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
#
#

sbt.version=1.5.3
sbt.version=1.5.5
13 changes: 6 additions & 7 deletions src/main/scala/org/hatdex/hat/api/services/HatApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import scala.concurrent.{ ExecutionContext, Future }
trait HatApplications {
protected val logger: Logger
protected val ws: WSClient
protected val schema: String
protected val hatAddress: String
protected val apiVersion: String
protected val host: String = if (hatAddress.isEmpty) "mock" else hatAddress
Expand All @@ -34,7 +33,7 @@ trait HatApplications {
def getApplications(access_token: String)(implicit ec: ExecutionContext): Future[Seq[HatService]] = {

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/v2/application")
.url(s"$hatAddress/api/v2/application")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down Expand Up @@ -64,7 +63,7 @@ trait HatApplications {
application: HatService
)(implicit ec: ExecutionContext): Future[HatService] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/api/v2/application")
.url(s"$hatAddress/api/v2/application")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand All @@ -90,7 +89,7 @@ trait HatApplications {

def getAllApplications(accessToken: String)(implicit ec: ExecutionContext): Future[Seq[HatApplication]] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/applications")
.url(s"$hatAddress/api/$apiVersion/applications")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)

Expand Down Expand Up @@ -119,7 +118,7 @@ trait HatApplications {
applicationId: String
)(implicit ec: ExecutionContext): Future[Boolean] = {
implicit val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/applications/$applicationId/setup")
.url(s"$hatAddress/api/$apiVersion/applications/$applicationId/setup")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)

Expand All @@ -131,7 +130,7 @@ trait HatApplications {
applicationId: String
)(implicit ec: ExecutionContext): Future[Boolean] = {
implicit val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/applications/$applicationId/disable")
.url(s"$hatAddress/api/$apiVersion/applications/$applicationId/disable")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)

Expand All @@ -143,7 +142,7 @@ trait HatApplications {
applicationId: String
)(implicit ec: ExecutionContext): Future[String] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/applications/$applicationId/access-token")
.url(s"$hatAddress/api/$apiVersion/applications/$applicationId/access-token")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> accessToken)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import scala.concurrent.{ ExecutionContext, Future }
trait HatAuthentication {
protected val logger: Logger
protected val ws: WSClient
protected val schema: String
protected val hatAddress: String
protected val apiVersion: String
protected val host: String = if (hatAddress.isEmpty) "mock" else hatAddress
Expand All @@ -34,7 +33,7 @@ trait HatAuthentication {

def retrievePublicKey()(implicit ec: ExecutionContext): Future[String] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/publickey")
.url(s"$hatAddress/publickey")
.withHttpHeaders("Accept" -> "text/plain")
.withVirtualHost(host)

Expand All @@ -52,7 +51,7 @@ trait HatAuthentication {
password: String
)(implicit ec: ExecutionContext): Future[String] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/users/access_token")
.url(s"$hatAddress/users/access_token")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "username" -> username, "password" -> password)

Expand Down Expand Up @@ -85,7 +84,7 @@ trait HatAuthentication {
hatUser: User
)(implicit ec: ExecutionContext): Future[UUID] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/users/user")
.url(s"$hatAddress/users/user")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand All @@ -108,7 +107,7 @@ trait HatAuthentication {
hatUser: User
)(implicit ec: ExecutionContext): Future[UUID] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/users/user/${hatUser.userId}/update")
.url(s"$hatAddress/users/user/${hatUser.userId}/update")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand All @@ -131,7 +130,7 @@ trait HatAuthentication {
userId: UUID
)(implicit ec: ExecutionContext): Future[Boolean] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/users/user/$userId/enable")
.url(s"$hatAddress/users/user/$userId/enable")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand All @@ -156,7 +155,7 @@ trait HatAuthentication {
)(implicit ec: ExecutionContext,
lang: Lang): Future[String] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/control/v2/auth/request-verification")
.url(s"$hatAddress/control/v2/auth/request-verification")
.withVirtualHost(host)
.withQueryStringParameters("lang" -> lang.language)
.withHttpHeaders("Accept" -> "application/json")
Expand Down Expand Up @@ -187,7 +186,7 @@ trait HatAuthentication {
lang: String = "en"
)(implicit ec: ExecutionContext): Future[String] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/control/v2/auth/claim")
.url(s"$hatAddress/control/v2/auth/claim")
.withVirtualHost(host)
.withQueryStringParameters("lang" -> lang)
.withHttpHeaders("Accept" -> "application/json")
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/org/hatdex/hat/api/services/HatClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import javax.inject.Inject
class HatClient(
val ws: WSClient,
val hatAddress: String,
override val schema: String,
override val apiVersion: String)
extends HatAuthentication
with HatDataDebits
Expand All @@ -27,6 +26,6 @@ class HatClient(
with Logging {
@Inject def this(
ws: WSClient,
hatAddress: String) = this(ws, hatAddress, "https://", "v2.6")
hatAddress: String) = this(ws, hatAddress, "v2.6")
override val host: String = if (hatAddress.isEmpty) "mock" else hatAddress
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import scala.concurrent.{ ExecutionContext, Future }
trait HatDataDebits {
protected val logger: Logger
protected val ws: WSClient
protected val schema: String
protected val hatAddress: String
protected val apiVersion: String
protected val host: String = if (hatAddress.isEmpty) "mock" else hatAddress
Expand All @@ -25,7 +24,7 @@ trait HatDataDebits {
)(implicit ec: ExecutionContext): Future[DataDebit] = {

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data-debit/$dataDebitId")
.url(s"$hatAddress/api/$apiVersion/data-debit/$dataDebitId")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down Expand Up @@ -57,7 +56,7 @@ trait HatDataDebits {
def listDataDebits(access_token: String)(implicit ec: ExecutionContext): Future[Seq[DataDebit]] = {

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data-debit")
.url(s"$hatAddress/api/$apiVersion/data-debit")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down Expand Up @@ -88,7 +87,7 @@ trait HatDataDebits {
)(implicit ec: ExecutionContext): Future[DataDebitData] = {

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data-debit/$dataDebitId/values")
.url(s"$hatAddress/api/$apiVersion/data-debit/$dataDebitId/values")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down Expand Up @@ -123,7 +122,7 @@ trait HatDataDebits {
dataDebit: DataDebitSetupRequest
)(implicit ec: ExecutionContext): Future[DataDebit] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data-debit/$dataDebitId")
.url(s"$hatAddress/api/$apiVersion/data-debit/$dataDebitId")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/org/hatdex/hat/api/services/HatRichData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import scala.concurrent.{ ExecutionContext, Future }
trait HatRichData {
protected val logger: Logger
protected val ws: WSClient
protected val schema: String
protected val hatAddress: String
protected val apiVersion: String
protected val host: String = if (hatAddress.isEmpty) "mock" else hatAddress
Expand All @@ -38,7 +37,7 @@ trait HatRichData {
)(implicit ec: ExecutionContext): Future[Seq[EndpointData]] = {

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data/$namespace/$endpoint")
.url(s"$hatAddress/api/$apiVersion/data/$namespace/$endpoint")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
.withQueryStringParameters("skipErrors" -> skipErrors.toString)
Expand Down Expand Up @@ -79,7 +78,7 @@ trait HatRichData {
data: Seq[EndpointData]
)(implicit ec: ExecutionContext): Future[Seq[EndpointData]] = {
val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data-batch")
.url(s"$hatAddress/api/$apiVersion/data-batch")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down Expand Up @@ -130,7 +129,7 @@ trait HatRichData {
).flatten

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/$apiVersion/data/$namespace/$endpoint")
.url(s"$hatAddress/api/$apiVersion/data/$namespace/$endpoint")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)
.withQueryStringParameters(queryParameter: _*)
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/org/hatdex/hat/api/services/HatSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import scala.concurrent.{ ExecutionContext, Future }
trait HatSystem {
protected val logger: Logger
protected val ws: WSClient
protected val schema: String
protected val hatAddress: String
protected val host: String = if (hatAddress.isEmpty) "mock" else hatAddress

def update(access_token: String)(implicit ec: ExecutionContext): Future[Unit] = {
logger.debug(s"Update HAT database")

val request: WSRequest = ws
.url(s"$schema$hatAddress/system/update")
.url(s"$hatAddress/system/update")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand All @@ -50,7 +49,7 @@ trait HatSystem {
logger.debug(s"Destroying HAT Cache")

val request: WSRequest = ws
.url(s"$schema$hatAddress/api/v2.6/system/destroy-cache")
.url(s"$hatAddress/api/v2.6/system/destroy-cache")
.withVirtualHost(host)
.withHttpHeaders("Accept" -> "application/json", "X-Auth-Token" -> access_token)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ object MockHatServer {

def withHatClient[T](block: HatClient => T): T =
withMockHatServerClient { client =>
block(new HatClient(client, "", "", "v2.6"))
block(new HatClient(client, "", "v2.6"))
}
}

0 comments on commit 9e70629

Please sign in to comment.