commonMain.app.bsky.graph.getRelationships.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bluesky-jvm Show documentation
Show all versions of bluesky-jvm Show documentation
Bluesky Social API bindings for Kotlin.
The newest version!
@file:Suppress("DEPRECATION")
package app.bsky.graph
import kotlin.Any
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmInline
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.AtIdentifier
import sh.christian.ozone.api.Did
import sh.christian.ozone.api.model.ReadOnlyList
import sh.christian.ozone.api.runtime.valueClassSerializer
@Serializable
public sealed interface GetRelationshipsResponseRelationshipUnion {
public class RelationshipSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.graph.defs#relationship",
constructor = ::Relationship,
valueProvider = Relationship::value,
valueSerializerProvider = { app.bsky.graph.Relationship.serializer() },
)
@Serializable(with = RelationshipSerializer::class)
@JvmInline
@SerialName("app.bsky.graph.defs#relationship")
public value class Relationship(
public val `value`: app.bsky.graph.Relationship,
) : GetRelationshipsResponseRelationshipUnion
public class NotFoundActorSerializer : KSerializer by valueClassSerializer(
serialName = "app.bsky.graph.defs#notFoundActor",
constructor = ::NotFoundActor,
valueProvider = NotFoundActor::value,
valueSerializerProvider = { app.bsky.graph.NotFoundActor.serializer() },
)
@Serializable(with = NotFoundActorSerializer::class)
@JvmInline
@SerialName("app.bsky.graph.defs#notFoundActor")
public value class NotFoundActor(
public val `value`: app.bsky.graph.NotFoundActor,
) : GetRelationshipsResponseRelationshipUnion
}
/**
* @param actor Primary account requesting relationships for.
* @param others List of 'other' accounts to be related back to the primary.
*/
@Serializable
public data class GetRelationshipsQueryParams(
/**
* Primary account requesting relationships for.
*/
public val actor: AtIdentifier,
/**
* List of 'other' accounts to be related back to the primary.
*/
public val others: ReadOnlyList = persistentListOf(),
) {
init {
require(others.count() <= 30) {
"others.count() must be <= 30, but was ${others.count()}"
}
}
public fun asList(): ReadOnlyList> = buildList {
add("actor" to actor)
others.forEach {
add("others" to it)
}
}.toImmutableList()
}
@Serializable
public data class GetRelationshipsResponse(
public val actor: Did? = null,
public val relationships: ReadOnlyList,
)