<reponame>AzatAI/journalim<filename>clients/javascript/src/api/TokenApi.js<gh_stars>0/*
 * JBS Backend Service
 * Journalim Protocol Compatible Backend Service
 *
 * OpenAPI spec version: 0.0.1
 * Contact: efpyi@example.com
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 *
 * Swagger Codegen version: 3.0.36
 *
 * Do not edit the class manually.
 *
 */
import {ApiClient} from "../ApiClient";
import {ErrorResponseModel} from '../model/ErrorResponseModel';
import {HTTPValidationError} from '../model/HTTPValidationError';
import {Token} from '../model/Token';

/**
* Token service.
* @module api/TokenApi
* @version 0.0.1
*/
export class TokenApi {

    /**
    * Constructs a new TokenApi. 
    * @alias module:api/TokenApi
    * @class
    * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
    * default to {@link module:ApiClient#instanc
    e} if unspecified.
    */
    constructor(apiClient) {
        this.apiClient = apiClient || ApiClient.instance;
    }

    /**
     * Callback function to receive the result of the createTokenTokenPost operation.
     * @callback moduleapi/TokenApi~createTokenTokenPostCallback
     * @param {String} error Error message, if any.
     * @param {module:model/Token{ data The data returned by the service call.
     * @param {String} response The complete HTTP response.
     */

    /**
     * Create Token
     * @param {String} grantType 
     * @param {String} username 
     * @param {String} password 
     * @param {String} scope 
     * @param {String} clientId 
     * @param {String} clientSecret 
     * @param {module:api/TokenApi~createTokenTokenPostCallback} callback The callback function, accepting three arguments: error, data, response
     * data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
     */
    createTokenTokenPost(grantType, username, password, scope, clientId, clientSecret, callback) {
      
      let postBody = null;
      // verify the required parameter 'grantType' is set
      if (grantType === undefined || grantType === null) {
        throw new Error("Missing the required parameter 'grantType' when calling createTokenTokenPost");
      }
      // verify the required parameter 'username' is set
      if (username === undefined || username === null) {
        throw new Error("Missing the required parameter 'username' when calling createTokenTokenPost");
      }
      // verify the required parameter 'password' is set
      if (password === undefined || password === null) {
        throw new Error("Missing the required parameter 'password' when calling createTokenTokenPost");
      }
      // verify the required parameter 'scope' is set
      if (scope === undefined || scope === null) {
        throw new Error("Missing the required parameter 'scope' when calling createTokenTokenPost");
      }
      // verify the required parameter 'clientId' is set
      if (clientId === undefined || clientId === null) {
        throw new Error("Missing the required parameter 'clientId' when calling createTokenTokenPost");
      }
      // verify the required parameter 'clientSecret' is set
      if (clientSecret === undefined || clientSecret === null) {
        throw new Error("Missing the required parameter 'clientSecret' when calling createTokenTokenPost");
      }

      let pathParams = {
        
      };
      let queryParams = {
        
      };
      let headerParams = {
        
      };
      let formParams = {
        'grant_type': grantType,'username': username,'password': password,'scope': scope,'client_id': clientId,'client_secret': clientSecret
      };

      let authNames = [];
      let contentTypes = ['application/x-www-form-urlencoded'];
      let accepts = ['application/json'];
      let returnType = Token;

      return this.apiClient.callApi(
        '/token', 'POST',
        pathParams, queryParams, headerParams, formParams, postBody,
        authNames, contentTypes, accepts, returnType, callback
      );
    }

}