Kinto client to ease communicating with the REST API.
Kinto is the backend for your next application. It's a generic JSON document store with sharing and synchronisation capabilities. It's open source. It's easy to deploy. You can host it yourself, own your data and keep it out of silos.
A constructor for a Client.
client
"https://kinto.dev.mozaws.net/v1/"
(Basic "username" "password")A type for authentication
Basic "username" "password"
Bearer "<token>"
Custom "customType" "customString"Return the header name and value for the given Auth.
headersForAuth (Basic "username" "password")A type for a Kinto resource. Usually constructed using one of bucketResource,
collectionResource or recordResource.
A constructor for a bucket resource.
bucketResource bucketDecoderA constructor for a collection resource.
collectionResource "bucket-name" collectionDecoderA constructor for a record resource.
A decoder for a basic Kinto response.
An encoder for a basic Kinto query.
A decoder for ErrorDetail. This is the kind of json message answered by Kinto when there's an error:
{"errno":104,
"message":"Please authenticate yourself to use this endpoint.",
"code":401,
"error":"Unauthorized"}Convert any Kinto.Error to a string
You create requests on either an item or a plural (list) endpoint. Kinto concepts explain that in details.
Plural (list) endpoints are:
buckets/buckets/:bucketId/collections/buckets/:bucketId/collections/:collectionId/records/Item endpoints are:
buckets/:bucketIdbuckets/:bucketId/collections/:collectionIdbuckets/:bucketId/collections/:collectionId/records/:recordIdA type describing a Kinto request. Basically an alias for an elm-http-builder request builder.
Update the URL to add a query parameter.
Create a GET request on an item endpoint
client
|> get resource itemIdCreate a POST request on a plural endpoint:
client
|> create resource itemId dataCreate a PATCH request on an item endpoint:
client
|> update resource itemId dataCreate a PUT request on an item endpoint:
client
|> replace resource itemId dataCreate a DELETE request on an item endpoint:
client
|> delete resource itemIdCreate a GET request on one of the plural endpoints. As lists are always
possibly paginated, When the request is succesful, a Pager is attached to the
reponse message.
client
|> getList resourceA stateful accumulator for a paginated list of objects.
Initialize a Pager.
emptyPager resourceUpdate a previous pager with data from a new one, appending new objects to the previous list.
updatePager nextPager previousPagerIf a pager has a nextPage, creates a GET request to retrieve the next page of objects.
When the request is succesful, a Pager with new objects appended is attached to the
reponse message.
client
|> loadNextPage pagerAdd sorting query parameters to the request sent to the Kinto server.
type Msg = TodosFetched (Result Kinto.Error (Kinto.pager Todo))
client
|> getList recordResource
|> sort ["title", "description"]
|> send TodosFetchedAdd limit query parameters to the request sent to the Kinto server.
type Msg = TodosFetched (Result Kinto.Error (Kinto.pager Todo))
client
|> getList recordResource
|> limit 10
|> send TodosFetchedAdd filtering query parameters to the request sent to the Kinto server.
type Msg = TodosFetched (Result Kinto.Error (Kinto.pager Todo))
client
|> getList recordResource
|> filter (NOT "title" "test")
|> send TodosFetchedA type for filtering, used with filter
A type for Kinto API endpoints.
RecordEndpoint "bucket-name" "collection-name" "item-id"Get the full url to an endpoint.
endpointUrl "https://kinto.dev.mozaws.net/v1/" (RecordListEndpoint "default" "test-items")A type for Kinto error details.
A type for all errors that the elm-client may return.
Extract an Error from an Http.Error or return the decoded value.
Extract an Error from an Http.Error or return a Pager for the decoded list.
Send a request to the Kinto server.
type Msg = TodoAdded (Result Kinto.Error Todo)
client
|> create resource data
|> send TodoAdded
A Kinto Client. Constructed using the
clienthelper.