-
Notifications
You must be signed in to change notification settings - Fork 0
/
lists.go
230 lines (214 loc) · 5.69 KB
/
lists.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
package wraptmdb
import (
"strconv"
"github.com/kwangsing3/http_methods_golang"
)
/*
* The MIT License (MIT)
*
* Copyright (c) kwangsing3
*
* https://github.com/wrapTMDB/wraptmdb_go
*
*/
type list struct{}
var Lists list
/********************
* 1.GET /list/{list_id}
* @description Get the details of a list.
* @param { int|string} list_id
* @param { int|string} language(optional)
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/get-list-details
********************/
func (l *list) GetDetails(list_id string, language string) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL + c_module.Route.LIST + list_id + `?api_key=` + token
if language != "" {
targetURL += `&language=` + language
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.GET(targetURL, header)
return data
}
/********************
* 2.GET /list/{list_id}/item_status
* @description You can use this method to check if a movie has already been added to the list.
* @param { int|string} list_id
* @param { int|string} movie_id
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/check-item-status
********************/
func (l *list) GetCheckItemStatus(
list_id string,
movie_id string,
) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL +
c_module.Route.LIST +
list_id + `/` +
"item_status" +
`?api_key=` + token
if movie_id != "" {
targetURL += `&movie_id=` + movie_id
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.GET(targetURL, header)
return data
}
/********************
* 3.POST /list
* @description Create a list.
* @param {any} query
* @param { int|string} session_id
* @example query{
* "name" "This is my awesome test list.",
* "description" "Just an awesome list dawg.",
* "language" "en"
* }
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/create-list
********************/
func (l *list) PostCreateList(query []byte, session_id string) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL + c_module.Route.LIST + `?api_key=` + token
if session_id != "" {
targetURL += `&session_id=` + session_id
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.POST(targetURL, header, query)
return data
}
/********************
* 4.POST /list/{list_id}/add_item
* @description Add a movie to a list.
* @param {any} query
* @param { int|string} list_id
* @param { int|string} session_id
* @example query{
* "media_id" 18
* }
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/add-movie
********************/
func (l *list) PostAddMovie(
query []byte,
list_id string,
session_id string,
) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL +
c_module.Route.LIST +
list_id + `/add_item` +
`?api_key=` + token
if session_id != "" {
targetURL += `&session_id=` + session_id
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.POST(targetURL, header, query)
return data
}
/********************
* 5.POST /list/{list_id}/remove_item
* @description Remove a movie from a list.
* @param {any} query
* @param { int|string} list_id
* @param { int|string} session_id
* @example query{
* "media_id" 12
* }
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/remove-movie
********************/
func (l *list) PostRemoveMovie(
query []byte,
list_id string,
session_id string,
) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL +
c_module.Route.LIST +
list_id + `/remove_item` +
`?api_key=` + token
if session_id != "" {
targetURL += `&session_id=` + session_id
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.POST(targetURL, header, query)
return data
}
/********************
* 6.POST /list/{list_id}/clear
* @description Clear all of the items from a list.
* @param { int|string} list_id
* @param { int|string} session_id
* @param {boolean} confirm
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/clear-list
********************/
func (l *list) PostClearList(
list_id string,
session_id string,
confirm bool,
) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL + c_module.Route.LIST + list_id + `/clear` + `?api_key=` + token
if session_id != "" {
targetURL += `&session_id=` + session_id
}
targetURL += `&confirm=` + strconv.FormatBool(confirm)
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.POST(targetURL, header, nil)
return data
}
/********************
* 7.DELETE /list/{list_id}
* @description Delete a list.
* @param { int|string} list_id
* @param { int|string} session_id
* @returns JSON
* @doc https://developers.themoviedb.org/3/lists/delete-list
********************/
func (l *list) DeleteDeleteList(
list_id string,
session_id string,
) interface{} {
var token = c_module.GetToken()
var header = c_module.GetHeader()
var targetURL string = baseURL + c_module.Route.LIST + list_id + `?api_key=` + token
if session_id != "" {
targetURL += `&session_id=` + session_id
}
if token == "UnitTest_api_key" {
return targetURL
}
var data, _ = http_methods_golang.DELETE(targetURL, header, nil)
return data
}
/*
1.GET Get Details
2.GET Check Item Status
3.POST Create List
4.POST Add Movie
5.POST Remove Movie
6.POST Clear List
7.DELETE Delete List
*/