UNPKG

3.22 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 };
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var rest_client_1 = require("@nativecode/rest-client");
17var MovieResource = /** @class */ (function (_super) {
18 __extends(MovieResource, _super);
19 function MovieResource(url, apikey, logger) {
20 var _this = _super.call(this, url, logger) || this;
21 _this.setHeader('X-Api-Key', apikey);
22 return _this;
23 }
24 MovieResource.prototype.add = function (movie) {
25 return this._post('movie', movie);
26 };
27 MovieResource.prototype.id = function (id) {
28 return this._get('movie/{:id}', [
29 {
30 key: 'id',
31 type: rest_client_1.ResourceRouteParamType.RouteParameter,
32 value: id,
33 },
34 ]);
35 };
36 MovieResource.prototype.imdb = function (imdbId) {
37 return this._get('movie/lookup/imdb', [
38 {
39 key: 'imdbId',
40 type: rest_client_1.ResourceRouteParamType.Query,
41 value: imdbId,
42 },
43 ]);
44 };
45 MovieResource.prototype.list = function () {
46 return this._get('movie');
47 };
48 MovieResource.prototype.lookup = function (term) {
49 return this._get('movie/lookup', [
50 {
51 key: 'term',
52 type: rest_client_1.ResourceRouteParamType.Query,
53 value: term,
54 },
55 ]);
56 };
57 MovieResource.prototype.remove = function (id, deleteFiles) {
58 if (deleteFiles === void 0) { deleteFiles = false; }
59 return this._delete('movie/{:id}', [
60 {
61 key: 'deleteFiles',
62 type: rest_client_1.ResourceRouteParamType.Query,
63 value: deleteFiles,
64 },
65 {
66 key: 'id',
67 type: rest_client_1.ResourceRouteParamType.RouteParameter,
68 value: id,
69 },
70 ]);
71 };
72 MovieResource.prototype.tmdb = function (tmdbId) {
73 return this._get('movie/lookup/tmdb', [
74 {
75 key: 'tmdbId',
76 type: rest_client_1.ResourceRouteParamType.Query,
77 value: tmdbId,
78 },
79 ]);
80 };
81 MovieResource.prototype.update = function (movie) {
82 return this._put('movie/{:id}', movie, [
83 {
84 key: 'id',
85 type: rest_client_1.ResourceRouteParamType.RouteParameter,
86 value: movie.id,
87 },
88 ]);
89 };
90 return MovieResource;
91}(rest_client_1.Resource));
92exports.MovieResource = MovieResource;
93//# sourceMappingURL=MovieResource.js.map
\No newline at end of file