Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add default baseURL #24

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 })
}
}