1
0
mirror of https://github.com/badkaktus/gorocket.git synced 2024-12-04 10:34:44 +02:00
gorocket/autotranslate.go

38 lines
826 B
Go
Raw Permalink Normal View History

2020-06-20 17:14:33 +02:00
package gorocket
import (
"fmt"
"net/http"
)
type SupportedLanguageResp struct {
Languages []language `json:"languages"`
Success bool `json:"success"`
}
type language struct {
Language string `json:"language"`
Name string `json:"name"`
}
2024-02-03 21:54:40 +02:00
// GetSupportedLanguage returns a list of supported languages by the autotranslate
2020-06-20 17:14:33 +02:00
func (c *Client) GetSupportedLanguage(query string) (*SupportedLanguageResp, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/%s/autotranslate.getSupportedLanguages", c.baseURL, c.apiVersion), nil)
if err != nil {
return nil, err
}
if query != "" {
q := req.URL.Query()
q.Add("targetLanguage", query)
req.URL.RawQuery = q.Encode()
}
res := SupportedLanguageResp{}
if err := c.sendRequest(req, &res); err != nil {
return nil, err
}
return &res, nil
}