diff --git a/utopia.go b/utopia.go index d926790..519faca 100644 --- a/utopia.go +++ b/utopia.go @@ -116,6 +116,22 @@ func (c *UtopiaClient) queryResultToInterfaceArray(methodName string, params map return nil, errors.New("accaptable result doesn't exists in client response") } +func (c *UtopiaClient) queryResultToStringsArray(methodName string, params map[string]interface{}) ([]string, error) { + if !c.CheckClientConnection() { + return nil, errors.New("client disconected") + } + response, err := c.apiQuery(methodName, params) + if result, ok := response["result"]; ok { + //check type assertion + IResult, isConvertable := result.([]string) + if !isConvertable { + return nil, errors.New("failed to get result array") + } + return IResult, err + } + return nil, errors.New("accaptable result doesn't exists in client response") +} + func (c *UtopiaClient) queryResultToString(methodName string, params map[string]interface{}) (string, error) { if !c.CheckClientConnection() { return "", errors.New("client disconected") @@ -293,3 +309,11 @@ func (c *UtopiaClient) SendChannelPicture(channelID, base64Image, comment, filen } return c.queryResultToString("sendChannelPicture", params) } + +// GetStickerNamesByCollection returns available names from corresponded collection +func (c *UtopiaClient) GetStickerNamesByCollection(collectionName string) ([]string, error) { + params := map[string]interface{}{ + "collection_name": collectionName, + } + return c.queryResultToStringsArray("getStickerNamesByCollection", params) +}