Swiftpack.co -  appledeveloperacademypucrs/AirtableKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
appledeveloperacademypucrs/AirtableKit
A SPM to interact with the REST Api from Airtable
.package(url: "https://github.com/appledeveloperacademypucrs/AirtableKit.git", from: "1.0.1")

AirtableKit

Supported platforms: iOS & macOS Language: Swift MIT License

Follow us Follow us

AirtableKit is a 100% Swift framework to wrap the REST API provided by Airtable. The implementation fully leverages Combine to handle asynchronous operations.

Features

  • Standard CRUD operations;
  • Operation batching;
  • API Error forwarding.

Instalation

AirtableKit only supports Swift Package Manager at the moment.

.package(url: "http://github.com/appledeveloperacademypucrs/AirtableKit.git", .upToNextMajor(from: "1.0.0"))

To install AirtableKit using Swift Package Manager look for http://github.com/appledeveloperacademypucrs/AirtableKit.git in Xcode (File/Swift Packages/Add Package Dependency...).

See Adding Package Dependencies to Your App for details.

Usage

To use AirtableKit, create an Airtable with your API Key and Base ID:


let airtable = Airtable(baseID: apiBaseId, apiKey: apiKey)

Listing records

Then, you can list items in any table in your base:


let publisher = airtable.list(tableName: tableName)

// to get only some fields
let publisher = airtable.list(tableName: tableName,
                              fields: ["name", "age", "isCool"])
        

or get an individual record, providing its ID:


let publisher = airtable.get(tableName: tableName, 
                             recordID: "YOUR_AIRTABLE_RECORD_ID")
        

Creating records

You can also create a new record:


let fields: [String: Any] = [
  "name" : "Nicolas",
  "isCool" : true
  "age" : 25,
  "updatedTime" : Date()
]

let record = Record(fields: fields)

let publisher = airtable.create(tableName: tableName, record: record)

or multiple records:


let fields: [[String: Any]] = [
  [
    "name" : "Nicolas",
    "isCool" : true
    "age" : 25,
    "updatedTime" : Date()
  ],
  [
    "name" : "Rafael",
    "isCool" : true
    "age" : 22,
    "updatedTime" : Date()
  ]
]

let records = fields.map { Record(fields: $0) }

let publisher = airtable.create(tableName: tableName, records: records)

Updating records

You can also update an existing record:

let fields: [String: Any] = [
  "name" : "Nicolas",
  "isCool" : true
  "age" : 25,
  "updatedTime" : Date()
]

let record = Record(fields: fields, id: "YOUR_AIRTABLE_RECORD_ID")

let publisher = airtable.update(tableName: tableName, record: record)

or multiple records:


let records = [
  Record(fields: [
    "name" : "Nicolas",
    "isCool" : true
    "age" : 25,
    "updatedTime" : Date()
  ], id: "YOUR_AIRTABLE_RECORD_ID_1"),
  
  Record(fields: [
    "name" : "Rafael",
    "isCool" : true
    "age" : 22,
    "updatedTime" : Date()
  ], id: "YOUR_AIRTABLE_RECORD_ID_2")
]
  
let publisher = airtable.update(tableName: tableName, records: records)

Deleting records

And finally, you can also delete an existing record:


let publisher = airtable.delete(tableName: tableName, recordID: "YOUR_AIRTABLE_RECORD_ID")

or multiple records:


let publisher = airtable.delete(tableName: tableName, recordsIDs: ["YOUR_AIRTABLE_RECORD_ID_1", "YOUR_AIRTABLE_RECORD_ID_2"])

Documentation

Full documentation of the types and methods is available on the wiki pages.

License

MIT License.

GitHub

link
Stars: 33
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

Stable version plus wiki
44 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API