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

fix(sample) #115: 401 error in credentials sample #116

Merged
merged 1 commit into from
Jun 27, 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
Expand Up @@ -21,10 +21,11 @@ open class PartnerCacheRepository : PartnerRepository {

override suspend fun savePartnerUrlForTokenA(tokenA: String, partnerUrl: String): String? = partners
.toList()
.firstOrNull { it.tokenA == tokenA }
?.copy(url = partnerUrl)
?.also { partners[it.url!!] = it }
?.url
.indexOfFirst { it.tokenA == tokenA }
.let { index ->
partners[index] = partners[index].copy(url = partnerUrl)
partnerUrl
}

override suspend fun saveCredentialsRoles(
partnerUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun main() {
serverVersionsUrlProvider = { receiverVersionsUrl },
requiredEndpoints = requiredOtherPartEndpoints
),
receiverVersionsRepository
versionsRepository = receiverVersionsRepository
).registerOn(receiverServer)
VersionsServer(
service = VersionsService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import com.izivia.ocpi.toolkit.modules.credentials.services.CredentialsClientSer
import com.izivia.ocpi.toolkit.modules.credentials.services.RequiredEndpoints
import com.izivia.ocpi.toolkit.modules.locations.domain.BusinessDetails
import com.izivia.ocpi.toolkit.modules.versions.VersionsServer
import com.izivia.ocpi.toolkit.modules.versions.domain.Endpoint
import com.izivia.ocpi.toolkit.modules.versions.domain.InterfaceRole
import com.izivia.ocpi.toolkit.modules.versions.domain.ModuleID
import com.izivia.ocpi.toolkit.modules.versions.domain.VersionNumber
import com.izivia.ocpi.toolkit.modules.versions.repositories.InMemoryVersionsRepository
import com.izivia.ocpi.toolkit.modules.versions.services.VersionsService
import com.izivia.ocpi.toolkit.samples.common.Http4kTransportClientBuilder
Expand Down Expand Up @@ -38,9 +41,14 @@ fun main() {
VersionsServer(
service = VersionsService(
repository = senderVersionsRepository,
baseUrlProvider = { receiverUrl }
baseUrlProvider = { senderUrl }
)
).registerOn(senderServer)

senderVersionsRepository.addEndpoint(
VersionNumber.V2_2_1,
Endpoint(ModuleID.credentials, InterfaceRole.SENDER, "$senderUrl/2.2.1/credentials")
)
}
senderServer.start()

Expand Down
Loading