Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
issuer-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeplotean committed Oct 19, 2023
1 parent 61937aa commit 8245011
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/kotlin/id/walt/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ fun Application.module() {
history()
account()
nfts()
issuers()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package id.walt.usecases.issuers

import kotlinx.serialization.Serializable

@Serializable
data class IssuerCredentialDataTransferObject(
val type: String,
val uiEndpoint: String,
val callbackUrl: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package id.walt.usecases.issuers

import kotlinx.serialization.Serializable

@Serializable
data class IssuerDataTransferObject(
val name: String,
val description: String = "no description",
)
13 changes: 13 additions & 0 deletions src/main/kotlin/id/walt/usecases/issuers/IssuersUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package id.walt.usecases.issuers

class IssuersUseCase {
fun list(){
TODO()
}

fun supportedCredentials(issuer: String){
TODO()
}


}
77 changes: 77 additions & 0 deletions src/main/kotlin/id/walt/web/controllers/IssuersController.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package id.walt.web.controllers

import id.walt.usecases.issuers.IssuerCredentialDataTransferObject
import id.walt.usecases.issuers.IssuerDataTransferObject
import io.github.smiley4.ktorswaggerui.dsl.get
import io.github.smiley4.ktorswaggerui.dsl.route
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.response.*

fun Application.issuers() = walletRoute {
route("issuers", {
tags = listOf("Issuers")
}) {
get({
summary = "List issuers"
response {
HttpStatusCode.OK to {
description = "Array of issuer objects"
body<List<IssuerDataTransferObject>>()
}
}
}) {
context.respond(mockIssuersList())
}
route("{issuer}/credentials", {
request {
pathParameter<String>("issuer") {
description = "The issuer name"
example = "walt.id"
}
}
}) {
get({
summary = "Show supported credentials for the given issuer"

response {
HttpStatusCode.OK to {
description = "Array of issuer credential objects"
body<List<IssuerCredentialDataTransferObject>>()
}
}
}) {
context.respond(mockCredentialsList())
}
}
}
}

internal fun mockIssuersList() = listOf(
IssuerDataTransferObject(
name = "walt.id",
description = "walt.id issuer portal",
),
IssuerDataTransferObject(
name = "walt-test#cloud",
description = "walt-test.cloud issuer portal",
),
)

internal fun mockCredentialsList() = listOf(
IssuerCredentialDataTransferObject(
type = "PermanentResidentCard",
uiEndpoint = "https://portal.walt.id",
callbackUrl = "https://wallet.portal.walt.id",
),
IssuerCredentialDataTransferObject(
type = "VerifiableAttestation",
uiEndpoint = "https://portal.walt.id",
callbackUrl = "https://wallet.portal.walt.id",
),
IssuerCredentialDataTransferObject(
type = "OpenBadgeCredential",
uiEndpoint = "https://portal.walt.id",
callbackUrl = "https://wallet.portal.walt.id",
),
)

0 comments on commit 8245011

Please sign in to comment.