-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlists.go
More file actions
32 lines (27 loc) · 705 Bytes
/
lists.go
File metadata and controls
32 lines (27 loc) · 705 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
package mubi
import (
"encoding/json"
"fmt"
"log"
)
type List struct {
Id int `json:id`
Title string `json:title`
ListFilmsCount int `json:"list_films_count"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
CanonicalUrl string `json:"canonical_url"`
}
func (api *MubiAPI) GetLists(userId int64, page int, perPage int) []List {
url := fmt.Sprintf(
"https://mubi.com/services/api/lists?user_id=%d&sort=updated_at&page=%d&per_page=%d",
userId, page, perPage,
)
body := api.GetResponseBody(url)
lists := make([]List, 0)
jsonErr := json.Unmarshal(body, &lists)
if jsonErr != nil {
log.Fatal(jsonErr)
}
return lists
}