mirror of
https://github.com/badkaktus/gorocket.git
synced 2024-12-04 10:34:44 +02:00
38 lines
826 B
Go
38 lines
826 B
Go
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"`
|
|
}
|
|
|
|
// GetSupportedLanguage returns a list of supported languages by the autotranslate
|
|
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
|
|
}
|