Endpoint

data class Endpoint(urlParts: EndpointRegion.UrlParts, queryParameters: EndpointRegion.QueryParameters)

Class representing an endpoint template. Valid template structures:

  • static text

  • {var} -> replace w/ value

  • {{var}} -> replace w/ /var/{var} or &var={var} if in query params

  • [?var:...] -> body if var != null, else empty. The body must contain whole segments

  • {{?var}} ->[?var:{{var}}]

Constructors

Link copied to clipboard
fun Endpoint(urlParts: EndpointRegion.UrlParts, queryParameters: EndpointRegion.QueryParameters)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun allReferencedParameters(): Set<String>
Link copied to clipboard
inline fun fillParameters(transform: (EndpointPart.Parameter) -> String?): Endpoint

Substitute parameters in this endpoint, without resolving optionals (it maps into all of them)

Link copied to clipboard
inline fun fillWithArgs(methodName: String, knownArguments: Set<String>, usedOptionals: Set<String>, getValue: (String) -> String): Pair<String, Set<String>>

Substitute argument values into an endpoint template. Requires all keys in the template to be used.

Link copied to clipboard
inline fun forEachPart(traverseOptionals: Boolean = true, block: (EndpointPart<*>) -> Unit)

Call block on each part of the endpoint, traversing down into optionals if traverseOptionals is true.

inline fun forEachPart(noinline traverseOptionals: (String) -> Boolean, block: (EndpointPart<*>) -> Unit)

Call block on each part of the endpoint, traversing down into optionals if traverseOptionals is true for that optional.

Link copied to clipboard
fun resolve(url: UrlRequest): Map<String, String>?
fun resolve(url: String): Map<String, String>?

Resolve this endpoint. Returns parameter values if successful, or null if not.

Link copied to clipboard
fun resolveOptionals(usedOptionals: Set<String>): Endpoint

Include or exclude any optionals depending on if their key is in usedOptionals

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
val allResolvePaths: Set<ResolveEndpoint>

All possible resolution paths of this endpoint.

Link copied to clipboard
val queryParameters: EndpointRegion.QueryParameters
Link copied to clipboard
val resolveTree: EndpointResolveTree

The resolve tree for this endpoint.

Link copied to clipboard
val urlParts: EndpointRegion.UrlParts

Sources

Link copied to clipboard