Online bookings/appointments/calendars in Go using the SuperSaaS scheduling platform - https://supersaas.com
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
supersaas
tests
.gitignore
LICENSE
README.md

README.md

SuperSaaS Go SDK

Online bookings/appointments/calendars in Golang using the SuperSaaS scheduling platform - https://supersaas.com

The SuperSaaS API provides services that can be used to add online booking and scheduling functionality to an existing website or CRM software.

Prerequisites

  1. Register for a (free) SuperSaaS account, and
  2. get your account name and password.
Dependencies

Go 1.7 or greater.

No external libraries. Only the native endcoding and net packages are used.

Installation

Fetch the package from github.

go get github.com/SuperSaas/supersaas-go-api-client/supersaas

Configuration

The Client can be used either (1) through the singleton helper method GetInstance(), e.g.

client := supersaas.GetInstance()

Or else by (2) creating a new client instance with the NewClient() method, e.g.

client := supersaas.NewClient("accnt", "pwd")

Call Configure to set all client options, e.g.

client.Configure("accnt", "pwd", "", false, true)

If the client isn't configured explicitly, it will use default ENV variables for the account name, password, and user name.

os.Setenv("SSS_API_ACCOUNT_NAME", "your-env-supersaas-account-name")
os.Setenv("SSS_API_PASSWORD", "your-env-supersaas-account-name")
supersaas.GetInstance().AccountName //=> "your-env-supersaas-account-name"
supersaas.GetInstance().Password //=> "your-env-supersaas-account-name"

All configuration options can be individually set on the client.

supersaas.GetInstance().Password = "pwd"
supersaas.GetInstance().Verbose = true
...

API Methods

Details of the data structures, parameters, and values can be found on the developer documentation site:

https://www.supersaas.com/info/dev

API Methods

Details of the data structures, parameters, and values can be found on the developer documentation site:

https://www.supersaas.com/info/dev

List Schedules

Get all account schedules:

schedules, err := supersaas.GetInstance().Schedules.List()

List Resource

Get all services/resources by schedule_id:

resources, err := supersaas.GetInstance().Schedules.Resources(12345)

Note: does not work for capacity type schedules.

Create User

Create a user with user attributes map, external userID, and webhook params:

a := map[string]interface{}
a["full_name"] = "Test"
...
_, err := supersaas.GetInstance().Users.Create(a, "12345fk", true)

Update User

Update a user by user_id with user attributes map, and webhook params:

a := map[string]interface{}
a["full_name"] = "Test"
...
_, err := supersaas.GetInstance().Users.Update(12345, a, true)

Delete User

Delete a single user by user_id:

err := supersaas.GetInstance().Users.Delete(12345)

Get User

Get a single user by user_id:

user, err := supersaas.GetInstance().Users.Get(12345)

List Users

Get all users with optional form and limit/offset pagination params:

users, err := supersaas.GetInstance().Users.List(true, 10, 5)

Create Appointment/Booking

Create an appointment by schedule_id and user_id with appointment attributes and form and webhook params:

a := map[string]interface{}
a["full_name"] = "Test"
...
_, err := supersaas.GetInstance().Appointments.Create(12345, 67890, a, true, false)

Update Appointment/Booking

Update an appointment by schedule_id and appointment_id with appointment attributes params:

a := map[string]interface{}
a["full_name"] = "Test"
...
_, err := supersaas.GetInstance().Appointments.Update(12345, 67890, a, true, true)

Delete Appointment/Booking

Delete a single appointment by schedule_id and appointment_id:

err := supersaas.GetInstance().Appointments.Delete(12345, 67890)

Get Appointment/Booking

Get a single appointment by schedule_id and appointment_id:

appointment, err := supersaas.GetInstance().Appointments.Get(12345, 67890)

List Appointments/Bookings

List appointments by schedule_id, with form and start_time and limit view params:

appointments, err := supersaas.GetInstance().Appointments.List(12345, true, time.Now(), 10)

Get Agenda

Get agenda (upcoming) appointments by schedule_id and user_id, with from_time view params:

appointments, err := supersaas.GetInstance().Appointments.Agenda(12345, 67890, time.Now())

Get Agenda Slots

Get agenda (upcoming) slots by schedule_id and user_id, with from_time view param:

slots, err := supersaas.GetInstance().Appointments.AgendaSlots(12345, 67890, time.Now())

Note: works only for capacity type schedules.

Get Available Appointments/Bookings

Get available appointments by schedule_id, with from time and length_minutes and resource params:

appointments, err := supersaas.GetInstance().Appointments.Available(12345, time.Now(), 60, "", true, 10)

Get Recent Changes

Get recently changed appointments by schedule_id, with from_time view params:

appointments, err := supersaas.GetInstance().Appointments.Changes(12345, time.Now())

Get Recent Changes Slots

Get recently changed appointments by schedule_id, with from time and slot view params:

slots, err := supersaas.GetInstance().Appointments.ChangesSlots(12345, time.Now())

List Template Forms

Get all forms by template superform_id, with from time param:

forms, err := supersaas.GetInstance().Forms.List(12345, time.Now())

Get Form

Get a single form by form_id:

form, err := supersaas.GetInstance().Forms.Get(12345)

Testing

The HTTP requests can be stubbed by configuring the client with the DryRun option, e.g.

supersaas.GetInstance().DryRun = true

Note, stubbed requests always return an empty Hash.

The Client also provides a last_request attribute containing the Net::HTTP object from the last performed request, e.g.

supersaas.GetInstance().LastRequest #=> <Net::HTTP::Get>

The headers, body, path, etc. of the last request can be inspected for assertion in tests, or for troubleshooting failed API requests.

For additional troubleshooting, the client can be configured with the verbose option, which will puts any JSON contents in the request and response, e.g.

supersaas.GetInstance().Verbose = true 

Error Handling

The API Client methods return an error object for HTTP errors and invalid input, e.g.

_, err = supersaas.GetInstance().Users.Create({...})

Additional Information

Contact: support@supersaas.com

Releases

The package follows semantic versioning, i.e. MAJOR.MINOR.PATCH

Versioning is supported through tagged repository URLs, e.g.

github.com/SuperSaas/supersaas-go-api-client/tree/0.10.0/supersaas

License

The SuperSaaS Go API Client is available under the MIT license. See the LICENSE file for more info.