mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 12:26:06 +03:00
commit
109ad20fc0
12
v1/client.go
12
v1/client.go
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-querystring/query"
|
||||
@ -659,9 +660,9 @@ func (c *MgClient) CommandDelete(request string) (map[string]interface{}, int, e
|
||||
return resp, status, err
|
||||
}
|
||||
|
||||
// Ws let you receive url & headers to open web socket connection
|
||||
func (c *MgClient) Ws() (string, http.Header, error) {
|
||||
url := fmt.Sprintf("%s%s%s", c.URL, prefix, "/ws")
|
||||
// WsMeta let you receive url & headers to open web socket connection
|
||||
func (c *MgClient) WsMeta(events []string) (string, http.Header, error) {
|
||||
url := fmt.Sprintf("%s%s%s%s", c.URL, prefix, "/ws?events=", strings.Join(events[:], ","))
|
||||
headers := http.Header{}
|
||||
headers.Add("x-bot-token", c.Token)
|
||||
|
||||
@ -670,6 +671,11 @@ func (c *MgClient) Ws() (string, http.Header, error) {
|
||||
return url, headers, err
|
||||
}
|
||||
|
||||
if len(events) < 1 {
|
||||
err := errors.New("events list must not be empty")
|
||||
return url, headers, err
|
||||
}
|
||||
|
||||
return url, headers, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user