hermanschaaf / sqwiggle

Go client library for Sqwiggle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sqwiggle Go Client

Build Status Coverage Status Go Report Card

A Golang client library for the Sqwiggle API.

Supports

  • Attachments
  • Conversations
  • Info
  • Invites
  • Messages
  • Organizations
  • Streams
  • Users

Installation

go get github.com/hermanschaaf/sqwiggle

Example usage

The following example lists the 50 most recent messages across all streams, and prints them out.

package main

import (
	"fmt"
	"github.com/hermanschaaf/sqwiggle"
)

// The following code instantiates a client, then calls the
// ListMessages method to return a slice of Messages. If no error occurred, it
// iterates through the messages and prints them out one by one.
func main() {
	client := sqwiggle.NewClient("YOUR-API-KEY")

	page, limit := 0, 50
	msgs, err := client.ListMessages(page, limit)
	if err != nil {
		panic(err)
	}

	for _, m := range msgs {
		fmt.Printf("%s: %s\n", m.Author.Name, m.Text)
	}
}

When instantiating a new client, it is also possible to use your own HTTPClient:

client := Client{
	APIKey:     "YOUR-API-KEY",
	RootURL:    "https://api.sqwiggle.com/", // customize the URL
	HTTPClient: &http.Client{}, // your own custom http.Client
}

This is useful in testing environments, for example (and is used in the tests for this package).

Full Docs

https://godoc.org/github.com/hermanschaaf/sqwiggle

There are plenty more usage examples in the docs and also in sqwiggle_test.go.


MIT License

About

Go client library for Sqwiggle

License:MIT License


Languages

Language:Go 100.0%