Skip to content

Commit 8fe6d61

Browse files
authored
Fix certifications (#86)
1 parent 2070f69 commit 8fe6d61

File tree

1 file changed

+9
-142
lines changed

1 file changed

+9
-142
lines changed

certifications.go

Lines changed: 9 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -9,90 +9,17 @@ type Certification struct {
99
Order int `json:"order"`
1010
}
1111

12-
// CertificationMovie type is a struct for movie certifications JSON response.
13-
type CertificationMovie struct {
14-
Certifications struct {
15-
AU []struct {
16-
*Certification
17-
} `json:"AU"`
18-
BG []struct {
19-
*Certification
20-
} `json:"BG"`
21-
BR []struct {
22-
*Certification
23-
} `json:"BR"`
24-
CA []struct {
25-
*Certification
26-
} `json:"CA"`
27-
CA_QC []struct {
28-
*Certification
29-
} `json:"CA-QC"`
30-
DE []struct {
31-
*Certification
32-
} `json:"DE"`
33-
DK []struct {
34-
*Certification
35-
} `json:"DK"`
36-
ES []struct {
37-
*Certification
38-
} `json:"ES"`
39-
FI []struct {
40-
*Certification
41-
} `json:"FI"`
42-
FR []struct {
43-
*Certification
44-
} `json:"FR"`
45-
GB []struct {
46-
*Certification
47-
} `json:"GB"`
48-
HU []struct {
49-
*Certification
50-
} `json:"HU"`
51-
IN []struct {
52-
*Certification
53-
} `json:"IN"`
54-
IT []struct {
55-
*Certification
56-
} `json:"IT"`
57-
LT []struct {
58-
*Certification
59-
} `json:"LT"`
60-
MY []struct {
61-
*Certification
62-
} `json:"MY"`
63-
NL []struct {
64-
*Certification
65-
} `json:"NL"`
66-
NO []struct {
67-
*Certification
68-
} `json:"NO"`
69-
NZ []struct {
70-
*Certification
71-
} `json:"NZ"`
72-
PH []struct {
73-
*Certification
74-
} `json:"PH"`
75-
PT []struct {
76-
*Certification
77-
} `json:"PT"`
78-
RU []struct {
79-
*Certification
80-
} `json:"RU"`
81-
SE []struct {
82-
*Certification
83-
} `json:"SE"`
84-
US []struct {
85-
*Certification
86-
} `json:"US"`
87-
} `json:"certifications"`
12+
// Certifications type is a struct for movie and tv certifications JSON response.
13+
type Certifications struct {
14+
Certifications map[string][]Certification `json:"certifications"`
8815
}
8916

9017
// GetCertificationMovie get an up to date list of the
9118
// officially supported movie certifications on TMDb.
9219
//
93-
// https://developers.themoviedb.org/3/certifications/get-movie-certifications
20+
// https://developer.themoviedb.org/reference/certification-movie-list
9421
func (c *Client) GetCertificationMovie() (
95-
*CertificationMovie,
22+
*Certifications,
9623
error,
9724
) {
9825
tmdbURL := fmt.Sprintf(
@@ -101,79 +28,19 @@ func (c *Client) GetCertificationMovie() (
10128
movieURL,
10229
c.apiKey,
10330
)
104-
certificationMovie := CertificationMovie{}
31+
certificationMovie := Certifications{}
10532
if err := c.get(tmdbURL, &certificationMovie); err != nil {
10633
return nil, err
10734
}
10835
return &certificationMovie, nil
10936
}
11037

111-
// CertificationTV type is a struct for tv certifications JSON response.
112-
type CertificationTV struct {
113-
Certifications struct {
114-
AU []struct {
115-
*Certification
116-
} `json:"AU"`
117-
BR []struct {
118-
*Certification
119-
} `json:"BR"`
120-
CA []struct {
121-
*Certification
122-
} `json:"CA"`
123-
CA_QC []struct {
124-
*Certification
125-
} `json:"CA-QC"`
126-
DE []struct {
127-
*Certification
128-
} `json:"DE"`
129-
ES []struct {
130-
*Certification
131-
} `json:"ES"`
132-
FR []struct {
133-
*Certification
134-
} `json:"FR"`
135-
GB []struct {
136-
*Certification
137-
} `json:"GB"`
138-
HU []struct {
139-
*Certification
140-
} `json:"HU"`
141-
KR []struct {
142-
*Certification
143-
} `json:"KR"`
144-
LT []struct {
145-
*Certification
146-
} `json:"LT"`
147-
NL []struct {
148-
*Certification
149-
} `json:"NL"`
150-
PH []struct {
151-
*Certification
152-
} `json:"PH"`
153-
PT []struct {
154-
*Certification
155-
} `json:"PT"`
156-
RU []struct {
157-
*Certification
158-
} `json:"RU"`
159-
SK []struct {
160-
*Certification
161-
} `json:"SK"`
162-
TH []struct {
163-
*Certification
164-
} `json:"TH"`
165-
US []struct {
166-
*Certification
167-
} `json:"US"`
168-
} `json:"certifications"`
169-
}
170-
17138
// GetCertificationTV get an up to date list of the
17239
// officially supported TV show certifications on TMDb.
17340
//
174-
// https://developers.themoviedb.org/3/certifications/get-tv-certifications
41+
// https://developer.themoviedb.org/reference/certifications-tv-list
17542
func (c *Client) GetCertificationTV() (
176-
*CertificationTV,
43+
*Certifications,
17744
error,
17845
) {
17946
tmdbURL := fmt.Sprintf(
@@ -182,7 +49,7 @@ func (c *Client) GetCertificationTV() (
18249
tvURL,
18350
c.apiKey,
18451
)
185-
certificationTV := CertificationTV{}
52+
certificationTV := Certifications{}
18653
if err := c.get(tmdbURL, &certificationTV); err != nil {
18754
return nil, err
18855
}

0 commit comments

Comments
 (0)