altjsus / elmtable / Airtable

Package for Airtable integration. Just Http wrapper around calls. Watch https://airtable.com/api

Database type


type alias DB =
{ apiKey : String
, database : String
, table : String 
}

Airtable database representation

API wrappers

getRecord : DB -> String -> Http.Expect msg -> Platform.Cmd.Cmd msg

Get record by ID

getRecords : DB -> String -> Basics.Int -> Basics.Int -> Basics.Int -> Http.Expect msg -> Platform.Cmd.Cmd msg

Get records with db, view, maxRecords, pageSize, offset, expect provided. maxRecords = max (pageSize) = 100 (from https://airtable.com/api)

createRecord : DB -> Json.Decode.Value -> Http.Expect msg -> Platform.Cmd.Cmd msg

Creates a new record

changeRecord : DB -> Json.Decode.Value -> Http.Expect msg -> Platform.Cmd.Cmd msg

Changes record. Uses "PATCH" for changing the record only by changing certain fields (fields that are not included won't be updated). From https://airtable.com/api

deleteRecord : DB -> String -> (Result Http.Error DeletionResponse -> msg) -> Platform.Cmd.Cmd msg

Deletes record and expects DeletionResponse or and error. Example deletion response: { "id": "recuK4bC2bEf6d3xQ", "deleted": true }

Deletion reponse type and wrapper


type alias DeletionResponse =
{ id : String
, deleted : Basics.Bool 
}

Responce from deletion request handler

Example response:
{
  "id": "recuK4bC2bEf6d3xQ",
  "deleted": true
}

decodeDeletionResponce : Json.Decode.Decoder DeletionResponse

Deletion responce Json decoder