mirror of
https://github.com/retailcrm/mg-bot-api-client-go.git
synced 2024-11-21 20:36:05 +03:00
fix
This commit is contained in:
parent
de3eca3a55
commit
3e9078ee86
12
v1/client.go
12
v1/client.go
@ -925,7 +925,7 @@ func (c WsOption) apply(opts *wsParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WsMeta let you receive url & headers to open web socket connection
|
// WsMeta let you receive url & headers to open web socket connection
|
||||||
func (c *MgClient) WsMeta(events []string, opts ...WsParams) (string, http.Header, error) {
|
func (c *MgClient) WsMeta(events []string, urlParams ...WsParams) (string, http.Header, error) {
|
||||||
var url string
|
var url string
|
||||||
|
|
||||||
if len(events) < 1 {
|
if len(events) < 1 {
|
||||||
@ -935,12 +935,12 @@ func (c *MgClient) WsMeta(events []string, opts ...WsParams) (string, http.Heade
|
|||||||
|
|
||||||
url = fmt.Sprintf("%s%s%s%s", strings.Replace(c.URL, "https", "wss", 1), prefix, "/ws?events=", strings.Join(events[:], ","))
|
url = fmt.Sprintf("%s%s%s%s", strings.Replace(c.URL, "https", "wss", 1), prefix, "/ws?events=", strings.Join(events[:], ","))
|
||||||
|
|
||||||
var wsOpts wsParams
|
var params wsParams
|
||||||
for _, opt := range opts {
|
for _, opt := range urlParams {
|
||||||
opt.apply(&wsOpts)
|
opt.apply(¶ms)
|
||||||
}
|
}
|
||||||
if len(wsOpts.options) > 0 {
|
if len(params.options) > 0 {
|
||||||
url = fmt.Sprintf("%s&options=%s", url, strings.Join(wsOpts.options, ","))
|
url = fmt.Sprintf("%s&options=%s", url, strings.Join(params.options, ","))
|
||||||
}
|
}
|
||||||
|
|
||||||
if url == "" {
|
if url == "" {
|
||||||
|
@ -849,9 +849,9 @@ func TestMgClient_CommandEditDelete(t *testing.T) {
|
|||||||
func TestMgClient_WsMeta_With_Options(t *testing.T) {
|
func TestMgClient_WsMeta_With_Options(t *testing.T) {
|
||||||
c := client()
|
c := client()
|
||||||
events := []string{"user_updated", "user_join_chat"}
|
events := []string{"user_updated", "user_join_chat"}
|
||||||
options := []WsParams{WsOptionIncludeMassCommunication}
|
params := []WsParams{WsOptionIncludeMassCommunication}
|
||||||
|
|
||||||
url, headers, err := c.WsMeta(events, options...)
|
url, headers, err := c.WsMeta(events, params...)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%v", err)
|
t.Errorf("%v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user