'use strict';

var client = require('../client');

class Tokens {
  constructor(client) {
    this.client = client;
  }
  list(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        bucketId: paramsOrFirst,
        fileId: rest[0],
        queries: rest[1],
        total: rest[2]
      };
    }
    const bucketId = params.bucketId;
    const fileId = params.fileId;
    const queries = params.queries;
    const total = params.total;
    if (typeof bucketId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "bucketId"');
    }
    if (typeof fileId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "fileId"');
    }
    const apiPath = "/tokens/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId);
    const payload = {};
    if (typeof queries !== "undefined") {
      payload["queries"] = queries;
    }
    if (typeof total !== "undefined") {
      payload["total"] = total;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {};
    return this.client.call(
      "get",
      uri,
      apiHeaders,
      payload
    );
  }
  createFileToken(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        bucketId: paramsOrFirst,
        fileId: rest[0],
        expire: rest[1]
      };
    }
    const bucketId = params.bucketId;
    const fileId = params.fileId;
    const expire = params.expire;
    if (typeof bucketId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "bucketId"');
    }
    if (typeof fileId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "fileId"');
    }
    const apiPath = "/tokens/buckets/{bucketId}/files/{fileId}".replace("{bucketId}", bucketId).replace("{fileId}", fileId);
    const payload = {};
    if (typeof expire !== "undefined") {
      payload["expire"] = expire;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "post",
      uri,
      apiHeaders,
      payload
    );
  }
  get(paramsOrFirst) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        tokenId: paramsOrFirst
      };
    }
    const tokenId = params.tokenId;
    if (typeof tokenId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "tokenId"');
    }
    const apiPath = "/tokens/{tokenId}".replace("{tokenId}", tokenId);
    const payload = {};
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {};
    return this.client.call(
      "get",
      uri,
      apiHeaders,
      payload
    );
  }
  update(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        tokenId: paramsOrFirst,
        expire: rest[0]
      };
    }
    const tokenId = params.tokenId;
    const expire = params.expire;
    if (typeof tokenId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "tokenId"');
    }
    const apiPath = "/tokens/{tokenId}".replace("{tokenId}", tokenId);
    const payload = {};
    if (typeof expire !== "undefined") {
      payload["expire"] = expire;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "patch",
      uri,
      apiHeaders,
      payload
    );
  }
  delete(paramsOrFirst) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        tokenId: paramsOrFirst
      };
    }
    const tokenId = params.tokenId;
    if (typeof tokenId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "tokenId"');
    }
    const apiPath = "/tokens/{tokenId}".replace("{tokenId}", tokenId);
    const payload = {};
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "delete",
      uri,
      apiHeaders,
      payload
    );
  }
}

exports.Tokens = Tokens;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=tokens.js.map