2021-07-21 00:15:57 +02:00
|
|
|
package api
|
|
|
|
|
|
|
|
import "encoding/base64"
|
|
|
|
|
|
|
|
// A Client for the API
|
|
|
|
type Client struct {
|
2021-07-28 14:50:33 +02:00
|
|
|
Token string `toml:"token"`
|
|
|
|
URL string `toml:"url"`
|
|
|
|
DefaultVHost string `toml:"default_vhost"`
|
|
|
|
DefaultApp string `toml:"default_app"`
|
2021-07-21 00:15:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// New Client from host and token
|
2021-07-28 14:50:33 +02:00
|
|
|
func New(url, token string) *Client {
|
2021-07-21 00:15:57 +02:00
|
|
|
c := &Client{
|
2021-07-28 14:50:33 +02:00
|
|
|
URL: url,
|
2021-07-21 00:15:57 +02:00
|
|
|
}
|
|
|
|
c.SetToken(token)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetToken by using base64encoding
|
|
|
|
func (c *Client) SetToken(token string) {
|
|
|
|
c.Token = base64.StdEncoding.EncodeToString([]byte(token))
|
|
|
|
}
|