chayns

package module
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2024 License: MIT Imports: 7 Imported by: 0

README

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>")
uintercom
// uintercom
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()

Documentation

Index

Constants

View Source
const (
	BASE_URL = "https://api.chayns.net/"
	VERSION  = "v2.0"
)

Variables

This section is empty.

Functions

func ValidateAccessTokenAlt added in v0.5.0

func ValidateAccessTokenAlt(token string) (bool, error)

Types

type AccessTokenLocal added in v0.6.0

type AccessTokenLocal struct {
	Jti         string    `json:"jti,omitempty"`
	Sub         string    `json:"sub,omitempty"`
	Type        uint      `json:"type,omitempty"`
	Exp         time.Time `json:"exp,omitempty"`
	Iat         time.Time `json:"iat,omitempty"`
	LocationID  uint      `json:"LocationID,omitempty"`
	SiteID      string    `json:"SiteID,omitempty"`
	IsAdmin     bool      `json:"IsAdmin,omitempty"`
	TobitUserID uint      `json:"TobitUserID,omitempty"`
	PersonID    string    `json:"PersonID,omitempty"`
	FirstName   string    `json:"FirstName,omitempty"`
	LastName    string    `json:"LastName,omitempty"`
	Prov        uint      `json:"prov,omitempty"`
}

func InspectAccesstoken added in v0.6.0

func InspectAccesstoken(token string) (AccessTokenLocal, error)

type AccessTokenServer added in v0.6.0

type AccessTokenServer struct {
	LocationID     uint      `json:"locationId"`
	DeveloperID    uint      `json:"developerId"`
	TappID         uint      `json:"tappId"`
	Permissions    []string  `json:"permissions"`
	UserID         uint      `json:"userId"`
	FacebookUserID string    `json:"facevookUserId"`
	PersonID       string    `json:"personId"`
	FirstName      string    `json:"firstName"`
	LastName       string    `json:"lastName"`
	Expires        time.Time `json:"expires"`
	TokenType      struct {
		Type uint   `json:"type"`
		Name string `json:"name"`
	} `json:"tokenType"`
}

type Client added in v0.5.0

type Client struct {
	// contains filtered or unexported fields
}

func NewClient added in v0.5.0

func NewClient(location uint) *Client

func (*Client) Device added in v0.5.0

func (c *Client) Device(deviceId uint) (Device, error)

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Device

func (*Client) Location added in v0.5.0

func (c *Client) Location() (location, error)

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Location

func (*Client) ModifyGroup added in v0.5.0

func (c *Client) ModifyGroup(groupId uint, name string, showName string) (UAC, error)

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Group#modify-uac-group

func (*Client) NewPageAccessToken added in v0.5.0

func (c *Client) NewPageAccessToken(pem ...string) (string, error)

https://github.com/TobitSoftware/chayns-backend/wiki/Authorization

func (*Client) SetLocation added in v0.5.0

func (c *Client) SetLocation(location uint) *Client

func (*Client) SetSecret added in v0.5.0

func (c *Client) SetSecret(secret string) *Client

func (*Client) SetTapp added in v0.5.0

func (c *Client) SetTapp(tapp uint) *Client

func (*Client) UserUAC added in v0.5.0

func (c *Client) UserUAC(userId uint, filter ...map[string]string) ([]UAC, error)

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-User#get-uac-groups

type Device added in v0.4.0

type Device struct {
	SysName     string `json:"sysName"`
	SysVersion  string `json:"sysVersion"`
	LastRequest string `json:"lastRequest"`
	DeviceToken string `json:"deviceToken"`
	UDID        string `json:"udid"`
	DeviceID    uint   `json:"deviceId"`
	AppVersion  uint   `json:"appVersion"`
}

type Intercom

type Intercom struct {
	Message             string  `json:"Message"`
	UacIds              []int   `json:"UacIds,omitempty"`
	UserIds             []int   `json:"UserIds,omitempty"`
	ReceiverLocationIds []int   `json:"ReceiverLocationIds,omitempty"`
	ThreadName          string  `json:"ThreadName,omitempty"`
	UseGroupChat        bool    `json:"UseGroupChat"`
	UserAccessToken     string  `json:"UserAccessToken,omitempty"`
	Images              []image `json:"Images,omitempty"`
	// contains filtered or unexported fields
}

func (*Intercom) AddGroup added in v0.5.0

func (i *Intercom) AddGroup(groupId ...int) *Intercom

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Intercom

func (*Intercom) AddLocation added in v0.5.0

func (i *Intercom) AddLocation(locationId ...int) *Intercom

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Intercom

func (*Intercom) AddUser added in v0.5.0

func (i *Intercom) AddUser(userId ...int) *Intercom

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Intercom

func (*Intercom) SetAccessToken added in v0.5.0

func (i *Intercom) SetAccessToken(token string) *Intercom

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Intercom

func (*Intercom) SetGroupChat added in v0.5.0

func (i *Intercom) SetGroupChat(group bool) *Intercom

https://github.com/TobitSoftware/chayns-backend/wiki/Reference-Intercom

type UAC added in v0.4.0

type UAC struct {
	Name        string `json:"name"`
	ShowName    string `json:"showName"`
	UserGroupID uint   `json:"userGroupId"`
	CountMember uint   `json:"CountMember"`
	TappID      uint   `json:"tappId"`
}

type User added in v0.4.0

type User struct {
	FirstName   string `json:"firstName"`
	LastName    string `json:"lastName"`
	Name        string `json:"name"`
	Picture     string `json:"picture"`
	Gender      string `json:"gender"`
	UserID      uint   `json:"userId"`
	PersonID    string `json:"personId"`
	CountGroups uint   `json:"countGroups"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL