Skip to content

Lukas-Nielsen/go-chayns

Repository files navigation

go-chayns

package to wrap the api of chanys®, you can find the documentation of the api at the repository of TobitSoftware GitHub

used packages

getting started

go get github.com/Lukas-Nielsen/go-chayns
import chayns "github.com/Lukas-Nielsen/go-chayns"

usage

conf

for all actions you need a locationId and for the most actions you need a tappId and a secret

// conf
c := chayns.NewConf(<locationId>)

c.
    SetLocation(<locationId>).
    SetTapp(<tappId>).
    SetSecret("<secret>")

filter

Reference at GitHub-Wiki @ TobitSoftware

some functions accept a filter parameter this has to be of type map[string]string, eg:

filter := map[string]string{
    "gender": "female",
}

functions

accesstoken

// generate page accesstoken
// string, error
result, err := c.NewPageAccessToken(..."<permission>")

// validate an accesstoken
// accessToken (information about the token), error
result, err := c.ValidateAccessToken("<your token>", ...<groupId>)

user

// get all users
// []user, error
result, err := c.Users(...filter)

// get user by id
// user, error
result, err := c.User(<userId>)

// get groups of user by id
// []uac, error
result, err := c.UserUAC(<userId>, ...filter)

// get devices of user by id
// []device, error
result, err := c.UserDevices(<userId>, ...filter)

// get device by id of user by id
// []device, error
result, err := c.UserDevice(<userId>, <deviceId>)

group

// get all groups
// []uac, error
result, err := c.Groups(...filter)

// get group by id
// uac, error
result, err := c.Group(<goupId>)

// create a new group
// uac, error
result, err := c.NewGroup("<name>", "<showName>")

// modify a group
// uac, error
result, err := c.ModifyGroup(<groupId>, "<name>", "<showName>")

// delete a group
// bool, error
result, err := c.DeleteGroup(<groupId>)

group member

// get all members of group by id
// []user, error
result, err := c.Members(<groupId>, ...filter)

// get member by id of group by id
// user, error
result, err := c.Member(<goupId>, <userId>)

// add user to group
// user, error
result, err := c.AddUserUac(<groupId>, <userId>)

// remove user from group
// bool, error
result, err := c.RemoveUserUac(<groupId>, <userId>)

device

// get device by id
// device, error
result, err := c.Device(<deviceId>)

location

// get information about the location
// location, error
result, err := c.Location()

push

// send push notification to group
// bool, error
result, err := c.PushGroup(<groupId>, "<message>")

// send push notification to user
// bool, error
result, err := c.PushUser(<userId>, "<message>")

intercom

// intercom
i := c.NewIntercom("<message>")

i.
    AddUser(...<userId>).
    AddGroup(...<groupId>).
    AddLocation(...<locationId>).
    AddImage(..."<url>").
    SetAccessToken("<token>").
    SetThreadName("<name>").
    SetGroupChat(boolean)

// send the message
// bool, error
result, err := i.Send()

About

wrapper for the chayns backend api

Topics

Resources

License

Stars

Watchers

Forks

Languages