'use strict';

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

class Teams {
  constructor(client) {
    this.client = client;
  }
  list(paramsOrFirst, ...rest) {
    let params;
    if (!paramsOrFirst || paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        queries: paramsOrFirst,
        search: rest[0],
        total: rest[1]
      };
    }
    const queries = params.queries;
    const search = params.search;
    const total = params.total;
    const apiPath = "/teams";
    const payload = {};
    if (typeof queries !== "undefined") {
      payload["queries"] = queries;
    }
    if (typeof search !== "undefined") {
      payload["search"] = search;
    }
    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
    );
  }
  create(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        name: rest[0],
        roles: rest[1]
      };
    }
    const teamId = params.teamId;
    const name = params.name;
    const roles = params.roles;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof name === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "name"');
    }
    const apiPath = "/teams";
    const payload = {};
    if (typeof teamId !== "undefined") {
      payload["teamId"] = teamId;
    }
    if (typeof name !== "undefined") {
      payload["name"] = name;
    }
    if (typeof roles !== "undefined") {
      payload["roles"] = roles;
    }
    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 = {
        teamId: paramsOrFirst
      };
    }
    const teamId = params.teamId;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    const apiPath = "/teams/{teamId}".replace("{teamId}", teamId);
    const payload = {};
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {};
    return this.client.call(
      "get",
      uri,
      apiHeaders,
      payload
    );
  }
  updateName(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        name: rest[0]
      };
    }
    const teamId = params.teamId;
    const name = params.name;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof name === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "name"');
    }
    const apiPath = "/teams/{teamId}".replace("{teamId}", teamId);
    const payload = {};
    if (typeof name !== "undefined") {
      payload["name"] = name;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "put",
      uri,
      apiHeaders,
      payload
    );
  }
  delete(paramsOrFirst) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst
      };
    }
    const teamId = params.teamId;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    const apiPath = "/teams/{teamId}".replace("{teamId}", teamId);
    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
    );
  }
  listMemberships(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        queries: rest[0],
        search: rest[1],
        total: rest[2]
      };
    }
    const teamId = params.teamId;
    const queries = params.queries;
    const search = params.search;
    const total = params.total;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    const apiPath = "/teams/{teamId}/memberships".replace("{teamId}", teamId);
    const payload = {};
    if (typeof queries !== "undefined") {
      payload["queries"] = queries;
    }
    if (typeof search !== "undefined") {
      payload["search"] = search;
    }
    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
    );
  }
  createMembership(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        roles: rest[0],
        email: rest[1],
        userId: rest[2],
        phone: rest[3],
        url: rest[4],
        name: rest[5]
      };
    }
    const teamId = params.teamId;
    const roles = params.roles;
    const email = params.email;
    const userId = params.userId;
    const phone = params.phone;
    const url = params.url;
    const name = params.name;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof roles === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "roles"');
    }
    const apiPath = "/teams/{teamId}/memberships".replace("{teamId}", teamId);
    const payload = {};
    if (typeof email !== "undefined") {
      payload["email"] = email;
    }
    if (typeof userId !== "undefined") {
      payload["userId"] = userId;
    }
    if (typeof phone !== "undefined") {
      payload["phone"] = phone;
    }
    if (typeof roles !== "undefined") {
      payload["roles"] = roles;
    }
    if (typeof url !== "undefined") {
      payload["url"] = url;
    }
    if (typeof name !== "undefined") {
      payload["name"] = name;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "post",
      uri,
      apiHeaders,
      payload
    );
  }
  getMembership(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        membershipId: rest[0]
      };
    }
    const teamId = params.teamId;
    const membershipId = params.membershipId;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof membershipId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "membershipId"');
    }
    const apiPath = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId);
    const payload = {};
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {};
    return this.client.call(
      "get",
      uri,
      apiHeaders,
      payload
    );
  }
  updateMembership(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        membershipId: rest[0],
        roles: rest[1]
      };
    }
    const teamId = params.teamId;
    const membershipId = params.membershipId;
    const roles = params.roles;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof membershipId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "membershipId"');
    }
    if (typeof roles === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "roles"');
    }
    const apiPath = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId);
    const payload = {};
    if (typeof roles !== "undefined") {
      payload["roles"] = roles;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "patch",
      uri,
      apiHeaders,
      payload
    );
  }
  deleteMembership(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        membershipId: rest[0]
      };
    }
    const teamId = params.teamId;
    const membershipId = params.membershipId;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof membershipId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "membershipId"');
    }
    const apiPath = "/teams/{teamId}/memberships/{membershipId}".replace("{teamId}", teamId).replace("{membershipId}", membershipId);
    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
    );
  }
  updateMembershipStatus(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        membershipId: rest[0],
        userId: rest[1],
        secret: rest[2]
      };
    }
    const teamId = params.teamId;
    const membershipId = params.membershipId;
    const userId = params.userId;
    const secret = params.secret;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof membershipId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "membershipId"');
    }
    if (typeof userId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "userId"');
    }
    if (typeof secret === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "secret"');
    }
    const apiPath = "/teams/{teamId}/memberships/{membershipId}/status".replace("{teamId}", teamId).replace("{membershipId}", membershipId);
    const payload = {};
    if (typeof userId !== "undefined") {
      payload["userId"] = userId;
    }
    if (typeof secret !== "undefined") {
      payload["secret"] = secret;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "patch",
      uri,
      apiHeaders,
      payload
    );
  }
  getPrefs(paramsOrFirst) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst
      };
    }
    const teamId = params.teamId;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    const apiPath = "/teams/{teamId}/prefs".replace("{teamId}", teamId);
    const payload = {};
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {};
    return this.client.call(
      "get",
      uri,
      apiHeaders,
      payload
    );
  }
  updatePrefs(paramsOrFirst, ...rest) {
    let params;
    if (paramsOrFirst && typeof paramsOrFirst === "object" && !Array.isArray(paramsOrFirst)) {
      params = paramsOrFirst || {};
    } else {
      params = {
        teamId: paramsOrFirst,
        prefs: rest[0]
      };
    }
    const teamId = params.teamId;
    const prefs = params.prefs;
    if (typeof teamId === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "teamId"');
    }
    if (typeof prefs === "undefined") {
      throw new client.AppwriteException('Missing required parameter: "prefs"');
    }
    const apiPath = "/teams/{teamId}/prefs".replace("{teamId}", teamId);
    const payload = {};
    if (typeof prefs !== "undefined") {
      payload["prefs"] = prefs;
    }
    const uri = new URL(this.client.config.endpoint + apiPath);
    const apiHeaders = {
      "content-type": "application/json"
    };
    return this.client.call(
      "put",
      uri,
      apiHeaders,
      payload
    );
  }
}

exports.Teams = Teams;
//# sourceMappingURL=out.js.map
//# sourceMappingURL=teams.js.map