Skip to content

Commit

Permalink
chore: add default baseURL (#24)
Browse files Browse the repository at this point in the history
PR: #24
  • Loading branch information
anonvt authored Sep 2, 2024
1 parent 891e6c6 commit 708a0ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package com.topsort.analytics.core

object ServiceSettings {
lateinit var baseApiUrl: String
lateinit var bearerToken: String

fun isSetup() : Boolean{
return this::baseApiUrl.isInitialized
}
var baseApiUrl: String = "https://api.topsort.com"
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.topsort.analytics.service

import com.topsort.analytics.Cache
import com.topsort.analytics.core.HttpClient
import com.topsort.analytics.core.HttpResponse
import com.topsort.analytics.core.ServiceSettings
import com.topsort.analytics.core.ServiceSettings.baseApiUrl
import com.topsort.analytics.core.ServiceSettings.bearerToken
import com.topsort.analytics.model.auctions.AuctionRequest
import com.topsort.analytics.model.auctions.AuctionResponse

Expand All @@ -24,10 +23,9 @@ internal object TopsortAuctionsHttpService {

private fun executeRunAuctions(auctionRequest: AuctionRequest): HttpResponse {
if(!this::httpClient.isInitialized){
assert(ServiceSettings.isSetup())
httpClient = HttpClient("${baseApiUrl}${AUCTION_ENDPOINT}")
}
val json = auctionRequest.toJsonObject().toString()
return httpClient.post(json, bearerToken)
return httpClient.post(json, Cache.token.ifEmpty { null })
}
}

0 comments on commit 708a0ee

Please sign in to comment.