@andev2005/movie-glu-sdk 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -8
- package/dist/index.d.mts +70 -47
- package/dist/index.d.ts +70 -47
- package/dist/index.js +66 -11
- package/dist/index.mjs +65 -11
- package/package.json +1 -1
- package/src/http.ts +6 -0
- package/src/index.ts +69 -11
- package/src/type.ts +72 -45
package/README.md
CHANGED
|
@@ -16,7 +16,6 @@ npm i @andev2005/movie-glu-sdk
|
|
|
16
16
|
|
|
17
17
|
## Yêu cầu
|
|
18
18
|
|
|
19
|
-
- Có `apiKey` của MovieGlu
|
|
20
19
|
- Runtime có `fetch` (Node.js 18+) hoặc truyền `fetch` custom vào client
|
|
21
20
|
|
|
22
21
|
## Sử dụng nhanh
|
|
@@ -27,7 +26,8 @@ npm i @andev2005/movie-glu-sdk
|
|
|
27
26
|
import { createMovieGluClient } from '@andev2005/movie-glu-sdk';
|
|
28
27
|
|
|
29
28
|
const movieGlu = createMovieGluClient({
|
|
30
|
-
apiKey
|
|
29
|
+
// apiKey là optional, mặc định đã được gắn theo cấu hình ANDE/XX
|
|
30
|
+
// apiKey: process.env.MOVIE_GLU_API_KEY,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
async function main() {
|
|
@@ -50,7 +50,6 @@ main().catch(console.error);
|
|
|
50
50
|
import { createMovieGluClient } from '@andev2005/movie-glu-sdk';
|
|
51
51
|
|
|
52
52
|
const client = createMovieGluClient({
|
|
53
|
-
apiKey: 'your-api-key',
|
|
54
53
|
// Tuỳ chọn:
|
|
55
54
|
// baseUrl: 'https://api-gate2.movieglu.com',
|
|
56
55
|
// headers: { 'x-custom-header': 'value' },
|
|
@@ -63,14 +62,27 @@ const client = createMovieGluClient({
|
|
|
63
62
|
### `films`
|
|
64
63
|
|
|
65
64
|
```ts
|
|
66
|
-
// Phim đang chiếu
|
|
65
|
+
// Phim đang chiếu (limit optional, default 10)
|
|
67
66
|
await client.films.nowShowing({ limit: 10 });
|
|
68
67
|
|
|
69
|
-
// Phim sắp chiếu
|
|
68
|
+
// Phim sắp chiếu (limit optional, default 10)
|
|
70
69
|
await client.films.comingSoon({ limit: 10 });
|
|
71
70
|
|
|
72
71
|
// Chi tiết phim
|
|
73
72
|
await client.films.details(12345);
|
|
73
|
+
|
|
74
|
+
// Chi tiết phim + size_category
|
|
75
|
+
await client.films.details({
|
|
76
|
+
filmId: 12345,
|
|
77
|
+
sizeCategory: ['small', 'medium'],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Lịch chiếu theo phim + ngày
|
|
81
|
+
await client.films.showTimes({
|
|
82
|
+
filmId: 12345,
|
|
83
|
+
date: '2026-02-25',
|
|
84
|
+
limit: 10,
|
|
85
|
+
});
|
|
74
86
|
```
|
|
75
87
|
|
|
76
88
|
### `cinemas`
|
|
@@ -106,6 +118,16 @@ await client.cinemas.showTimes({
|
|
|
106
118
|
|
|
107
119
|
SDK sẽ throw `MovieGluError` nếu request thất bại (HTTP status không thành công).
|
|
108
120
|
|
|
121
|
+
Mỗi request tự động gửi các header mặc định:
|
|
122
|
+
|
|
123
|
+
- `client: ANDE`
|
|
124
|
+
- `x-api-key: Bcg2m9aHOI8QSg5h8EDNK8ecPZRTiove3dsbZVuz`
|
|
125
|
+
- `authorization: Basic QU5ERV9YWDpWMEhoUjYzSHZOalM=`
|
|
126
|
+
- `territory: XX`
|
|
127
|
+
- `api-version: v201`
|
|
128
|
+
- `geolocation: -22.0;14.0`
|
|
129
|
+
- `device-datetime: <ISO datetime hiện tại>`
|
|
130
|
+
|
|
109
131
|
```ts
|
|
110
132
|
import { MovieGluError } from '@andev2005/movie-glu-sdk';
|
|
111
133
|
|
|
@@ -127,9 +149,10 @@ try {
|
|
|
127
149
|
|
|
128
150
|
SDK có kiểm tra đầu vào và sẽ throw `TypeError` nếu:
|
|
129
151
|
|
|
130
|
-
- `apiKey`
|
|
152
|
+
- `apiKey` rỗng (nếu bạn truyền vào)
|
|
131
153
|
- `limit` không phải số nguyên dương
|
|
132
|
-
- `id
|
|
154
|
+
- `id/filmId/cinemaId` không phải số nguyên dương
|
|
155
|
+
- `sizeCategory` không thuộc `small|medium|large|xlarge|xxlarge`
|
|
133
156
|
- `date` không đúng định dạng `YYYY-MM-DD`
|
|
134
157
|
|
|
135
158
|
## Utility build URL (tuỳ chọn)
|
|
@@ -148,7 +171,8 @@ Các helper có sẵn:
|
|
|
148
171
|
- `MOVIE_GLU.FILM_NOWSHOWING(limit)`
|
|
149
172
|
- `MOVIE_GLU.CINEMA_NEARBY(limit)`
|
|
150
173
|
- `MOVIE_GLU.FILMS_COMING_SOON(limit)`
|
|
151
|
-
- `MOVIE_GLU.
|
|
174
|
+
- `MOVIE_GLU.FILM_SHOWTIME({ filmId, date, limit? })`
|
|
175
|
+
- `MOVIE_GLU.FILMS_DETAIL(idOrParams)`
|
|
152
176
|
- `MOVIE_GLU.CINEMA_DETAIL(id)`
|
|
153
177
|
- `MOVIE_GLU.CINEMA_SHOWTIME({ cinemaId, date, filmId?, sort? })`
|
|
154
178
|
|
package/dist/index.d.mts
CHANGED
|
@@ -26,7 +26,7 @@ type Client = {
|
|
|
26
26
|
fetch?: FetchLike;
|
|
27
27
|
};
|
|
28
28
|
type MovieGluClientConfig = {
|
|
29
|
-
apiKey
|
|
29
|
+
apiKey?: string;
|
|
30
30
|
baseUrl?: string;
|
|
31
31
|
headers?: Record<string, string>;
|
|
32
32
|
geolocation?: GeolocationInput;
|
|
@@ -38,8 +38,25 @@ type CinemaShowTimesParams = {
|
|
|
38
38
|
filmId?: number;
|
|
39
39
|
sort?: SortType;
|
|
40
40
|
};
|
|
41
|
+
declare const IMAGE_SIZE_CATEGORY: {
|
|
42
|
+
readonly SMALL: "small";
|
|
43
|
+
readonly MEDIUM: "medium";
|
|
44
|
+
readonly LARGE: "large";
|
|
45
|
+
readonly XLARGE: "xlarge";
|
|
46
|
+
readonly XXLARGE: "xxlarge";
|
|
47
|
+
};
|
|
48
|
+
type ImageSizeCategory = (typeof IMAGE_SIZE_CATEGORY)[keyof typeof IMAGE_SIZE_CATEGORY];
|
|
49
|
+
type FilmDetailsParams = {
|
|
50
|
+
filmId: number;
|
|
51
|
+
sizeCategory?: ImageSizeCategory | ImageSizeCategory[];
|
|
52
|
+
};
|
|
53
|
+
type FilmShowTimesParams = {
|
|
54
|
+
date: string;
|
|
55
|
+
filmId: number;
|
|
56
|
+
limit?: number;
|
|
57
|
+
};
|
|
41
58
|
type ListParams = {
|
|
42
|
-
limit
|
|
59
|
+
limit?: number;
|
|
43
60
|
};
|
|
44
61
|
type GeolocationInput = string | UserLocation;
|
|
45
62
|
type CinemasNearbyParams = ListParams;
|
|
@@ -49,7 +66,8 @@ type MovieGluSdk = {
|
|
|
49
66
|
films: {
|
|
50
67
|
nowShowing(params: ListParams): Promise<FilmsNowShowing>;
|
|
51
68
|
comingSoon(params: ListParams): Promise<FilmsComingSoonResponse>;
|
|
52
|
-
details(
|
|
69
|
+
details(idOrParams: number | FilmDetailsParams): Promise<FilmDetailsResponse>;
|
|
70
|
+
showTimes(params: FilmShowTimesParams): Promise<FilmShowTimesResponse>;
|
|
53
71
|
};
|
|
54
72
|
cinemas: {
|
|
55
73
|
nearby(params: CinemasNearbyParams, options?: CinemasNearbyRequestOptions): Promise<CinemasNearbyResponse>;
|
|
@@ -76,21 +94,21 @@ type FilmsComingSoonResponse = {
|
|
|
76
94
|
};
|
|
77
95
|
type FilmDetailsResponse = {
|
|
78
96
|
film_id: number;
|
|
79
|
-
imdb_id
|
|
80
|
-
imdb_title_id
|
|
97
|
+
imdb_id?: number;
|
|
98
|
+
imdb_title_id?: string;
|
|
81
99
|
film_name: string;
|
|
82
|
-
other_titles
|
|
83
|
-
version_type
|
|
100
|
+
other_titles?: OtherTitles;
|
|
101
|
+
version_type?: string;
|
|
84
102
|
images: FilmImages;
|
|
85
103
|
synopsis_long: string;
|
|
86
|
-
distributor_id
|
|
87
|
-
distributor
|
|
104
|
+
distributor_id?: number;
|
|
105
|
+
distributor?: string;
|
|
88
106
|
release_dates: ReleaseDate[];
|
|
89
107
|
age_rating: AgeRating[];
|
|
90
|
-
duration_mins
|
|
91
|
-
review_stars
|
|
92
|
-
review_txt
|
|
93
|
-
trailers:
|
|
108
|
+
duration_mins?: number;
|
|
109
|
+
review_stars?: number;
|
|
110
|
+
review_txt?: string;
|
|
111
|
+
trailers: Trailers | null;
|
|
94
112
|
genres: Genre[];
|
|
95
113
|
cast: Cast[];
|
|
96
114
|
directors: Director[];
|
|
@@ -104,19 +122,19 @@ type CinemaDetailsResponse = {
|
|
|
104
122
|
cinema_id: number;
|
|
105
123
|
cinema_name: string;
|
|
106
124
|
address: string;
|
|
107
|
-
address2
|
|
125
|
+
address2?: string;
|
|
108
126
|
city: string;
|
|
109
|
-
state
|
|
110
|
-
county
|
|
111
|
-
country
|
|
127
|
+
state?: string;
|
|
128
|
+
county?: string;
|
|
129
|
+
country?: string;
|
|
112
130
|
postcode: string;
|
|
113
|
-
phone
|
|
131
|
+
phone?: string;
|
|
114
132
|
lat: number;
|
|
115
133
|
lng: number;
|
|
116
|
-
distance
|
|
117
|
-
ticketing
|
|
118
|
-
directions
|
|
119
|
-
logo_url
|
|
134
|
+
distance?: number;
|
|
135
|
+
ticketing?: number;
|
|
136
|
+
directions?: string;
|
|
137
|
+
logo_url?: string;
|
|
120
138
|
show_dates: ShowDate[];
|
|
121
139
|
status: Status;
|
|
122
140
|
};
|
|
@@ -145,12 +163,12 @@ type Status = {
|
|
|
145
163
|
type OtherTitles = Record<string, string>;
|
|
146
164
|
type ReleaseDate = {
|
|
147
165
|
release_date: string;
|
|
148
|
-
notes
|
|
166
|
+
notes?: string;
|
|
149
167
|
};
|
|
150
168
|
type AgeRating = {
|
|
151
169
|
rating: string;
|
|
152
|
-
age_rating_image
|
|
153
|
-
age_advisory
|
|
170
|
+
age_rating_image?: string;
|
|
171
|
+
age_advisory?: string;
|
|
154
172
|
};
|
|
155
173
|
type FilmImageSize = {
|
|
156
174
|
film_image: string;
|
|
@@ -167,8 +185,8 @@ type Still = {
|
|
|
167
185
|
medium: FilmImageSize;
|
|
168
186
|
};
|
|
169
187
|
type FilmImages = {
|
|
170
|
-
poster
|
|
171
|
-
still
|
|
188
|
+
poster?: KeyNumberObject<Poster>;
|
|
189
|
+
still?: KeyNumberObject<Still>;
|
|
172
190
|
};
|
|
173
191
|
type ShowDate = {
|
|
174
192
|
date: string;
|
|
@@ -177,10 +195,10 @@ type Cinema = {
|
|
|
177
195
|
cinema_id: number;
|
|
178
196
|
cinema_name: string;
|
|
179
197
|
address: string;
|
|
180
|
-
address2
|
|
198
|
+
address2?: string;
|
|
181
199
|
city: string;
|
|
182
|
-
state
|
|
183
|
-
county
|
|
200
|
+
state?: string;
|
|
201
|
+
county?: string;
|
|
184
202
|
country?: string;
|
|
185
203
|
postcode: string;
|
|
186
204
|
phone?: string;
|
|
@@ -193,8 +211,8 @@ type Cinema = {
|
|
|
193
211
|
};
|
|
194
212
|
type Film = {
|
|
195
213
|
film_id: number;
|
|
196
|
-
imdb_id
|
|
197
|
-
imdb_title_id
|
|
214
|
+
imdb_id?: number;
|
|
215
|
+
imdb_title_id?: string;
|
|
198
216
|
film_name: string;
|
|
199
217
|
other_titles?: OtherTitles;
|
|
200
218
|
release_dates: ReleaseDate[];
|
|
@@ -205,10 +223,10 @@ type Film = {
|
|
|
205
223
|
};
|
|
206
224
|
type FilmComingSoon = {
|
|
207
225
|
film_id: number;
|
|
208
|
-
imdb_id
|
|
209
|
-
imdb_title_id
|
|
226
|
+
imdb_id?: number;
|
|
227
|
+
imdb_title_id?: string;
|
|
210
228
|
film_name: string;
|
|
211
|
-
other_titles
|
|
229
|
+
other_titles?: OtherTitles;
|
|
212
230
|
release_dates: ReleaseDate[];
|
|
213
231
|
age_rating: AgeRating[];
|
|
214
232
|
film_trailer: string | null;
|
|
@@ -240,11 +258,15 @@ type AlternateVersion = {
|
|
|
240
258
|
film_name: string;
|
|
241
259
|
version_type: string;
|
|
242
260
|
};
|
|
243
|
-
type
|
|
244
|
-
|
|
261
|
+
type TrailerItem = {
|
|
262
|
+
film_trailer: string;
|
|
245
263
|
trailer_image?: string;
|
|
246
|
-
|
|
247
|
-
|
|
264
|
+
version?: number;
|
|
265
|
+
quality?: string;
|
|
266
|
+
region?: string;
|
|
267
|
+
};
|
|
268
|
+
type Trailers = {
|
|
269
|
+
[quality: string]: TrailerItem[];
|
|
248
270
|
};
|
|
249
271
|
type ShowtimeTime = {
|
|
250
272
|
start_time: string;
|
|
@@ -262,10 +284,10 @@ type CinemaShowTimesCinema = {
|
|
|
262
284
|
};
|
|
263
285
|
type CinemaShowTimesFilm = {
|
|
264
286
|
film_id: number;
|
|
265
|
-
imdb_id
|
|
266
|
-
imdb_title_id
|
|
287
|
+
imdb_id?: number;
|
|
288
|
+
imdb_title_id?: string;
|
|
267
289
|
film_name: string;
|
|
268
|
-
other_titles
|
|
290
|
+
other_titles?: OtherTitles;
|
|
269
291
|
version_type: string;
|
|
270
292
|
age_rating: AgeRating[];
|
|
271
293
|
film_image: string;
|
|
@@ -276,10 +298,10 @@ type CinemaShowTimesFilm = {
|
|
|
276
298
|
};
|
|
277
299
|
type FilmShowTimesFilm = {
|
|
278
300
|
film_id: number;
|
|
279
|
-
imdb_id
|
|
280
|
-
imdb_title_id
|
|
301
|
+
imdb_id?: number;
|
|
302
|
+
imdb_title_id?: string;
|
|
281
303
|
film_name: string;
|
|
282
|
-
other_titles
|
|
304
|
+
other_titles?: OtherTitles;
|
|
283
305
|
version_type: string;
|
|
284
306
|
age_rating: AgeRating[];
|
|
285
307
|
film_image: string;
|
|
@@ -310,10 +332,11 @@ declare const MOVIE_GLU: {
|
|
|
310
332
|
FILM_NOWSHOWING(limit: number): string;
|
|
311
333
|
CINEMA_NEARBY(limit: number): string;
|
|
312
334
|
FILMS_COMING_SOON(limit: number): string;
|
|
313
|
-
|
|
335
|
+
FILM_SHOWTIME(params: FilmShowTimesParams): string;
|
|
336
|
+
FILMS_DETAIL(idOrParams: number | FilmDetailsParams): string;
|
|
314
337
|
CINEMA_DETAIL(id: number): string;
|
|
315
338
|
CINEMA_SHOWTIME(params: CinemaShowTimesParams): string;
|
|
316
339
|
};
|
|
317
340
|
declare function createMovieGluClient(config: MovieGluClientConfig): MovieGluSdk;
|
|
318
341
|
|
|
319
|
-
export { type AgeRating, type AlternateVersion, type Cast, type Cinema, type CinemaDetailsRequestOptions, type CinemaDetailsResponse, type CinemaShowTimesCinema, type CinemaShowTimesFilm, type CinemaShowTimesParams, type CinemaShowTimesResponse, type CinemasNearbyParams, type CinemasNearbyRequestOptions, type CinemasNearbyResponse, type Client, DEFAULT_BASE_URL, type Director, type FetchLike, type Film, type FilmComingSoon, type FilmDetailsResponse, type FilmImageSize, type FilmImages, type FilmShowTimesCinema, type FilmShowTimesFilm, type FilmShowTimesResponse, type FilmsComingSoonResponse, type FilmsNowShowing, type Genre, type GeolocationInput, type KeyNumberObject, type ListParams, MOVIE_GLU, type MovieGluClientConfig, MovieGluError, type MovieGluSdk, type OtherTitles, type Poster, type Producer, type ReleaseDate, type RequestOptions, SORT_TYPE, type ShowDate, type Showings, type ShowtimeGroup, type ShowtimeTime, type SortType, type Status, type Still, type
|
|
342
|
+
export { type AgeRating, type AlternateVersion, type Cast, type Cinema, type CinemaDetailsRequestOptions, type CinemaDetailsResponse, type CinemaShowTimesCinema, type CinemaShowTimesFilm, type CinemaShowTimesParams, type CinemaShowTimesResponse, type CinemasNearbyParams, type CinemasNearbyRequestOptions, type CinemasNearbyResponse, type Client, DEFAULT_BASE_URL, type Director, type FetchLike, type Film, type FilmComingSoon, type FilmDetailsParams, type FilmDetailsResponse, type FilmImageSize, type FilmImages, type FilmShowTimesCinema, type FilmShowTimesFilm, type FilmShowTimesParams, type FilmShowTimesResponse, type FilmsComingSoonResponse, type FilmsNowShowing, type Genre, type GeolocationInput, IMAGE_SIZE_CATEGORY, type ImageSizeCategory, type KeyNumberObject, type ListParams, MOVIE_GLU, type MovieGluClientConfig, MovieGluError, type MovieGluSdk, type OtherTitles, type Poster, type Producer, type ReleaseDate, type RequestOptions, SORT_TYPE, type ShowDate, type Showings, type ShowtimeGroup, type ShowtimeTime, type SortType, type Status, type Still, type TrailerItem, type Trailers, type UserLocation, type Writer, createMovieGluClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ type Client = {
|
|
|
26
26
|
fetch?: FetchLike;
|
|
27
27
|
};
|
|
28
28
|
type MovieGluClientConfig = {
|
|
29
|
-
apiKey
|
|
29
|
+
apiKey?: string;
|
|
30
30
|
baseUrl?: string;
|
|
31
31
|
headers?: Record<string, string>;
|
|
32
32
|
geolocation?: GeolocationInput;
|
|
@@ -38,8 +38,25 @@ type CinemaShowTimesParams = {
|
|
|
38
38
|
filmId?: number;
|
|
39
39
|
sort?: SortType;
|
|
40
40
|
};
|
|
41
|
+
declare const IMAGE_SIZE_CATEGORY: {
|
|
42
|
+
readonly SMALL: "small";
|
|
43
|
+
readonly MEDIUM: "medium";
|
|
44
|
+
readonly LARGE: "large";
|
|
45
|
+
readonly XLARGE: "xlarge";
|
|
46
|
+
readonly XXLARGE: "xxlarge";
|
|
47
|
+
};
|
|
48
|
+
type ImageSizeCategory = (typeof IMAGE_SIZE_CATEGORY)[keyof typeof IMAGE_SIZE_CATEGORY];
|
|
49
|
+
type FilmDetailsParams = {
|
|
50
|
+
filmId: number;
|
|
51
|
+
sizeCategory?: ImageSizeCategory | ImageSizeCategory[];
|
|
52
|
+
};
|
|
53
|
+
type FilmShowTimesParams = {
|
|
54
|
+
date: string;
|
|
55
|
+
filmId: number;
|
|
56
|
+
limit?: number;
|
|
57
|
+
};
|
|
41
58
|
type ListParams = {
|
|
42
|
-
limit
|
|
59
|
+
limit?: number;
|
|
43
60
|
};
|
|
44
61
|
type GeolocationInput = string | UserLocation;
|
|
45
62
|
type CinemasNearbyParams = ListParams;
|
|
@@ -49,7 +66,8 @@ type MovieGluSdk = {
|
|
|
49
66
|
films: {
|
|
50
67
|
nowShowing(params: ListParams): Promise<FilmsNowShowing>;
|
|
51
68
|
comingSoon(params: ListParams): Promise<FilmsComingSoonResponse>;
|
|
52
|
-
details(
|
|
69
|
+
details(idOrParams: number | FilmDetailsParams): Promise<FilmDetailsResponse>;
|
|
70
|
+
showTimes(params: FilmShowTimesParams): Promise<FilmShowTimesResponse>;
|
|
53
71
|
};
|
|
54
72
|
cinemas: {
|
|
55
73
|
nearby(params: CinemasNearbyParams, options?: CinemasNearbyRequestOptions): Promise<CinemasNearbyResponse>;
|
|
@@ -76,21 +94,21 @@ type FilmsComingSoonResponse = {
|
|
|
76
94
|
};
|
|
77
95
|
type FilmDetailsResponse = {
|
|
78
96
|
film_id: number;
|
|
79
|
-
imdb_id
|
|
80
|
-
imdb_title_id
|
|
97
|
+
imdb_id?: number;
|
|
98
|
+
imdb_title_id?: string;
|
|
81
99
|
film_name: string;
|
|
82
|
-
other_titles
|
|
83
|
-
version_type
|
|
100
|
+
other_titles?: OtherTitles;
|
|
101
|
+
version_type?: string;
|
|
84
102
|
images: FilmImages;
|
|
85
103
|
synopsis_long: string;
|
|
86
|
-
distributor_id
|
|
87
|
-
distributor
|
|
104
|
+
distributor_id?: number;
|
|
105
|
+
distributor?: string;
|
|
88
106
|
release_dates: ReleaseDate[];
|
|
89
107
|
age_rating: AgeRating[];
|
|
90
|
-
duration_mins
|
|
91
|
-
review_stars
|
|
92
|
-
review_txt
|
|
93
|
-
trailers:
|
|
108
|
+
duration_mins?: number;
|
|
109
|
+
review_stars?: number;
|
|
110
|
+
review_txt?: string;
|
|
111
|
+
trailers: Trailers | null;
|
|
94
112
|
genres: Genre[];
|
|
95
113
|
cast: Cast[];
|
|
96
114
|
directors: Director[];
|
|
@@ -104,19 +122,19 @@ type CinemaDetailsResponse = {
|
|
|
104
122
|
cinema_id: number;
|
|
105
123
|
cinema_name: string;
|
|
106
124
|
address: string;
|
|
107
|
-
address2
|
|
125
|
+
address2?: string;
|
|
108
126
|
city: string;
|
|
109
|
-
state
|
|
110
|
-
county
|
|
111
|
-
country
|
|
127
|
+
state?: string;
|
|
128
|
+
county?: string;
|
|
129
|
+
country?: string;
|
|
112
130
|
postcode: string;
|
|
113
|
-
phone
|
|
131
|
+
phone?: string;
|
|
114
132
|
lat: number;
|
|
115
133
|
lng: number;
|
|
116
|
-
distance
|
|
117
|
-
ticketing
|
|
118
|
-
directions
|
|
119
|
-
logo_url
|
|
134
|
+
distance?: number;
|
|
135
|
+
ticketing?: number;
|
|
136
|
+
directions?: string;
|
|
137
|
+
logo_url?: string;
|
|
120
138
|
show_dates: ShowDate[];
|
|
121
139
|
status: Status;
|
|
122
140
|
};
|
|
@@ -145,12 +163,12 @@ type Status = {
|
|
|
145
163
|
type OtherTitles = Record<string, string>;
|
|
146
164
|
type ReleaseDate = {
|
|
147
165
|
release_date: string;
|
|
148
|
-
notes
|
|
166
|
+
notes?: string;
|
|
149
167
|
};
|
|
150
168
|
type AgeRating = {
|
|
151
169
|
rating: string;
|
|
152
|
-
age_rating_image
|
|
153
|
-
age_advisory
|
|
170
|
+
age_rating_image?: string;
|
|
171
|
+
age_advisory?: string;
|
|
154
172
|
};
|
|
155
173
|
type FilmImageSize = {
|
|
156
174
|
film_image: string;
|
|
@@ -167,8 +185,8 @@ type Still = {
|
|
|
167
185
|
medium: FilmImageSize;
|
|
168
186
|
};
|
|
169
187
|
type FilmImages = {
|
|
170
|
-
poster
|
|
171
|
-
still
|
|
188
|
+
poster?: KeyNumberObject<Poster>;
|
|
189
|
+
still?: KeyNumberObject<Still>;
|
|
172
190
|
};
|
|
173
191
|
type ShowDate = {
|
|
174
192
|
date: string;
|
|
@@ -177,10 +195,10 @@ type Cinema = {
|
|
|
177
195
|
cinema_id: number;
|
|
178
196
|
cinema_name: string;
|
|
179
197
|
address: string;
|
|
180
|
-
address2
|
|
198
|
+
address2?: string;
|
|
181
199
|
city: string;
|
|
182
|
-
state
|
|
183
|
-
county
|
|
200
|
+
state?: string;
|
|
201
|
+
county?: string;
|
|
184
202
|
country?: string;
|
|
185
203
|
postcode: string;
|
|
186
204
|
phone?: string;
|
|
@@ -193,8 +211,8 @@ type Cinema = {
|
|
|
193
211
|
};
|
|
194
212
|
type Film = {
|
|
195
213
|
film_id: number;
|
|
196
|
-
imdb_id
|
|
197
|
-
imdb_title_id
|
|
214
|
+
imdb_id?: number;
|
|
215
|
+
imdb_title_id?: string;
|
|
198
216
|
film_name: string;
|
|
199
217
|
other_titles?: OtherTitles;
|
|
200
218
|
release_dates: ReleaseDate[];
|
|
@@ -205,10 +223,10 @@ type Film = {
|
|
|
205
223
|
};
|
|
206
224
|
type FilmComingSoon = {
|
|
207
225
|
film_id: number;
|
|
208
|
-
imdb_id
|
|
209
|
-
imdb_title_id
|
|
226
|
+
imdb_id?: number;
|
|
227
|
+
imdb_title_id?: string;
|
|
210
228
|
film_name: string;
|
|
211
|
-
other_titles
|
|
229
|
+
other_titles?: OtherTitles;
|
|
212
230
|
release_dates: ReleaseDate[];
|
|
213
231
|
age_rating: AgeRating[];
|
|
214
232
|
film_trailer: string | null;
|
|
@@ -240,11 +258,15 @@ type AlternateVersion = {
|
|
|
240
258
|
film_name: string;
|
|
241
259
|
version_type: string;
|
|
242
260
|
};
|
|
243
|
-
type
|
|
244
|
-
|
|
261
|
+
type TrailerItem = {
|
|
262
|
+
film_trailer: string;
|
|
245
263
|
trailer_image?: string;
|
|
246
|
-
|
|
247
|
-
|
|
264
|
+
version?: number;
|
|
265
|
+
quality?: string;
|
|
266
|
+
region?: string;
|
|
267
|
+
};
|
|
268
|
+
type Trailers = {
|
|
269
|
+
[quality: string]: TrailerItem[];
|
|
248
270
|
};
|
|
249
271
|
type ShowtimeTime = {
|
|
250
272
|
start_time: string;
|
|
@@ -262,10 +284,10 @@ type CinemaShowTimesCinema = {
|
|
|
262
284
|
};
|
|
263
285
|
type CinemaShowTimesFilm = {
|
|
264
286
|
film_id: number;
|
|
265
|
-
imdb_id
|
|
266
|
-
imdb_title_id
|
|
287
|
+
imdb_id?: number;
|
|
288
|
+
imdb_title_id?: string;
|
|
267
289
|
film_name: string;
|
|
268
|
-
other_titles
|
|
290
|
+
other_titles?: OtherTitles;
|
|
269
291
|
version_type: string;
|
|
270
292
|
age_rating: AgeRating[];
|
|
271
293
|
film_image: string;
|
|
@@ -276,10 +298,10 @@ type CinemaShowTimesFilm = {
|
|
|
276
298
|
};
|
|
277
299
|
type FilmShowTimesFilm = {
|
|
278
300
|
film_id: number;
|
|
279
|
-
imdb_id
|
|
280
|
-
imdb_title_id
|
|
301
|
+
imdb_id?: number;
|
|
302
|
+
imdb_title_id?: string;
|
|
281
303
|
film_name: string;
|
|
282
|
-
other_titles
|
|
304
|
+
other_titles?: OtherTitles;
|
|
283
305
|
version_type: string;
|
|
284
306
|
age_rating: AgeRating[];
|
|
285
307
|
film_image: string;
|
|
@@ -310,10 +332,11 @@ declare const MOVIE_GLU: {
|
|
|
310
332
|
FILM_NOWSHOWING(limit: number): string;
|
|
311
333
|
CINEMA_NEARBY(limit: number): string;
|
|
312
334
|
FILMS_COMING_SOON(limit: number): string;
|
|
313
|
-
|
|
335
|
+
FILM_SHOWTIME(params: FilmShowTimesParams): string;
|
|
336
|
+
FILMS_DETAIL(idOrParams: number | FilmDetailsParams): string;
|
|
314
337
|
CINEMA_DETAIL(id: number): string;
|
|
315
338
|
CINEMA_SHOWTIME(params: CinemaShowTimesParams): string;
|
|
316
339
|
};
|
|
317
340
|
declare function createMovieGluClient(config: MovieGluClientConfig): MovieGluSdk;
|
|
318
341
|
|
|
319
|
-
export { type AgeRating, type AlternateVersion, type Cast, type Cinema, type CinemaDetailsRequestOptions, type CinemaDetailsResponse, type CinemaShowTimesCinema, type CinemaShowTimesFilm, type CinemaShowTimesParams, type CinemaShowTimesResponse, type CinemasNearbyParams, type CinemasNearbyRequestOptions, type CinemasNearbyResponse, type Client, DEFAULT_BASE_URL, type Director, type FetchLike, type Film, type FilmComingSoon, type FilmDetailsResponse, type FilmImageSize, type FilmImages, type FilmShowTimesCinema, type FilmShowTimesFilm, type FilmShowTimesResponse, type FilmsComingSoonResponse, type FilmsNowShowing, type Genre, type GeolocationInput, type KeyNumberObject, type ListParams, MOVIE_GLU, type MovieGluClientConfig, MovieGluError, type MovieGluSdk, type OtherTitles, type Poster, type Producer, type ReleaseDate, type RequestOptions, SORT_TYPE, type ShowDate, type Showings, type ShowtimeGroup, type ShowtimeTime, type SortType, type Status, type Still, type
|
|
342
|
+
export { type AgeRating, type AlternateVersion, type Cast, type Cinema, type CinemaDetailsRequestOptions, type CinemaDetailsResponse, type CinemaShowTimesCinema, type CinemaShowTimesFilm, type CinemaShowTimesParams, type CinemaShowTimesResponse, type CinemasNearbyParams, type CinemasNearbyRequestOptions, type CinemasNearbyResponse, type Client, DEFAULT_BASE_URL, type Director, type FetchLike, type Film, type FilmComingSoon, type FilmDetailsParams, type FilmDetailsResponse, type FilmImageSize, type FilmImages, type FilmShowTimesCinema, type FilmShowTimesFilm, type FilmShowTimesParams, type FilmShowTimesResponse, type FilmsComingSoonResponse, type FilmsNowShowing, type Genre, type GeolocationInput, IMAGE_SIZE_CATEGORY, type ImageSizeCategory, type KeyNumberObject, type ListParams, MOVIE_GLU, type MovieGluClientConfig, MovieGluError, type MovieGluSdk, type OtherTitles, type Poster, type Producer, type ReleaseDate, type RequestOptions, SORT_TYPE, type ShowDate, type Showings, type ShowtimeGroup, type ShowtimeTime, type SortType, type Status, type Still, type TrailerItem, type Trailers, type UserLocation, type Writer, createMovieGluClient };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
23
|
+
IMAGE_SIZE_CATEGORY: () => IMAGE_SIZE_CATEGORY,
|
|
23
24
|
MOVIE_GLU: () => MOVIE_GLU,
|
|
24
25
|
MovieGluError: () => MovieGluError,
|
|
25
26
|
SORT_TYPE: () => SORT_TYPE,
|
|
@@ -96,7 +97,13 @@ async function httpRequest(client, path, options = {}) {
|
|
|
96
97
|
}
|
|
97
98
|
const headers = {
|
|
98
99
|
Accept: "application/json",
|
|
100
|
+
client: "ANDE",
|
|
99
101
|
"x-api-key": client.apiKey,
|
|
102
|
+
authorization: "Basic QU5ERV9YWDpWMEhoUjYzSHZOalM=",
|
|
103
|
+
territory: "XX",
|
|
104
|
+
"api-version": "v201",
|
|
105
|
+
geolocation: "-22.0;14.0",
|
|
106
|
+
"device-datetime": (/* @__PURE__ */ new Date()).toISOString(),
|
|
100
107
|
...client.headers,
|
|
101
108
|
...options.headers
|
|
102
109
|
};
|
|
@@ -124,17 +131,28 @@ var SORT_TYPE = {
|
|
|
124
131
|
ALPHABETICAL: "alphabetical",
|
|
125
132
|
POPULARITY: "popularity"
|
|
126
133
|
};
|
|
134
|
+
var IMAGE_SIZE_CATEGORY = {
|
|
135
|
+
SMALL: "small",
|
|
136
|
+
MEDIUM: "medium",
|
|
137
|
+
LARGE: "large",
|
|
138
|
+
XLARGE: "xlarge",
|
|
139
|
+
XXLARGE: "xxlarge"
|
|
140
|
+
};
|
|
127
141
|
|
|
128
142
|
// src/index.ts
|
|
129
143
|
var DEFAULT_BASE_URL = "https://api-gate2.movieglu.com";
|
|
130
144
|
var ENDPOINT_PATH = {
|
|
131
145
|
FILM_NOWSHOWING: "/filmsNowShowing",
|
|
146
|
+
FILM_SHOWTIME: "/filmShowTimes",
|
|
132
147
|
CINEMA_NEARBY: "/cinemasNearby",
|
|
133
148
|
FILMS_COMING_SOON: "/filmsComingSoon",
|
|
134
149
|
FILMS_DETAIL: "/filmDetails/",
|
|
135
150
|
CINEMA_DETAIL: "/cinemaDetails/",
|
|
136
151
|
CINEMA_SHOWTIME: "/cinemaShowTimes/"
|
|
137
152
|
};
|
|
153
|
+
var DEFAULT_API_KEY = "Bcg2m9aHOI8QSg5h8EDNK8ecPZRTiove3dsbZVuz";
|
|
154
|
+
var DEFAULT_LIST_LIMIT = 10;
|
|
155
|
+
var VALID_IMAGE_SIZE_CATEGORIES = /* @__PURE__ */ new Set(["small", "medium", "large", "xlarge", "xxlarge"]);
|
|
138
156
|
function normalizeBaseUrl(baseUrl) {
|
|
139
157
|
return baseUrl.replace(/\/+$/, "");
|
|
140
158
|
}
|
|
@@ -177,8 +195,9 @@ function formatGeolocationHeader(geolocation) {
|
|
|
177
195
|
return `${geolocation.lat};${geolocation.lng}`;
|
|
178
196
|
}
|
|
179
197
|
function toListQuery(params) {
|
|
180
|
-
|
|
181
|
-
|
|
198
|
+
const limit = params.limit ?? DEFAULT_LIST_LIMIT;
|
|
199
|
+
assertPositiveInteger(limit, "limit");
|
|
200
|
+
return { n: limit };
|
|
182
201
|
}
|
|
183
202
|
function toCinemaShowTimesQuery(params) {
|
|
184
203
|
assertPositiveInteger(params.cinemaId, "cinemaId");
|
|
@@ -193,6 +212,34 @@ function toCinemaShowTimesQuery(params) {
|
|
|
193
212
|
film_id: params.filmId
|
|
194
213
|
};
|
|
195
214
|
}
|
|
215
|
+
function toFilmShowTimesQuery(params) {
|
|
216
|
+
assertDateString(params.date, "date");
|
|
217
|
+
assertPositiveInteger(params.filmId, "filmId");
|
|
218
|
+
if (params.limit !== void 0) {
|
|
219
|
+
assertPositiveInteger(params.limit, "limit");
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
date: params.date,
|
|
223
|
+
film_id: params.filmId,
|
|
224
|
+
n: params.limit
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function normalizeFilmDetailsInput(input) {
|
|
228
|
+
const details = typeof input === "number" ? { filmId: input } : input;
|
|
229
|
+
assertPositiveInteger(details.filmId, "filmId");
|
|
230
|
+
if (!details.sizeCategory) {
|
|
231
|
+
return { film_id: details.filmId };
|
|
232
|
+
}
|
|
233
|
+
const sizeCategoryRaw = Array.isArray(details.sizeCategory) ? details.sizeCategory.join(",") : details.sizeCategory;
|
|
234
|
+
const normalizedValues = sizeCategoryRaw.split(",").map((value) => value.trim().toLowerCase()).filter(Boolean);
|
|
235
|
+
if (normalizedValues.length === 0 || normalizedValues.some((value) => !VALID_IMAGE_SIZE_CATEGORIES.has(value))) {
|
|
236
|
+
throw new TypeError("sizeCategory must be one or more of: small, medium, large, xlarge, xxlarge");
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
film_id: details.filmId,
|
|
240
|
+
size_category: normalizedValues.join(",")
|
|
241
|
+
};
|
|
242
|
+
}
|
|
196
243
|
var MOVIE_GLU = {
|
|
197
244
|
FILM_NOWSHOWING(limit) {
|
|
198
245
|
assertPositiveInteger(limit, "limit");
|
|
@@ -206,9 +253,11 @@ var MOVIE_GLU = {
|
|
|
206
253
|
assertPositiveInteger(limit, "limit");
|
|
207
254
|
return buildUrl(ENDPOINT_PATH.FILMS_COMING_SOON, { n: limit });
|
|
208
255
|
},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
256
|
+
FILM_SHOWTIME(params) {
|
|
257
|
+
return buildUrl(ENDPOINT_PATH.FILM_SHOWTIME, toFilmShowTimesQuery(params));
|
|
258
|
+
},
|
|
259
|
+
FILMS_DETAIL(idOrParams) {
|
|
260
|
+
return buildUrl(ENDPOINT_PATH.FILMS_DETAIL, normalizeFilmDetailsInput(idOrParams));
|
|
212
261
|
},
|
|
213
262
|
CINEMA_DETAIL(id) {
|
|
214
263
|
assertPositiveInteger(id, "id");
|
|
@@ -219,12 +268,13 @@ var MOVIE_GLU = {
|
|
|
219
268
|
}
|
|
220
269
|
};
|
|
221
270
|
function createMovieGluClient(config) {
|
|
222
|
-
|
|
223
|
-
|
|
271
|
+
const resolvedApiKey = (config.apiKey ?? DEFAULT_API_KEY).trim();
|
|
272
|
+
if (!resolvedApiKey) {
|
|
273
|
+
throw new TypeError("apiKey must not be empty");
|
|
224
274
|
}
|
|
225
275
|
const client = {
|
|
226
276
|
baseUrl: normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL),
|
|
227
|
-
apiKey:
|
|
277
|
+
apiKey: resolvedApiKey,
|
|
228
278
|
headers: config.headers,
|
|
229
279
|
geolocation: config.geolocation,
|
|
230
280
|
fetch: config.fetch
|
|
@@ -241,10 +291,14 @@ function createMovieGluClient(config) {
|
|
|
241
291
|
queryParams: toListQuery(params)
|
|
242
292
|
});
|
|
243
293
|
},
|
|
244
|
-
details(
|
|
245
|
-
assertPositiveInteger(id, "id");
|
|
294
|
+
details(idOrParams) {
|
|
246
295
|
return httpRequest(client, ENDPOINT_PATH.FILMS_DETAIL, {
|
|
247
|
-
queryParams:
|
|
296
|
+
queryParams: normalizeFilmDetailsInput(idOrParams)
|
|
297
|
+
});
|
|
298
|
+
},
|
|
299
|
+
showTimes(params) {
|
|
300
|
+
return httpRequest(client, ENDPOINT_PATH.FILM_SHOWTIME, {
|
|
301
|
+
queryParams: toFilmShowTimesQuery(params)
|
|
248
302
|
});
|
|
249
303
|
}
|
|
250
304
|
},
|
|
@@ -284,6 +338,7 @@ function createMovieGluClient(config) {
|
|
|
284
338
|
// Annotate the CommonJS export names for ESM import in node:
|
|
285
339
|
0 && (module.exports = {
|
|
286
340
|
DEFAULT_BASE_URL,
|
|
341
|
+
IMAGE_SIZE_CATEGORY,
|
|
287
342
|
MOVIE_GLU,
|
|
288
343
|
MovieGluError,
|
|
289
344
|
SORT_TYPE,
|
package/dist/index.mjs
CHANGED
|
@@ -67,7 +67,13 @@ async function httpRequest(client, path, options = {}) {
|
|
|
67
67
|
}
|
|
68
68
|
const headers = {
|
|
69
69
|
Accept: "application/json",
|
|
70
|
+
client: "ANDE",
|
|
70
71
|
"x-api-key": client.apiKey,
|
|
72
|
+
authorization: "Basic QU5ERV9YWDpWMEhoUjYzSHZOalM=",
|
|
73
|
+
territory: "XX",
|
|
74
|
+
"api-version": "v201",
|
|
75
|
+
geolocation: "-22.0;14.0",
|
|
76
|
+
"device-datetime": (/* @__PURE__ */ new Date()).toISOString(),
|
|
71
77
|
...client.headers,
|
|
72
78
|
...options.headers
|
|
73
79
|
};
|
|
@@ -95,17 +101,28 @@ var SORT_TYPE = {
|
|
|
95
101
|
ALPHABETICAL: "alphabetical",
|
|
96
102
|
POPULARITY: "popularity"
|
|
97
103
|
};
|
|
104
|
+
var IMAGE_SIZE_CATEGORY = {
|
|
105
|
+
SMALL: "small",
|
|
106
|
+
MEDIUM: "medium",
|
|
107
|
+
LARGE: "large",
|
|
108
|
+
XLARGE: "xlarge",
|
|
109
|
+
XXLARGE: "xxlarge"
|
|
110
|
+
};
|
|
98
111
|
|
|
99
112
|
// src/index.ts
|
|
100
113
|
var DEFAULT_BASE_URL = "https://api-gate2.movieglu.com";
|
|
101
114
|
var ENDPOINT_PATH = {
|
|
102
115
|
FILM_NOWSHOWING: "/filmsNowShowing",
|
|
116
|
+
FILM_SHOWTIME: "/filmShowTimes",
|
|
103
117
|
CINEMA_NEARBY: "/cinemasNearby",
|
|
104
118
|
FILMS_COMING_SOON: "/filmsComingSoon",
|
|
105
119
|
FILMS_DETAIL: "/filmDetails/",
|
|
106
120
|
CINEMA_DETAIL: "/cinemaDetails/",
|
|
107
121
|
CINEMA_SHOWTIME: "/cinemaShowTimes/"
|
|
108
122
|
};
|
|
123
|
+
var DEFAULT_API_KEY = "Bcg2m9aHOI8QSg5h8EDNK8ecPZRTiove3dsbZVuz";
|
|
124
|
+
var DEFAULT_LIST_LIMIT = 10;
|
|
125
|
+
var VALID_IMAGE_SIZE_CATEGORIES = /* @__PURE__ */ new Set(["small", "medium", "large", "xlarge", "xxlarge"]);
|
|
109
126
|
function normalizeBaseUrl(baseUrl) {
|
|
110
127
|
return baseUrl.replace(/\/+$/, "");
|
|
111
128
|
}
|
|
@@ -148,8 +165,9 @@ function formatGeolocationHeader(geolocation) {
|
|
|
148
165
|
return `${geolocation.lat};${geolocation.lng}`;
|
|
149
166
|
}
|
|
150
167
|
function toListQuery(params) {
|
|
151
|
-
|
|
152
|
-
|
|
168
|
+
const limit = params.limit ?? DEFAULT_LIST_LIMIT;
|
|
169
|
+
assertPositiveInteger(limit, "limit");
|
|
170
|
+
return { n: limit };
|
|
153
171
|
}
|
|
154
172
|
function toCinemaShowTimesQuery(params) {
|
|
155
173
|
assertPositiveInteger(params.cinemaId, "cinemaId");
|
|
@@ -164,6 +182,34 @@ function toCinemaShowTimesQuery(params) {
|
|
|
164
182
|
film_id: params.filmId
|
|
165
183
|
};
|
|
166
184
|
}
|
|
185
|
+
function toFilmShowTimesQuery(params) {
|
|
186
|
+
assertDateString(params.date, "date");
|
|
187
|
+
assertPositiveInteger(params.filmId, "filmId");
|
|
188
|
+
if (params.limit !== void 0) {
|
|
189
|
+
assertPositiveInteger(params.limit, "limit");
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
date: params.date,
|
|
193
|
+
film_id: params.filmId,
|
|
194
|
+
n: params.limit
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function normalizeFilmDetailsInput(input) {
|
|
198
|
+
const details = typeof input === "number" ? { filmId: input } : input;
|
|
199
|
+
assertPositiveInteger(details.filmId, "filmId");
|
|
200
|
+
if (!details.sizeCategory) {
|
|
201
|
+
return { film_id: details.filmId };
|
|
202
|
+
}
|
|
203
|
+
const sizeCategoryRaw = Array.isArray(details.sizeCategory) ? details.sizeCategory.join(",") : details.sizeCategory;
|
|
204
|
+
const normalizedValues = sizeCategoryRaw.split(",").map((value) => value.trim().toLowerCase()).filter(Boolean);
|
|
205
|
+
if (normalizedValues.length === 0 || normalizedValues.some((value) => !VALID_IMAGE_SIZE_CATEGORIES.has(value))) {
|
|
206
|
+
throw new TypeError("sizeCategory must be one or more of: small, medium, large, xlarge, xxlarge");
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
film_id: details.filmId,
|
|
210
|
+
size_category: normalizedValues.join(",")
|
|
211
|
+
};
|
|
212
|
+
}
|
|
167
213
|
var MOVIE_GLU = {
|
|
168
214
|
FILM_NOWSHOWING(limit) {
|
|
169
215
|
assertPositiveInteger(limit, "limit");
|
|
@@ -177,9 +223,11 @@ var MOVIE_GLU = {
|
|
|
177
223
|
assertPositiveInteger(limit, "limit");
|
|
178
224
|
return buildUrl(ENDPOINT_PATH.FILMS_COMING_SOON, { n: limit });
|
|
179
225
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
226
|
+
FILM_SHOWTIME(params) {
|
|
227
|
+
return buildUrl(ENDPOINT_PATH.FILM_SHOWTIME, toFilmShowTimesQuery(params));
|
|
228
|
+
},
|
|
229
|
+
FILMS_DETAIL(idOrParams) {
|
|
230
|
+
return buildUrl(ENDPOINT_PATH.FILMS_DETAIL, normalizeFilmDetailsInput(idOrParams));
|
|
183
231
|
},
|
|
184
232
|
CINEMA_DETAIL(id) {
|
|
185
233
|
assertPositiveInteger(id, "id");
|
|
@@ -190,12 +238,13 @@ var MOVIE_GLU = {
|
|
|
190
238
|
}
|
|
191
239
|
};
|
|
192
240
|
function createMovieGluClient(config) {
|
|
193
|
-
|
|
194
|
-
|
|
241
|
+
const resolvedApiKey = (config.apiKey ?? DEFAULT_API_KEY).trim();
|
|
242
|
+
if (!resolvedApiKey) {
|
|
243
|
+
throw new TypeError("apiKey must not be empty");
|
|
195
244
|
}
|
|
196
245
|
const client = {
|
|
197
246
|
baseUrl: normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL),
|
|
198
|
-
apiKey:
|
|
247
|
+
apiKey: resolvedApiKey,
|
|
199
248
|
headers: config.headers,
|
|
200
249
|
geolocation: config.geolocation,
|
|
201
250
|
fetch: config.fetch
|
|
@@ -212,10 +261,14 @@ function createMovieGluClient(config) {
|
|
|
212
261
|
queryParams: toListQuery(params)
|
|
213
262
|
});
|
|
214
263
|
},
|
|
215
|
-
details(
|
|
216
|
-
assertPositiveInteger(id, "id");
|
|
264
|
+
details(idOrParams) {
|
|
217
265
|
return httpRequest(client, ENDPOINT_PATH.FILMS_DETAIL, {
|
|
218
|
-
queryParams:
|
|
266
|
+
queryParams: normalizeFilmDetailsInput(idOrParams)
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
showTimes(params) {
|
|
270
|
+
return httpRequest(client, ENDPOINT_PATH.FILM_SHOWTIME, {
|
|
271
|
+
queryParams: toFilmShowTimesQuery(params)
|
|
219
272
|
});
|
|
220
273
|
}
|
|
221
274
|
},
|
|
@@ -254,6 +307,7 @@ function createMovieGluClient(config) {
|
|
|
254
307
|
}
|
|
255
308
|
export {
|
|
256
309
|
DEFAULT_BASE_URL,
|
|
310
|
+
IMAGE_SIZE_CATEGORY,
|
|
257
311
|
MOVIE_GLU,
|
|
258
312
|
MovieGluError,
|
|
259
313
|
SORT_TYPE,
|
package/package.json
CHANGED
package/src/http.ts
CHANGED
|
@@ -82,7 +82,13 @@ export async function httpRequest<T>(
|
|
|
82
82
|
|
|
83
83
|
const headers: Record<string, string> = {
|
|
84
84
|
Accept: 'application/json',
|
|
85
|
+
client: 'ANDE',
|
|
85
86
|
'x-api-key': client.apiKey,
|
|
87
|
+
authorization: 'Basic QU5ERV9YWDpWMEhoUjYzSHZOalM=',
|
|
88
|
+
territory: 'XX',
|
|
89
|
+
'api-version': 'v201',
|
|
90
|
+
geolocation: '-22.0;14.0',
|
|
91
|
+
'device-datetime': new Date().toISOString(),
|
|
86
92
|
...client.headers,
|
|
87
93
|
...options.headers,
|
|
88
94
|
};
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,10 @@ import type {
|
|
|
7
7
|
CinemasNearbyParams,
|
|
8
8
|
CinemasNearbyRequestOptions,
|
|
9
9
|
CinemasNearbyResponse,
|
|
10
|
+
FilmDetailsParams,
|
|
10
11
|
FilmDetailsResponse,
|
|
12
|
+
FilmShowTimesParams,
|
|
13
|
+
FilmShowTimesResponse,
|
|
11
14
|
FilmsComingSoonResponse,
|
|
12
15
|
FilmsNowShowing,
|
|
13
16
|
GeolocationInput,
|
|
@@ -22,6 +25,7 @@ export const DEFAULT_BASE_URL = 'https://api-gate2.movieglu.com';
|
|
|
22
25
|
|
|
23
26
|
const ENDPOINT_PATH = {
|
|
24
27
|
FILM_NOWSHOWING: '/filmsNowShowing',
|
|
28
|
+
FILM_SHOWTIME: '/filmShowTimes',
|
|
25
29
|
CINEMA_NEARBY: '/cinemasNearby',
|
|
26
30
|
FILMS_COMING_SOON: '/filmsComingSoon',
|
|
27
31
|
FILMS_DETAIL: '/filmDetails/',
|
|
@@ -29,6 +33,10 @@ const ENDPOINT_PATH = {
|
|
|
29
33
|
CINEMA_SHOWTIME: '/cinemaShowTimes/',
|
|
30
34
|
} as const;
|
|
31
35
|
|
|
36
|
+
const DEFAULT_API_KEY = 'Bcg2m9aHOI8QSg5h8EDNK8ecPZRTiove3dsbZVuz';
|
|
37
|
+
const DEFAULT_LIST_LIMIT = 10;
|
|
38
|
+
const VALID_IMAGE_SIZE_CATEGORIES = new Set(['small', 'medium', 'large', 'xlarge', 'xxlarge']);
|
|
39
|
+
|
|
32
40
|
type QueryValue = string | number | boolean | null | undefined;
|
|
33
41
|
|
|
34
42
|
function normalizeBaseUrl(baseUrl: string): string {
|
|
@@ -86,8 +94,9 @@ function formatGeolocationHeader(geolocation: GeolocationInput): string {
|
|
|
86
94
|
}
|
|
87
95
|
|
|
88
96
|
function toListQuery(params: ListParams): { n: number } {
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
const limit = params.limit ?? DEFAULT_LIST_LIMIT;
|
|
98
|
+
assertPositiveInteger(limit, 'limit');
|
|
99
|
+
return { n: limit };
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
function toCinemaShowTimesQuery(params: CinemaShowTimesParams): {
|
|
@@ -111,6 +120,48 @@ function toCinemaShowTimesQuery(params: CinemaShowTimesParams): {
|
|
|
111
120
|
};
|
|
112
121
|
}
|
|
113
122
|
|
|
123
|
+
function toFilmShowTimesQuery(params: FilmShowTimesParams): { date: string; film_id: number; n?: number } {
|
|
124
|
+
assertDateString(params.date, 'date');
|
|
125
|
+
assertPositiveInteger(params.filmId, 'filmId');
|
|
126
|
+
|
|
127
|
+
if (params.limit !== undefined) {
|
|
128
|
+
assertPositiveInteger(params.limit, 'limit');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
date: params.date,
|
|
133
|
+
film_id: params.filmId,
|
|
134
|
+
n: params.limit,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function normalizeFilmDetailsInput(input: number | FilmDetailsParams): { film_id: number; size_category?: string } {
|
|
139
|
+
const details = typeof input === 'number' ? { filmId: input } : input;
|
|
140
|
+
assertPositiveInteger(details.filmId, 'filmId');
|
|
141
|
+
|
|
142
|
+
if (!details.sizeCategory) {
|
|
143
|
+
return { film_id: details.filmId };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const sizeCategoryRaw = Array.isArray(details.sizeCategory)
|
|
147
|
+
? details.sizeCategory.join(',')
|
|
148
|
+
: details.sizeCategory;
|
|
149
|
+
|
|
150
|
+
const normalizedValues = sizeCategoryRaw
|
|
151
|
+
.split(',')
|
|
152
|
+
.map((value) => value.trim().toLowerCase())
|
|
153
|
+
.filter(Boolean);
|
|
154
|
+
|
|
155
|
+
if (normalizedValues.length === 0 || normalizedValues.some((value) => !VALID_IMAGE_SIZE_CATEGORIES.has(value))) {
|
|
156
|
+
throw new TypeError('sizeCategory must be one or more of: small, medium, large, xlarge, xxlarge');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
film_id: details.filmId,
|
|
161
|
+
size_category: normalizedValues.join(','),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
114
165
|
export const MOVIE_GLU = {
|
|
115
166
|
FILM_NOWSHOWING(limit: number): string {
|
|
116
167
|
assertPositiveInteger(limit, 'limit');
|
|
@@ -124,9 +175,11 @@ export const MOVIE_GLU = {
|
|
|
124
175
|
assertPositiveInteger(limit, 'limit');
|
|
125
176
|
return buildUrl(ENDPOINT_PATH.FILMS_COMING_SOON, { n: limit });
|
|
126
177
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
178
|
+
FILM_SHOWTIME(params: FilmShowTimesParams): string {
|
|
179
|
+
return buildUrl(ENDPOINT_PATH.FILM_SHOWTIME, toFilmShowTimesQuery(params));
|
|
180
|
+
},
|
|
181
|
+
FILMS_DETAIL(idOrParams: number | FilmDetailsParams): string {
|
|
182
|
+
return buildUrl(ENDPOINT_PATH.FILMS_DETAIL, normalizeFilmDetailsInput(idOrParams));
|
|
130
183
|
},
|
|
131
184
|
CINEMA_DETAIL(id: number): string {
|
|
132
185
|
assertPositiveInteger(id, 'id');
|
|
@@ -138,13 +191,14 @@ export const MOVIE_GLU = {
|
|
|
138
191
|
};
|
|
139
192
|
|
|
140
193
|
export function createMovieGluClient(config: MovieGluClientConfig): MovieGluSdk {
|
|
141
|
-
|
|
142
|
-
|
|
194
|
+
const resolvedApiKey = (config.apiKey ?? DEFAULT_API_KEY).trim();
|
|
195
|
+
if (!resolvedApiKey) {
|
|
196
|
+
throw new TypeError('apiKey must not be empty');
|
|
143
197
|
}
|
|
144
198
|
|
|
145
199
|
const client = {
|
|
146
200
|
baseUrl: normalizeBaseUrl(config.baseUrl ?? DEFAULT_BASE_URL),
|
|
147
|
-
apiKey:
|
|
201
|
+
apiKey: resolvedApiKey,
|
|
148
202
|
headers: config.headers,
|
|
149
203
|
geolocation: config.geolocation,
|
|
150
204
|
fetch: config.fetch,
|
|
@@ -162,10 +216,14 @@ export function createMovieGluClient(config: MovieGluClientConfig): MovieGluSdk
|
|
|
162
216
|
queryParams: toListQuery(params),
|
|
163
217
|
});
|
|
164
218
|
},
|
|
165
|
-
details(
|
|
166
|
-
assertPositiveInteger(id, 'id');
|
|
219
|
+
details(idOrParams: number | FilmDetailsParams): Promise<FilmDetailsResponse> {
|
|
167
220
|
return httpRequest<FilmDetailsResponse>(client, ENDPOINT_PATH.FILMS_DETAIL, {
|
|
168
|
-
queryParams:
|
|
221
|
+
queryParams: normalizeFilmDetailsInput(idOrParams),
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
showTimes(params: FilmShowTimesParams): Promise<FilmShowTimesResponse> {
|
|
225
|
+
return httpRequest<FilmShowTimesResponse>(client, ENDPOINT_PATH.FILM_SHOWTIME, {
|
|
226
|
+
queryParams: toFilmShowTimesQuery(params),
|
|
169
227
|
});
|
|
170
228
|
},
|
|
171
229
|
},
|
package/src/type.ts
CHANGED
|
@@ -32,7 +32,7 @@ export type Client = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export type MovieGluClientConfig = {
|
|
35
|
-
apiKey
|
|
35
|
+
apiKey?: string;
|
|
36
36
|
baseUrl?: string;
|
|
37
37
|
headers?: Record<string, string>;
|
|
38
38
|
geolocation?: GeolocationInput;
|
|
@@ -46,8 +46,29 @@ export type CinemaShowTimesParams = {
|
|
|
46
46
|
sort?: SortType;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
export const IMAGE_SIZE_CATEGORY = {
|
|
50
|
+
SMALL: 'small',
|
|
51
|
+
MEDIUM: 'medium',
|
|
52
|
+
LARGE: 'large',
|
|
53
|
+
XLARGE: 'xlarge',
|
|
54
|
+
XXLARGE: 'xxlarge',
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
57
|
+
export type ImageSizeCategory = (typeof IMAGE_SIZE_CATEGORY)[keyof typeof IMAGE_SIZE_CATEGORY];
|
|
58
|
+
|
|
59
|
+
export type FilmDetailsParams = {
|
|
60
|
+
filmId: number;
|
|
61
|
+
sizeCategory?: ImageSizeCategory | ImageSizeCategory[];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type FilmShowTimesParams = {
|
|
65
|
+
date: string;
|
|
66
|
+
filmId: number;
|
|
67
|
+
limit?: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
49
70
|
export type ListParams = {
|
|
50
|
-
limit
|
|
71
|
+
limit?: number;
|
|
51
72
|
};
|
|
52
73
|
|
|
53
74
|
export type GeolocationInput = string | UserLocation;
|
|
@@ -61,7 +82,8 @@ export type MovieGluSdk = {
|
|
|
61
82
|
films: {
|
|
62
83
|
nowShowing(params: ListParams): Promise<FilmsNowShowing>;
|
|
63
84
|
comingSoon(params: ListParams): Promise<FilmsComingSoonResponse>;
|
|
64
|
-
details(
|
|
85
|
+
details(idOrParams: number | FilmDetailsParams): Promise<FilmDetailsResponse>;
|
|
86
|
+
showTimes(params: FilmShowTimesParams): Promise<FilmShowTimesResponse>;
|
|
65
87
|
};
|
|
66
88
|
cinemas: {
|
|
67
89
|
nearby(params: CinemasNearbyParams, options?: CinemasNearbyRequestOptions): Promise<CinemasNearbyResponse>;
|
|
@@ -93,21 +115,21 @@ export type FilmsComingSoonResponse = {
|
|
|
93
115
|
|
|
94
116
|
export type FilmDetailsResponse = {
|
|
95
117
|
film_id: number;
|
|
96
|
-
imdb_id
|
|
97
|
-
imdb_title_id
|
|
118
|
+
imdb_id?: number;
|
|
119
|
+
imdb_title_id?: string;
|
|
98
120
|
film_name: string;
|
|
99
|
-
other_titles
|
|
100
|
-
version_type
|
|
121
|
+
other_titles?: OtherTitles;
|
|
122
|
+
version_type?: string;
|
|
101
123
|
images: FilmImages;
|
|
102
124
|
synopsis_long: string;
|
|
103
|
-
distributor_id
|
|
104
|
-
distributor
|
|
125
|
+
distributor_id?: number;
|
|
126
|
+
distributor?: string;
|
|
105
127
|
release_dates: ReleaseDate[];
|
|
106
128
|
age_rating: AgeRating[];
|
|
107
|
-
duration_mins
|
|
108
|
-
review_stars
|
|
109
|
-
review_txt
|
|
110
|
-
trailers:
|
|
129
|
+
duration_mins?: number;
|
|
130
|
+
review_stars?: number;
|
|
131
|
+
review_txt?: string;
|
|
132
|
+
trailers: Trailers | null;
|
|
111
133
|
genres: Genre[];
|
|
112
134
|
cast: Cast[];
|
|
113
135
|
directors: Director[];
|
|
@@ -122,19 +144,19 @@ export type CinemaDetailsResponse = {
|
|
|
122
144
|
cinema_id: number;
|
|
123
145
|
cinema_name: string;
|
|
124
146
|
address: string;
|
|
125
|
-
address2
|
|
147
|
+
address2?: string;
|
|
126
148
|
city: string;
|
|
127
|
-
state
|
|
128
|
-
county
|
|
129
|
-
country
|
|
149
|
+
state?: string;
|
|
150
|
+
county?: string;
|
|
151
|
+
country?: string;
|
|
130
152
|
postcode: string;
|
|
131
|
-
phone
|
|
153
|
+
phone?: string;
|
|
132
154
|
lat: number;
|
|
133
155
|
lng: number;
|
|
134
|
-
distance
|
|
135
|
-
ticketing
|
|
136
|
-
directions
|
|
137
|
-
logo_url
|
|
156
|
+
distance?: number;
|
|
157
|
+
ticketing?: number;
|
|
158
|
+
directions?: string;
|
|
159
|
+
logo_url?: string;
|
|
138
160
|
show_dates: ShowDate[];
|
|
139
161
|
status: Status;
|
|
140
162
|
};
|
|
@@ -169,13 +191,13 @@ export type OtherTitles = Record<string, string>;
|
|
|
169
191
|
|
|
170
192
|
export type ReleaseDate = {
|
|
171
193
|
release_date: string;
|
|
172
|
-
notes
|
|
194
|
+
notes?: string;
|
|
173
195
|
};
|
|
174
196
|
|
|
175
197
|
export type AgeRating = {
|
|
176
198
|
rating: string;
|
|
177
|
-
age_rating_image
|
|
178
|
-
age_advisory
|
|
199
|
+
age_rating_image?: string;
|
|
200
|
+
age_advisory?: string;
|
|
179
201
|
};
|
|
180
202
|
|
|
181
203
|
export type FilmImageSize = {
|
|
@@ -196,8 +218,8 @@ export type Still = {
|
|
|
196
218
|
};
|
|
197
219
|
|
|
198
220
|
export type FilmImages = {
|
|
199
|
-
poster
|
|
200
|
-
still
|
|
221
|
+
poster?: KeyNumberObject<Poster>;
|
|
222
|
+
still?: KeyNumberObject<Still>;
|
|
201
223
|
};
|
|
202
224
|
|
|
203
225
|
export type ShowDate = {
|
|
@@ -208,10 +230,10 @@ export type Cinema = {
|
|
|
208
230
|
cinema_id: number;
|
|
209
231
|
cinema_name: string;
|
|
210
232
|
address: string;
|
|
211
|
-
address2
|
|
233
|
+
address2?: string;
|
|
212
234
|
city: string;
|
|
213
|
-
state
|
|
214
|
-
county
|
|
235
|
+
state?: string;
|
|
236
|
+
county?: string;
|
|
215
237
|
country?: string;
|
|
216
238
|
postcode: string;
|
|
217
239
|
phone?: string;
|
|
@@ -225,8 +247,8 @@ export type Cinema = {
|
|
|
225
247
|
|
|
226
248
|
export type Film = {
|
|
227
249
|
film_id: number;
|
|
228
|
-
imdb_id
|
|
229
|
-
imdb_title_id
|
|
250
|
+
imdb_id?: number;
|
|
251
|
+
imdb_title_id?: string;
|
|
230
252
|
film_name: string;
|
|
231
253
|
other_titles?: OtherTitles;
|
|
232
254
|
release_dates: ReleaseDate[];
|
|
@@ -238,10 +260,10 @@ export type Film = {
|
|
|
238
260
|
|
|
239
261
|
export type FilmComingSoon = {
|
|
240
262
|
film_id: number;
|
|
241
|
-
imdb_id
|
|
242
|
-
imdb_title_id
|
|
263
|
+
imdb_id?: number;
|
|
264
|
+
imdb_title_id?: string;
|
|
243
265
|
film_name: string;
|
|
244
|
-
other_titles
|
|
266
|
+
other_titles?: OtherTitles;
|
|
245
267
|
release_dates: ReleaseDate[];
|
|
246
268
|
age_rating: AgeRating[];
|
|
247
269
|
film_trailer: string | null;
|
|
@@ -280,11 +302,16 @@ export type AlternateVersion = {
|
|
|
280
302
|
version_type: string;
|
|
281
303
|
};
|
|
282
304
|
|
|
283
|
-
export type
|
|
284
|
-
|
|
305
|
+
export type TrailerItem = {
|
|
306
|
+
film_trailer: string;
|
|
285
307
|
trailer_image?: string;
|
|
286
|
-
|
|
287
|
-
|
|
308
|
+
version?: number;
|
|
309
|
+
quality?: string;
|
|
310
|
+
region?: string;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export type Trailers = {
|
|
314
|
+
[quality: string]: TrailerItem[];
|
|
288
315
|
};
|
|
289
316
|
|
|
290
317
|
export type ShowtimeTime = {
|
|
@@ -307,10 +334,10 @@ export type CinemaShowTimesCinema = {
|
|
|
307
334
|
|
|
308
335
|
export type CinemaShowTimesFilm = {
|
|
309
336
|
film_id: number;
|
|
310
|
-
imdb_id
|
|
311
|
-
imdb_title_id
|
|
337
|
+
imdb_id?: number;
|
|
338
|
+
imdb_title_id?: string;
|
|
312
339
|
film_name: string;
|
|
313
|
-
other_titles
|
|
340
|
+
other_titles?: OtherTitles;
|
|
314
341
|
version_type: string;
|
|
315
342
|
age_rating: AgeRating[];
|
|
316
343
|
film_image: string;
|
|
@@ -322,10 +349,10 @@ export type CinemaShowTimesFilm = {
|
|
|
322
349
|
|
|
323
350
|
export type FilmShowTimesFilm = {
|
|
324
351
|
film_id: number;
|
|
325
|
-
imdb_id
|
|
326
|
-
imdb_title_id
|
|
352
|
+
imdb_id?: number;
|
|
353
|
+
imdb_title_id?: string;
|
|
327
354
|
film_name: string;
|
|
328
|
-
other_titles
|
|
355
|
+
other_titles?: OtherTitles;
|
|
329
356
|
version_type: string;
|
|
330
357
|
age_rating: AgeRating[];
|
|
331
358
|
film_image: string;
|