Skip to content

Commit

Permalink
Merge pull request #136 from atschabu/fixCommandModule
Browse files Browse the repository at this point in the history
fix(commands) #132: missing changes in command module
  • Loading branch information
lilgallon authored Oct 4, 2024
2 parents 35a3b49 + 79be78e commit 8e9f7a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.izivia.ocpi.toolkit.transport.domain.HttpRequest
* Example implementation
*
* httpAuth = { req ->
* partnerRepository.getPartnerUrlByCredentialsServerToken(req.parseAuthorizationHeader())!!
* partnerRepository.getPartnerIdByCredentialsServerToken(req.parseAuthorizationHeader())!!
* }
*/
fun interface HttpAuthInterface {
suspend fun partnerUrlFromRequest(req: HttpRequest): String
suspend fun partnerIdFromRequest(req: HttpRequest): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ import com.izivia.ocpi.toolkit.modules.commands.domain.*

interface CommandCpoInterface {
suspend fun postStartSession(
partnerUrl: String,
partnerId: String,
startSession: StartSession,
): OcpiResponseBody<CommandResponse>

suspend fun postStopSession(
partnerUrl: String,
partnerId: String,
stopSession: StopSession,
): OcpiResponseBody<CommandResponse>

suspend fun postReserveNow(
partnerUrl: String,
partnerId: String,
reserveNow: ReserveNow,
): OcpiResponseBody<CommandResponse>

suspend fun postCancelReservation(
partnerUrl: String,
partnerId: String,
cancelReservation: CancelReservation,
): OcpiResponseBody<CommandResponse>

suspend fun postUnlockConnector(
partnerUrl: String,
partnerId: String,
unlockConnector: UnlockConnector,
): OcpiResponseBody<CommandResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ class CommandCpoServer(
method = HttpMethod.POST,
path = basePathSegments + FixedPathSegment("START_SESSION"),
) { req ->
val senderPlatformUrl = httpAuth.partnerUrlFromRequest(req)
val senderPlatformId = httpAuth.partnerIdFromRequest(req)
val startSession = mapper.readValue(req.body, StartSession::class.java)

req.httpResponse {
service.postStartSession(senderPlatformUrl, startSession)
service.postStartSession(senderPlatformId, startSession)
}
}

transportServer.handle(
method = HttpMethod.POST,
path = basePathSegments + FixedPathSegment("STOP_SESSION"),
) { req ->
val senderPlatformUrl = httpAuth.partnerUrlFromRequest(req)
val senderPlatformUrl = httpAuth.partnerIdFromRequest(req)
val stopSession = mapper.readValue(req.body, StopSession::class.java)

req.httpResponse {
Expand All @@ -55,7 +55,7 @@ class CommandCpoServer(
method = HttpMethod.POST,
path = basePathSegments + FixedPathSegment("RESERVE_NOW"),
) { req ->
val senderPlatformUrl = httpAuth.partnerUrlFromRequest(req)
val senderPlatformUrl = httpAuth.partnerIdFromRequest(req)
val reserveNow = mapper.readValue(req.body, ReserveNow::class.java)

req.httpResponse {
Expand All @@ -67,7 +67,7 @@ class CommandCpoServer(
method = HttpMethod.POST,
path = basePathSegments + FixedPathSegment("CANCEL_RESERVATION"),
) { req ->
val senderPlatformUrl = httpAuth.partnerUrlFromRequest(req)
val senderPlatformUrl = httpAuth.partnerIdFromRequest(req)
val cancelReservation = mapper.readValue(req.body, CancelReservation::class.java)

req.httpResponse {
Expand All @@ -79,7 +79,7 @@ class CommandCpoServer(
method = HttpMethod.POST,
path = basePathSegments + FixedPathSegment("UNLOCK_CONNECTOR"),
) { req ->
val senderPlatformUrl = httpAuth.partnerUrlFromRequest(req)
val senderPlatformUrl = httpAuth.partnerIdFromRequest(req)
val unlockConnector = mapper.readValue(req.body, UnlockConnector::class.java)

req.httpResponse {
Expand Down

0 comments on commit 8e9f7a8

Please sign in to comment.