Skip to content

Endpoints

Peter Araujo edited this page Jul 28, 2024 · 1 revision

General

Each service exposes endpoints as functions depending on the resource.

Parsed responses

The default functions return a parsed response as a model object.

Convention

Get items

You can access the base endpoint (for example: /artworks) like this:

{yourService}.getItems()

For example:

val artworkService = ArtworkService()

val response = artworkService.getItems(limit = 2)

Search

You can access the search endpoint (for example: /artworks/search) like this:

{yourService}.search()

For example:

val artworkService = ArtworkService()

val response = artworkService.search(search = "monet")

By ID

You can access the "get by id" endpoint (for example: /artworks/4) like this:

{yourService}.getById()

For example:

val artworkService = ArtworkService()

val response = artworkService.getById(id = 4)

Manifest

This is an artwork-exclusive endpoint (artworks/4/manifest.json). You can access it like this:

{yourArtworkService}.getArtworkManifest(id = 4)

For example:

val artworkService = ArtworkService()

val response = artworkService.getArtworkManifest(id = 4)

Availability

All endpoints are supported.

HTTP Responses

You can also obtain the response as HttpResponse.

Convention

To get HttpResponse as response:

{yourService}.{NormalEndpoint} + AsHttpResponse()

For example:

val artworkService = ArtworkService()

val response = artworkService.getItemsAsHttpResponse(limit = 2)

Availability

For every regular endpoint there is a complementary "AsHttpResponse" endpoint.

Clone this wiki locally