Source: client/openapi/api/WorldControllerApi.js

/**
 * 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 { World } from '../model/World.js';
import { WorldStatus } from '../model/WorldStatus.js';

/**
* WorldController service.
* @module api/WorldControllerApi
* @version v0
*/
export class WorldControllerApi {

    /**
    * Constructs a new WorldControllerApi. 
    * @alias module:api/WorldControllerApi
    * @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;
    }



    /**
     * Create a private world, the user must be authenticated.
     * Create a private world, the user must be authenticated. If the world already  exists, owner may change isPublic or isTemporary parameters. Returns HTTP 201  CREATED for created world, or HTTP 200 OK if world already exists.
     * @param {String} worldName world name of created world, must be unique
     * @param {String} templateWorldName optional world template to use
     * @param {Boolean} isPublic optional flag to create public or private world,                           default false
     * @param {Boolean} isTemporary optional flag to create a temporary world, default                           true
     * @return {Promise< String >} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link String} and HTTP response
     */
    createWorldWithHttpInfo(worldName, templateWorldName, isPublic, isTemporary) {
      let postBody = null;
      // verify the required parameter 'worldName' is set
      if (worldName === undefined || worldName === null) {
        throw new Error("Missing the required parameter 'worldName' when calling createWorld");
      }
      // verify the required parameter 'templateWorldName' is set
      if (templateWorldName === undefined || templateWorldName === null) {
        throw new Error("Missing the required parameter 'templateWorldName' when calling createWorld");
      }
      // verify the required parameter 'isPublic' is set
      if (isPublic === undefined || isPublic === null) {
        throw new Error("Missing the required parameter 'isPublic' when calling createWorld");
      }
      // verify the required parameter 'isTemporary' is set
      if (isTemporary === undefined || isTemporary === null) {
        throw new Error("Missing the required parameter 'isTemporary' when calling createWorld");
      }

      let pathParams = {
      };
      let queryParams = {
        'worldName': worldName,
        'templateWorldName': templateWorldName,
        'isPublic': isPublic,
        'isTemporary': isTemporary
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = [];
      let contentTypes = [];
      let accepts = ['*/*'];
      let returnType = 'String';
      return this.apiClient.callApi(
        '/vrspace/api/worlds/create', 'POST',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null
      );
    }

    /**
     * Create a private world, the user must be authenticated.
     * Create a private world, the user must be authenticated. If the world already  exists, owner may change isPublic or isTemporary parameters. Returns HTTP 201  CREATED for created world, or HTTP 200 OK if world already exists.
     * @param {String} worldName world name of created world, must be unique
     * @param {String} templateWorldName optional world template to use
     * @param {Boolean} isPublic optional flag to create public or private world,                           default false
     * @param {Boolean} isTemporary optional flag to create a temporary world, default                           true
     * @return {Promise< String >} a {@link https://www.promisejs.org/|Promise}, with data of type {@link String}
     */
    createWorld(worldName, templateWorldName, isPublic, isTemporary) {
      return this.createWorldWithHttpInfo(worldName, templateWorldName, isPublic, isTemporary)
        .then(function(response_and_data) {
          return response_and_data.data;
        });
    }


    /**
     * @return {Promise< Array.<World> >} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<World>} and HTTP response
     */
    listWithHttpInfo() {
      let postBody = null;

      let pathParams = {
      };
      let queryParams = {
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = [];
      let contentTypes = [];
      let accepts = ['*/*'];
      let returnType = [World];
      return this.apiClient.callApi(
        '/vrspace/api/worlds/list', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null
      );
    }

    /**
     * @return {Promise< Array.<World> >} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<World>}
     */
    list() {
      return this.listWithHttpInfo()
        .then(function(response_and_data) {
          return response_and_data.data;
        });
    }


    /**
     * @return {Promise< Array.<WorldStatus> >} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link Array.<WorldStatus>} and HTTP response
     */
    usersWithHttpInfo() {
      let postBody = null;

      let pathParams = {
      };
      let queryParams = {
      };
      let headerParams = {
      };
      let formParams = {
      };

      let authNames = [];
      let contentTypes = [];
      let accepts = ['*/*'];
      let returnType = [WorldStatus];
      return this.apiClient.callApi(
        '/vrspace/api/worlds/users', 'GET',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, null
      );
    }

    /**
     * @return {Promise< Array.<WorldStatus> >} a {@link https://www.promisejs.org/|Promise}, with data of type {@link Array.<WorldStatus>}
     */
    users() {
      return this.usersWithHttpInfo()
        .then(function(response_and_data) {
          return response_and_data.data;
        });
    }


}