UNPKG

@vrspace/babylonjs

Version:

vrspace.org babylonjs client

174 lines (151 loc) 6.05 kB
/** * OpenAPI definition * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: v0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. * */ import {ApiClient} from "../ApiClient.js"; import { WebPushSubscription } from '../model/WebPushSubscription.js'; /** * WebPush service. * @module api/WebPushApi * @version v0 */ export class WebPushApi { /** * Constructs a new WebPushApi. * @alias module:api/WebPushApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ constructor(apiClient) { this.apiClient = apiClient || ApiClient.instance; } /** * Returns public VAPID key required to create WebPush subscription. * Returns public VAPID key required to create WebPush subscription. * @return {Promise< String >} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link String} and HTTP response */ getKeyWithHttpInfo() { let postBody = null; let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = []; let accepts = ['*/*']; let returnType = 'String'; return this.apiClient.callApi( '/vrspace/api/webpush/publicKey', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Returns public VAPID key required to create WebPush subscription. * Returns public VAPID key required to create WebPush subscription. * @return {Promise< String >} a {@link https://www.promisejs.org/|Promise}, with data of type {@link String} */ getKey() { return this.getKeyWithHttpInfo() .then(function(response_and_data) { return response_and_data.data; }); } /** * Subscribe to webpush: this notifies the server that the browser has created a webpush subscription. * Subscribe to webpush: this notifies the server that the browser has created a webpush subscription. Requires authorization. * @param {WebPushSubscription} webPushSubscription Subscription data. * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ subscribeWithHttpInfo(webPushSubscription) { let postBody = webPushSubscription; // verify the required parameter 'webPushSubscription' is set if (webPushSubscription === undefined || webPushSubscription === null) { throw new Error("Missing the required parameter 'webPushSubscription' when calling subscribe"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = []; let returnType = null; return this.apiClient.callApi( '/vrspace/api/webpush/subscribe', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Subscribe to webpush: this notifies the server that the browser has created a webpush subscription. * Subscribe to webpush: this notifies the server that the browser has created a webpush subscription. Requires authorization. * @param {WebPushSubscription} webPushSubscription Subscription data. * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ subscribe(webPushSubscription) { return this.subscribeWithHttpInfo(webPushSubscription) .then(function(response_and_data) { return response_and_data.data; }); } /** * Removes subscription information from the server, when browser unsubscribes. * Removes subscription information from the server, when browser unsubscribes. Requires authorization. * @param {WebPushSubscription} webPushSubscription * @return {Promise} a {@link https://www.promisejs.org/|Promise}, with an object containing HTTP response */ unsubscribeWithHttpInfo(webPushSubscription) { let postBody = webPushSubscription; // verify the required parameter 'webPushSubscription' is set if (webPushSubscription === undefined || webPushSubscription === null) { throw new Error("Missing the required parameter 'webPushSubscription' when calling unsubscribe"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = []; let contentTypes = ['application/json']; let accepts = []; let returnType = null; return this.apiClient.callApi( '/vrspace/api/webpush/unsubscribe', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null ); } /** * Removes subscription information from the server, when browser unsubscribes. * Removes subscription information from the server, when browser unsubscribes. Requires authorization. * @param {WebPushSubscription} webPushSubscription * @return {Promise} a {@link https://www.promisejs.org/|Promise} */ unsubscribe(webPushSubscription) { return this.unsubscribeWithHttpInfo(webPushSubscription) .then(function(response_and_data) { return response_and_data.data; }); } }