-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Agent): Logic to parse out of band invitations (#25)
* [ATL-2998] Parse out of band invitation functionallity
- Loading branch information
1 parent
7cc738f
commit 85535c5
Showing
6 changed files
with
218 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...t/src/commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/models/InvitationType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.iohk.atala.prism.walletsdk.prismagent.models | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
sealed class InvitationType() |
50 changes: 50 additions & 0 deletions
50
.../commonMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/models/OutOfBandInvitation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.iohk.atala.prism.walletsdk.prismagent.models | ||
|
||
import io.iohk.atala.prism.apollo.uuid.UUID | ||
import io.iohk.atala.prism.domain.models.DID | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.Transient | ||
|
||
@Serializable | ||
data class OutOfBandInvitation( | ||
val id: String = UUID.randomUUID4().toString(), | ||
val body: Body, | ||
@SerialName("from") | ||
private val fromString: String, | ||
@Transient | ||
var from: DID = DID(fromString), | ||
val type: String | ||
) : InvitationType() { | ||
|
||
@Serializable | ||
data class Body( | ||
@SerialName("goal_code") | ||
val goalCode: String? = null, | ||
val goal: String? = null, | ||
val accept: Array<String>? = null | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (other == null || this::class != other::class) return false | ||
|
||
other as Body | ||
|
||
if (goalCode != other.goalCode) return false | ||
if (goal != other.goal) return false | ||
if (accept != null) { | ||
if (other.accept == null) return false | ||
if (!accept.contentEquals(other.accept)) return false | ||
} else if (other.accept != null) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = goalCode?.hashCode() ?: 0 | ||
result = 31 * result + (goal?.hashCode() ?: 0) | ||
result = 31 * result + (accept?.contentHashCode() ?: 0) | ||
return result | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...nMain/kotlin/io/iohk/atala/prism/walletsdk/prismagent/models/PrismOnboardingInvitation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.iohk.atala.prism.walletsdk.prismagent.models | ||
|
||
import io.iohk.atala.prism.domain.models.DID | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.Transient | ||
import kotlinx.serialization.decodeFromString | ||
import kotlinx.serialization.json.Json | ||
|
||
@Serializable | ||
data class PrismOnboardingInvitation( | ||
val onboardEndpoint: String, | ||
@SerialName("from") | ||
private val fromString: String, | ||
@Transient | ||
var from: DID? = null, | ||
val type: String | ||
) : InvitationType() { | ||
|
||
init { | ||
from = DID(fromString) | ||
} | ||
|
||
companion object { | ||
fun prismOnboardingInvitationFromJsonString(string: String): PrismOnboardingInvitation { | ||
return Json.decodeFromString(string) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters