All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.app.bsky.graph.getRelationships.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("DEPRECATION")

package app.bsky.graph

import kotlin.Any
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.jvm.JvmInline
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.JsonContent
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() },
  )

  @JvmInline
  @Serializable(with = RelationshipSerializer::class)
  @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() },
  )

  @JvmInline
  @Serializable(with = NotFoundActorSerializer::class)
  @SerialName("app.bsky.graph.defs#notFoundActor")
  public value class NotFoundActor(
    public val `value`: app.bsky.graph.NotFoundActor,
  ) : GetRelationshipsResponseRelationshipUnion

  @JvmInline
  @Serializable
  public value class Unknown(
    public val `value`: JsonContent,
  ) : 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: List = emptyList(),
) {
  init {
    require(others.count() <= 30) {
      "others.count() must be <= 30, but was ${others.count()}"
    }
  }

  public fun asList(): List> = buildList {
    add("actor" to actor)
    others.forEach {
      add("others" to it)
    }
  }
}

@Serializable
public data class GetRelationshipsResponse(
  public val actor: Did? = null,
  public val relationships: List,
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy