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 if err := t.get(c, "/3/configuration", url.Values{}); err != nil {
23 return nil, err
24 }
25 return c, nil
26 }
27
28 // Countries represents the list of ISO3166-1 country tags
29 type Countries []struct {
30 Country string `json:"iso_3166_1"`
31 EnglishName string `json:"english_name"`
32 }
33
34 // Countries retrieves the list of ISO3166-1 country tags
35 func (t *TMDB) Countries() (*Countries, error) {
36 c := new(Countries)
37 if err := t.get(c, "/3/configuration/countries", url.Values{}); err != nil {
38 return nil, err
39 }
40 return c, nil
41 }
42
43 // Jobs represents the list of jobs/departments
44 type Jobs []struct {
45 Department string `json:"department"`
46 Jobs []string `json:"jobs"`
47 }
48
49 // Jobs retrieves the list of jobs/departments
50 func (t *TMDB) Jobs() (*Jobs, error) {
51 j := new(Jobs)
52 if err := t.get(j, "/3/configuration/jobs", url.Values{}); err != nil {
53 return nil, err
54 }
55 return j, nil
56 }
57
58 // Languages represents the list of languages
59 type Languages []struct {
60 Language string `json:"iso_639_1"`
61 EnglishName string `json:"english_name"`
62 Name string `json:"name"`
63 }
64
65 // Languages retrieves the list of languages
66 func (t *TMDB) Languages() (*Languages, error) {
67 l := new(Languages)
68 if err := t.get(l, "/3/configurationslanguages", url.Values{}); err != nil {
69 return nil, err
70 }
71 return l, nil
72 }
73
74 // PrimaryTranslations represents the list of primary translations
75 type PrimaryTranslations []string
76
77 // PrimaryTranslations retrieves the list of primary translations
78 func (t *TMDB) PrimaryTranslations() (*PrimaryTranslations, error) {
79 p := new(PrimaryTranslations)
80 if err := t.get(p, "/3/configuration/primary_translations", url.Values{}); err != nil {
81 return nil, err
82 }
83 return p, nil
84 }
85
86 // Timezones represents the list of timezones used by TMDB
87 type Timezones []struct {
88 Country string `json:"iso_3166_1"`
89 Zones []string `json:"zones"`
90 }
91
92 // Timezones retrieves the list of timezones
93 func (t *TMDB) Timezones() (*Timezones, error) {
94 tz := new(Timezones)
95 if err := t.get(tz, "/3/configuration/timezones", url.Values{}); err != nil {
96 return nil, err
97 }
98 return tz, nil
99 }