threecx

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 4 Imported by: 0

README

go-3cx

package to wrap the api of 3cx®

used packages

getting started

go get github.com/Lukas-Nielsen/go-3cx
import threecx "github.com/Lukas-Nielsen/go-3cx"

usage

conf

you need the FQDN of the instanz, username and password (with permissions for the action)

client, err := new threecx.NewClient(threecx.Host{FQDN string, Port int, Debug bool});

client.SetUser(threecx.User{Username string, Password string, MFA string});
// or
client.SetRest(Rest{ClientID string, ClientSecret string});
// or
client.SetToken(Token{TokenType string, Expires int, AccessToken string, RefreshToken string});
functions
get
err := c.Get(<uri>, <result struct>, <query params as map[string]string>)
delete
err := c.Delete(<uri>, <query params as map[string]string>)
post, put, patch
err := c.<Post|Put|Patch>(<uri>, <payload>, <query params as map[string]string>)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(host Host) (*Client, error)

func (*Client) Delete

func (c *Client) Delete(uri string, query map[string]string) error

func (*Client) Get

func (c *Client) Get(uri string, result *any, query map[string]string) error

func (*Client) GetToken added in v0.0.4

func (c *Client) GetToken() Token

func (*Client) Patch

func (c *Client) Patch(uri string, payload any, query map[string]string) error

func (*Client) Post

func (c *Client) Post(uri string, payload any, query map[string]string) error

func (*Client) Put

func (c *Client) Put(uri string, payload any, query map[string]string) error

func (*Client) SetHost added in v0.0.5

func (c *Client) SetHost(host Host) (*Client, error)

func (*Client) SetRest added in v0.0.5

func (c *Client) SetRest(rest Rest) (*Client, error)

func (*Client) SetToken added in v0.0.5

func (c *Client) SetToken(token Token) (*Client, error)

func (*Client) SetUser added in v0.0.5

func (c *Client) SetUser(user User) (*Client, error)

type Host added in v0.0.5

type Host struct {
	// 3cx FQDN
	FQDN string
	// 3cx port
	Port int
	// debug the requests (see https://github.com/go-resty/resty)
	Debug bool
}

type Rest added in v0.0.5

type Rest struct {
	// clietn id
	ClientID string
	// client secret
	ClientSecret string
}

type Token added in v0.0.4

type Token struct {
	// normaly Bearer
	TokenType string `json:"token_type"`
	// unix timestamp when token expires
	Expires      int64  `json:"expires_in"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type User added in v0.0.5

type User struct {
	// username
	Username string
	// password
	Password string
	// mfa secret
	MFA string
}

Jump to

Keyboard shortcuts

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