airtable-api 0.1.0.1 → 0.1.0.2
raw patch · 4 files changed
+31/−10 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- LICENSE +1/−1
- airtable-api.cabal +1/−1
- src/Airtable/Query.hs +23/−7
- src/Airtable/Table.hs +6/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright Author name here (c) 2017+Copyright AlphaSheets, Inc (c) 2017 All rights reserved.
airtable-api.cabal view
@@ -1,5 +1,5 @@ name: airtable-api-version: 0.1.0.1+version: 0.1.0.2 synopsis: Requesting and introspecting Tables within an Airtable project. -- description: homepage: https://github.com/ooblahman/airtable-api
src/Airtable/Query.hs view
@@ -2,7 +2,9 @@ module Airtable.Query ( module Airtable.Table+ -- * Configuration for Airtable requests. , AirtableOptions+ -- * Main API , getTable ) where @@ -17,27 +19,41 @@ import Data.Monoid import qualified Data.ByteString.Char8 as BC --- * Configuration for Airtable requests.-+-- | Options data AirtableOptions = AirtableOptions {+ -- | the API key for your project apiKey :: String+ -- | the app ID for your project (http://api.airtable.com/v0/...) , appId :: String + -- | api version (http://api.airtable.com/v../...)+ , apiVersion :: Int } --- * Constants+-- | Airtable options defaulting to API version 0. Please change the +-- 'apiKey' and 'appId' fields.+defaultOptions :: AirtableOptions +defaultOptions = AirtableOptions {+ apiKey = ""+ , appId = ""+ , apiVersion = 0+ } -- | Base airtable API string. base_url :: String-base_url = "https://api.airtable.com/v0/"---- * Main API+base_url = "https://api.airtable.com/" -- | Retrieve a table from airtable.com given its name. getTable :: (FromJSON a) => AirtableOptions -> TableName -> IO (Table a) getTable opts tname = getTableFromUrl net_otps url where net_otps = defaults & header "Authorization" .~ ["Bearer " <> BC.pack (apiKey opts)] - url = base_url <> appId opts <> "/" <> tname+ url = base_url + <> "v" + <> show (apiVersion opts) + <> "/" + <> appId opts + <> "/" + <> tname getTableFromUrl :: (FromJSON a) => Options -> String -> IO (Table a) getTableFromUrl opts url = do
src/Airtable/Table.hs view
@@ -5,11 +5,16 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Airtable.Table- ( RecordID(..)+ ( + -- * RecordID + RecordID(..) , rec2str+ -- * IsRecord class , IsRecord(..)+ -- * Table , Table(..) , TableName+ -- * Table methods , toList , exists , select