forked from nukosuke/go-zendesk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
locale.go
41 lines (35 loc) · 983 Bytes
/
locale.go
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
38
39
40
41
package zendesk
import (
"encoding/json"
"time"
)
// Locale is zendesk locale JSON payload format
// https://developer.zendesk.com/rest_api/docs/support/locales
type Locale struct {
ID int64 `json:"id"`
URL string `json:"url"`
Locale string `json:"locale"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// LocaleAPI an interface containing all of the local related zendesk methods
type LocaleAPI interface {
GetLocales() ([]Locale, error)
}
// GetLocales lists the translation locales available for the account.
// https://developer.zendesk.com/rest_api/docs/support/locales#list-locales
func (z *Client) GetLocales() ([]Locale, error) {
var data struct {
Locales []Locale `json:"locales"`
}
body, err := z.Get("/locales.json")
if err != nil {
return nil, err
}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, err
}
return data.Locales, nil
}