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

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

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

package app.bsky.graph

import app.bsky.richtext.Facet
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmInline
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import sh.christian.ozone.api.model.Blob
import sh.christian.ozone.api.model.JsonContent
import sh.christian.ozone.api.model.Timestamp
import sh.christian.ozone.api.runtime.valueClassSerializer

@Serializable
public sealed interface ListLabelsUnion {
  public class SelfLabelsSerializer : KSerializer by valueClassSerializer(
    serialName = "com.atproto.label.defs#selfLabels",
    constructor = ::SelfLabels,
    valueProvider = SelfLabels::value,
    valueSerializerProvider = { com.atproto.label.SelfLabels.serializer() },
  )

  @JvmInline
  @Serializable(with = SelfLabelsSerializer::class)
  @SerialName("com.atproto.label.defs#selfLabels")
  public value class SelfLabels(
    public val `value`: com.atproto.label.SelfLabels,
  ) : ListLabelsUnion

  @JvmInline
  @Serializable
  public value class Unknown(
    public val `value`: JsonContent,
  ) : ListLabelsUnion
}

/**
 * @param purpose Defines the purpose of the list (aka, moderation-oriented or curration-oriented)
 * @param name Display name for list; can not be empty.
 */
@Serializable
public data class List(
  /**
   * Defines the purpose of the list (aka, moderation-oriented or curration-oriented)
   */
  public val purpose: Token,
  /**
   * Display name for list; can not be empty.
   */
  public val name: String,
  public val description: String? = null,
  public val descriptionFacets: kotlin.collections.List = emptyList(),
  public val avatar: Blob? = null,
  public val labels: ListLabelsUnion? = null,
  public val createdAt: Timestamp,
) {
  init {
    require(name.count() >= 1) {
      "name.count() must be >= 1, but was ${name.count()}"
    }
    require(name.count() <= 64) {
      "name.count() must be <= 64, but was ${name.count()}"
    }
    require(description == null || description.count() <= 3_000) {
      "description.count() must be <= 3_000, but was ${description?.count()}"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy