tmdb - configuration.go
1 package tmdb
2
3 import "net/url"
4
5 // Configuration contains system-wide configuration information.
6 type Configuration struct {
7 Images struct {
8 BaseURL string `json:"base_url"`
9 SecureBaseURL string `json:"secure_base_url"`
10 BackdropSizes []string `json:"backdrop_sizes"`
11 LogoSizes []string `json:"logo_sizes"`
12 PosterSizes []string `json:"poster_sizes"`
13 ProfileSizes []string `json:"profile_sizes"`
14 StillSizes []string `json:"still_sizes"`
15 }
16 ChangeKeys []string `json:"change_keys"`
17 }
18
19 // Configuration retrieves the system-wide configuration information.
20 func (t *TMDB) Configuration() (*Configuration, error) {
21 c := new(Configuration)
22
23 if err := t.get(c, "/3/configuration", url.Values{}); err != nil {
24 return nil, err
25 }
26
27 return c, nil
28 }
29
30 // Countries represents the list of ISO3166-1 country tags.
31 type Countries []struct {
32 Country string `json:"iso_3166_1"`
33 EnglishName string `json:"english_name"`
34 }
35
36 // Countries retrieves the list of ISO3166-1 country tags.
37 func (t *TMDB) Countries() (*Countries, error) {
38 c := new(Countries)
39
40 if err := t.get(c, "/3/configuration/countries", url.Values{}); err != nil {
41 return nil, err
42 }
43
44 return c, nil
45 }
46
47 // Jobs represents the list of jobs/departments.
48 type Jobs []struct {
49 Department string `json:"department"`
50 Jobs []string `json:"jobs"`
51 }
52
53 // Jobs retrieves the list of jobs/departments.
54 func (t *TMDB) Jobs() (*Jobs, error) {
55 j := new(Jobs)
56
57 if err := t.get(j, "/3/configuration/jobs", url.Values{}); err != nil {
58 return nil, err
59 }
60
61 return j, nil
62 }
63
64 // Languages represents the list of languages.
65 type Languages []struct {
66 Language string `json:"iso_639_1"`
67 EnglishName string `json:"english_name"`
68 Name string `json:"name"`
69 }
70
71 // Languages retrieves the list of languages.
72 func (t *TMDB) Languages() (*Languages, error) {
73 l := new(Languages)
74
75 if err := t.get(l, "/3/configurationslanguages", url.Values{}); err != nil {
76 return nil, err
77 }
78
79 return l, nil
80 }
81
82 // PrimaryTranslations represents the list of primary translations.
83 type PrimaryTranslations []string
84
85 // PrimaryTranslations retrieves the list of primary translations.
86 func (t *TMDB) PrimaryTranslations() (*PrimaryTranslations, error) {
87 p := new(PrimaryTranslations)
88
89 if err := t.get(p, "/3/configuration/primary_translations", url.Values{}); err != nil {
90 return nil, err
91 }
92
93 return p, nil
94 }
95
96 // Timezones represents the list of timezones used by TMDB.
97 type Timezones []struct {
98 Country string `json:"iso_3166_1"`
99 Zones []string `json:"zones"`
100 }
101
102 // Timezones retrieves the list of timezones.
103 func (t *TMDB) Timezones() (*Timezones, error) {
104 tz := new(Timezones)
105
106 if err := t.get(tz, "/3/configuration/timezones", url.Values{}); err != nil {
107 return nil, err
108 }
109
110 return tz, nil
111 }
112