Skip to content

Unofficial SDK for the Adalo API in GoLang

License

Notifications You must be signed in to change notification settings

be-foo/adalo-sdk-go

Repository files navigation

Adalo SDK Go

This is an unofficial SDK for the use with Go. It provides a thin wrapper for the endpoints provided by The Adalo API.

GoDoc Build Status Coverage Status Go Report Card License

Installation

Make sure your project is using Go Modules (it will have a go.mod file in its root if it already is):

go mod init

Then, reference stripe-go in a Go program with import:

import "github.com/be-foo/adalo-sdk-go"

Run any of the normal go commands (build/install/test). The Go toolchain will resolve and fetch the stripe-go module automatically.

Alternatively, you can also explicitly go get the package into a project:

go get -u github.com/be-foo/adalo-sdk-go

Using the SDK

Before using any of the SDK functions, make sure you have configured the credentials for your Adalo app. The keys will be used globally as parameters to your requests.

import "github.com/be-foo/adalo-sdk-go"

func main() {
    adalo.ApiKey = "<YOUR-API-KEY>"
    adalo.AppKey = "<YOUR-APP-KEY>"
}

Collection API

The API enables you to run basic CRUD operations on your Adalo collections. See below for some examples on how to use it with this SDK.

First initialize your collection

personCollection := adalo.NewCollection("<ID-OF-PERSON-COLLECTION>")

Get All Items

var persons []interface{} // result will be bind to this variable

err := personCollection.All(&persons)

if err != nil {
    panic(err)
}

Get Item by ID

var person interface{} // result will be bind to this variable

err := personCollection.Get(1, &person)

if err != nil {
    panic(err)
}

Insert Item

var person interface{} // will bind created item to this variable

err := personCollection.Insert(struct{
    Name    string
    Age     int
}{
    Name:   "John",
    Age:    21,
}, &person)

if err != nil {
    panic(err)
}

Update Item

var person interface{} // will bind updated item to this variable

err := personCollection.Update(1, struct{
    Name    string
    Age     int
}{
    Name:   "John",
    Age:    21,
}, &person)

if err != nil {
    panic(err)
}

Additional Notes

Because each collection has different fields, the SDK must work with the interface{} type. For type safety and a over-all better developer experience, we suggest you implement a wrapper/ superset of the Collection type, where you declare types according to your specific collections and then create wrapper functions for the functions of Collection, using your type.

You can see a full example of how this can look like in example.

About

Unofficial SDK for the Adalo API in GoLang

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published