text: "use strict";
  var __importDefault = (this && this.__importDefault) || function (mod) {
      return (mod && mod.__esModule) ? mod : { "default": mod };
  };
  Object.defineProperty(exports, "__esModule", { value: true });
  const node_fetch_1 = __importDefault(require("node-fetch"));
  const constants_1 = require("./constants");
  class ImagesApi {
      constructor(params) {
          this._skillId = params.skillId;
          this._oAuthToken = params.oAuthToken;
      }
      async uploadImageByUrl(url) {
          const response = await this._makeRequest({
              path: 'images',
              method: 'POST',
              body: { url },
          });
          return response.image;
      }
      async uploadImageFile() {
          throw new Error('Not implemented');
      }
      async getImages() {
          const response = await this._makeRequest({
              path: 'images',
              method: 'GET',
          });
          return response.images;
      }
      async getImagesQuota() {
          const response = await this._makeRequest({
              url: `${constants_1.ALICE_API_URL}/status`,
              method: 'GET',
          });
          return response.images.quota;
      }
      async deleteImage(imageId) {
          const response = await this._makeRequest({
              path: `images/${imageId}`,
              method: 'DELETE',
          });
          return response;
      }
      async _makeRequest(params) {
          if (!this._oAuthToken) {
              throw new Error(`Please, provide "oAuthToken" and "skillId" to alice constructor`);
          }
          const url = params.url || `${constants_1.ALICE_API_URL}/skills/${this._skillId}/${params.path}`;
          const method = params.method || 'GET';
          const body = params.body ? JSON.stringify(params.body) : undefined;
          const response = await node_fetch_1.default(url, {
              method: method,
              headers: {
                  'Authorization': `OAuth ${this._oAuthToken}`,
                  'Content-type': 'application/json',
              },
              body: body,
          });
          return await response.json();
      }
  }
  exports.ImagesApi = ImagesApi;
  