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(commands) #132: missing changes in command module #136

Merged
merged 1 commit into from
Oct 4, 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 @@ -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
Loading