UNPKG

@kaltura-ng/kaltura-client

Version:
88 lines 3.42 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import 'rxjs/add/observable/of'; import { Http, Headers } from '@angular/http'; import { CancelableAction } from './api/utils/cancelable-action'; import { KalturaHttpClientBase } from './api/kaltura-clients/kaltura-http-client-base'; import { KalturaClientConfiguration } from './kaltura-client-configuration.service'; var KalturaClient = (function (_super) { __extends(KalturaClient, _super); function KalturaClient(http, configuration) { var _this = _super.call(this, configuration) || this; _this.http = http; return _this; } KalturaClient.prototype._createCancelableAction = function (data) { var _this = this; var requestContext = new CancelableAction(function (resolve, reject) { var body = JSON.stringify(data.body); var headers = new Headers(data.headers); var subscription = _this.http.request(data.endpoint, { method: 'post', body: body, headers: headers }).subscribe(function (response) { resolve(response.json()); }, function (error) { reject(error); }); return function () { if (subscription) { subscription.unsubscribe(); } }; }); return requestContext; }; KalturaClient.prototype.request = function (request) { var _this = this; return Observable.create(function (observer) { var requestContext = _super.prototype._request.call(_this, request).then(function (value) { observer.next(value); observer.complete(); }, function (reason) { observer.error(reason); }); return function () { requestContext.cancel(); }; }); }; KalturaClient.prototype.multiRequest = function (arg) { var _this = this; return Observable.create(function (observer) { var requestContext = _super.prototype._multiRequest.call(_this, arg).then(function (value) { observer.next(value); observer.complete(); }, function (reason) { observer.error(reason); }); return function () { requestContext.cancel(); }; }); }; KalturaClient.decorators = [ { type: Injectable }, ]; /** @nocollapse */ KalturaClient.ctorParameters = function () { return [ { type: Http, }, { type: KalturaClientConfiguration, }, ]; }; return KalturaClient; }(KalturaHttpClientBase)); export { KalturaClient }; //# sourceMappingURL=kaltura-client.service.js.map