-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathautotranslate.go
More file actions
37 lines (30 loc) · 826 Bytes
/
autotranslate.go
File metadata and controls
37 lines (30 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
}