UNPKG

sinch-rtc

Version:

RTC JavaScript/Web SDK

257 lines 12.6 kB
"use strict"; /* tslint:disable */ /* eslint-disable */ /** * Ocra (REST API for Sinch RTC clients) * REST API for Sinch RTC clients. * * The version of the OpenAPI document: 0.11.0 * Contact: rtc@sinch.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PushApi = void 0; const runtime = require("../runtime"); const models_1 = require("../models"); /** * */ class PushApi extends runtime.BaseAPI { /** * Delete all PushProfiles for given User */ deleteAllUserPushProfilesRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.userId === null || requestParameters.userId === undefined) { throw new runtime.RequiredError('userId', 'Required parameter requestParameters.userId was null or undefined when calling deleteAllUserPushProfiles.'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("jwtAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v1/users/{userId}/pushProfiles`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); }); } /** * Delete all PushProfiles for given User */ deleteAllUserPushProfiles(requestParameters) { return __awaiter(this, void 0, void 0, function* () { yield this.deleteAllUserPushProfilesRaw(requestParameters); }); } /** * Delete PushProfile */ deletePushProfileRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.userId === null || requestParameters.userId === undefined) { throw new runtime.RequiredError('userId', 'Required parameter requestParameters.userId was null or undefined when calling deletePushProfile.'); } if (requestParameters.instanceId === null || requestParameters.instanceId === undefined) { throw new runtime.RequiredError('instanceId', 'Required parameter requestParameters.instanceId was null or undefined when calling deletePushProfile.'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("instanceAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v1/users/{userId}/instances/{instanceId}/pushProfile`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"instanceId"}}`, encodeURIComponent(String(requestParameters.instanceId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); }); } /** * Delete PushProfile */ deletePushProfile(requestParameters) { return __awaiter(this, void 0, void 0, function* () { yield this.deletePushProfileRaw(requestParameters); }); } /** * Get current PushProfile */ getPushProfileRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.userId === null || requestParameters.userId === undefined) { throw new runtime.RequiredError('userId', 'Required parameter requestParameters.userId was null or undefined when calling getPushProfile.'); } if (requestParameters.instanceId === null || requestParameters.instanceId === undefined) { throw new runtime.RequiredError('instanceId', 'Required parameter requestParameters.instanceId was null or undefined when calling getPushProfile.'); } const queryParameters = {}; const headerParameters = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("instanceAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v1/users/{userId}/instances/{instanceId}/pushProfile`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"instanceId"}}`, encodeURIComponent(String(requestParameters.instanceId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response, (jsonValue) => (0, models_1.PushProfileFromJSON)(jsonValue)); }); } /** * Get current PushProfile */ getPushProfile(requestParameters) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.getPushProfileRaw(requestParameters); return yield response.value(); }); } /** * (DEPRECATED) Send a single push notification message. */ sendPushNotificationRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.pushNotification === null || requestParameters.pushNotification === undefined) { throw new runtime.RequiredError('pushNotification', 'Required parameter requestParameters.pushNotification was null or undefined when calling sendPushNotification.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("instanceAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v1/pushNotifications`, method: 'POST', headers: headerParameters, query: queryParameters, body: (0, models_1.PushNotificationToJSON)(requestParameters.pushNotification), }); return new runtime.VoidApiResponse(response); }); } /** * (DEPRECATED) Send a single push notification message. */ sendPushNotification(requestParameters) { return __awaiter(this, void 0, void 0, function* () { yield this.sendPushNotificationRaw(requestParameters); }); } /** * Send push notification message(s) */ sendPushNotificationsRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.pushNotification === null || requestParameters.pushNotification === undefined) { throw new runtime.RequiredError('pushNotification', 'Required parameter requestParameters.pushNotification was null or undefined when calling sendPushNotifications.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("instanceAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v2/pushNotifications`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.pushNotification.map(models_1.PushNotificationToJSON), }); return new runtime.VoidApiResponse(response); }); } /** * Send push notification message(s) */ sendPushNotifications(requestParameters) { return __awaiter(this, void 0, void 0, function* () { yield this.sendPushNotificationsRaw(requestParameters); }); } /** * Create or update PushProfile */ updatePushProfileRaw(requestParameters) { return __awaiter(this, void 0, void 0, function* () { if (requestParameters.userId === null || requestParameters.userId === undefined) { throw new runtime.RequiredError('userId', 'Required parameter requestParameters.userId was null or undefined when calling updatePushProfile.'); } if (requestParameters.instanceId === null || requestParameters.instanceId === undefined) { throw new runtime.RequiredError('instanceId', 'Required parameter requestParameters.instanceId was null or undefined when calling updatePushProfile.'); } if (requestParameters.pushProfile === null || requestParameters.pushProfile === undefined) { throw new runtime.RequiredError('pushProfile', 'Required parameter requestParameters.pushProfile was null or undefined when calling updatePushProfile.'); } const queryParameters = {}; const headerParameters = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = typeof token === 'function' ? token("instanceAuth", []) : token; if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = yield this.request({ path: `/v1/users/{userId}/instances/{instanceId}/pushProfile`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))).replace(`{${"instanceId"}}`, encodeURIComponent(String(requestParameters.instanceId))), method: 'PUT', headers: headerParameters, query: queryParameters, body: (0, models_1.PushProfileToJSON)(requestParameters.pushProfile), }); return new runtime.VoidApiResponse(response); }); } /** * Create or update PushProfile */ updatePushProfile(requestParameters) { return __awaiter(this, void 0, void 0, function* () { yield this.updatePushProfileRaw(requestParameters); }); } } exports.PushApi = PushApi; //# sourceMappingURL=PushApi.js.map