-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_changes.go
271 lines (232 loc) · 12 KB
/
api_changes.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
Streaming Availability API
Streaming Availability API allows getting streaming availability information of movies and series; and querying the list of available shows on streaming services such as Netflix, Disney+, Apple TV, Max and Hulu across 60 countries!
API version: 4.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package streaming
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
)
// ChangesAPIService ChangesAPI service
type ChangesAPIService service
type ApiGetChangesRequest struct {
ctx context.Context
ApiService *ChangesAPIService
country *string
changeType *ChangeType
itemType *ItemType
catalogs *[]string
showType *ShowType
from *int64
to *int64
includeUnknownDates *bool
cursor *string
orderDirection *OrderDirection
outputLanguage *string
}
// [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the target country. See /countries endpoint to get the list of supported countries.
func (r ApiGetChangesRequest) Country(country string) ApiGetChangesRequest {
r.country = &country
return r
}
// Type of changes to query.
func (r ApiGetChangesRequest) ChangeType(changeType ChangeType) ApiGetChangesRequest {
r.changeType = &changeType
return r
}
// Type of items to search in. If item_type is show, you can use show_type parameter to only search for movies or series.
func (r ApiGetChangesRequest) ItemType(itemType ItemType) ApiGetChangesRequest {
r.itemType = &itemType
return r
}
// A comma separated list of up to 32 catalogs to search in. See /countries endpoint to get the supported services in each country and their ids. When multiple catalogs are passed as a comma separated list, any show that is in at least one of the catalogs will be included in the result. If no catalogs are passed, the endpoint will search in all the available catalogs in the country. Syntax of the catalogs supplied in the list can be as the followings: - <sevice_id>: Searches in the entire catalog of that service, including (if applicable) rentable, buyable shows or shows available through addons e.g. netflix, prime, apple - <sevice_id>.<streaming_option_type>: Only returns the shows that are available in that service with the given streaming option type. Valid streaming option types are subscription, free, rent, buy and addon e.g. peacock.free only returns the shows on Peacock that are free to watch, prime.subscription only returns the shows on Prime Video that are available to watch with a Prime subscription. hulu.addon only returns the shows on Hulu that are available via an addon, prime.rent only returns the shows on Prime Video that are rentable. - <sevice_id>.addon.<addon_id>: Only returns the shows that are available in that service with the given addon. Check /countries endpoint to fetch the available addons for a service in each country. Some sample values are: hulu.addon.hbo, prime.addon.hbomaxus.
func (r ApiGetChangesRequest) Catalogs(catalogs []string) ApiGetChangesRequest {
r.catalogs = &catalogs
return r
}
// Type of shows to search in. If not supplied, both movies and series will be included in the search results.
func (r ApiGetChangesRequest) ShowType(showType ShowType) ApiGetChangesRequest {
r.showType = &showType
return r
}
// [Unix Time Stamp](https://www.unixtimestamp.com/) to only query the changes happened/happening after this date (inclusive). For past changes such as new, removed or updated, the timestamp must be between today and 31 days ago. For future changes such as expiring or upcoming, the timestamp must be between today and 31 days from now in the future. If not supplied, the default value for past changes is 31 days ago, and for future changes is today.
func (r ApiGetChangesRequest) From(from int64) ApiGetChangesRequest {
r.from = &from
return r
}
// [Unix Time Stamp](https://www.unixtimestamp.com/) to only query the changes happened/happening before this date (inclusive). For past changes such as new, removed or updated, the timestamp must be between today and 31 days ago. For future changes such as expiring or upcoming, the timestamp must be between today and 31 days from now in the future. If not supplied, the default value for past changes is today, and for future changes is 31 days from now.
func (r ApiGetChangesRequest) To(to int64) ApiGetChangesRequest {
r.to = &to
return r
}
// Whether to include the changes with unknown dates. past changes such as new, removed or updated will always have a timestamp thus this parameter does not affect them. future changes such as expiring or upcoming may not have a timestamp if the exact date is not known (e.g. some services do not explicitly state the exact date of some of the upcoming/expiring shows). If set as true, the changes with unknown dates will be included in the response. If set as false, the changes with unknown dates will be excluded from the response. When ordering, the changes with unknown dates will be treated as if their timestamp is 0. Thus, they will appear first in the ascending order and last in the descending order.
func (r ApiGetChangesRequest) IncludeUnknownDates(includeUnknownDates bool) ApiGetChangesRequest {
r.includeUnknownDates = &includeUnknownDates
return r
}
// Cursor is used for pagination. After each request, the response includes a hasMore boolean field to tell if there are more results that did not fit into the returned list. If it is set as true, to get the rest of the result set, send a new request (with the same parameters for other fields), and set the cursor parameter as the nextCursor value of the response of the previous request. Do not forget to escape the cursor value before putting it into a query as it might contain characters such as ?and &. The first request naturally does not require a cursor parameter.
func (r ApiGetChangesRequest) Cursor(cursor string) ApiGetChangesRequest {
r.cursor = &cursor
return r
}
// Determines whether to order the results in ascending or descending order.
func (r ApiGetChangesRequest) OrderDirection(orderDirection OrderDirection) ApiGetChangesRequest {
r.orderDirection = &orderDirection
return r
}
// [ISO 639-1 code](https://en.wikipedia.org/wiki/ISO_639-1) of the output language. Determines in which language the output will be in.
func (r ApiGetChangesRequest) OutputLanguage(outputLanguage string) ApiGetChangesRequest {
r.outputLanguage = &outputLanguage
return r
}
func (r ApiGetChangesRequest) Execute() (*ChangesResult, *http.Response, error) {
return r.ApiService.GetChangesExecute(r)
}
/*
GetChanges Get Changes
Query the new, removed, updated, expiring or upcoming movies/series/seasons/episodes in a given list of streaming services.
Results are ordered by the date of the changes.
Changes listed per page is 25.
Changes are listed under changes field, and shows affected by these changes are listed under shows field.
Note that upcoming changes are only supported for Apple TV, Disney+, Max, Netflix and Prime Video.
For other services, upcoming changes will return an empty list.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return ApiGetChangesRequest
*/
func (a *ChangesAPIService) GetChanges(ctx context.Context) ApiGetChangesRequest {
return ApiGetChangesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
// @return ChangesResult
func (a *ChangesAPIService) GetChangesExecute(r ApiGetChangesRequest) (*ChangesResult, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *ChangesResult
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "ChangesAPIService.GetChanges")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/changes"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.country == nil {
return localVarReturnValue, nil, reportError("country is required and must be specified")
}
if r.changeType == nil {
return localVarReturnValue, nil, reportError("changeType is required and must be specified")
}
if r.itemType == nil {
return localVarReturnValue, nil, reportError("itemType is required and must be specified")
}
parameterAddToHeaderOrQuery(localVarQueryParams, "country", r.country, "")
if r.catalogs != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "catalogs", r.catalogs, "csv")
}
parameterAddToHeaderOrQuery(localVarQueryParams, "change_type", r.changeType, "")
parameterAddToHeaderOrQuery(localVarQueryParams, "item_type", r.itemType, "")
if r.showType != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "show_type", r.showType, "")
}
if r.from != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "from", r.from, "")
}
if r.to != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "to", r.to, "")
}
if r.includeUnknownDates != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "include_unknown_dates", r.includeUnknownDates, "")
} else {
var defaultValue bool = false
r.includeUnknownDates = &defaultValue
}
if r.cursor != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "")
}
if r.orderDirection != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "order_direction", r.orderDirection, "")
}
if r.outputLanguage != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "output_language", r.outputLanguage, "")
} else {
var defaultValue string = "en"
r.outputLanguage = &defaultValue
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
if r.ctx != nil {
// API Key Authentication
if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
if apiKey, ok := auth["X-Rapid-API-Key"]; ok {
var key string
if apiKey.Prefix != "" {
key = apiKey.Prefix + " " + apiKey.Key
} else {
key = apiKey.Key
}
localVarHeaderParams["X-RapidAPI-Key"] = key
}
}
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ModelError
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}