Edits history of script submission #3112 for ' Transfer an Organization to an Enterprise. (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Transfer an Organization to an Enterprise.
     * Transfer an organization to an enterprise.
    
     NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in the organization being added to the enterprise asynchronously. A 200 response only indicates receipt of the request, it does not indicate successful addition to the enterprise.
     */
    export async function main(
      auth: Trello,
      id: string,
      idOrganization: string | undefined
    ) {
      const url = new URL(
        `https://api.trello.com/1/enterprises/${id}/organizations`
      );
      for (const [k, v] of [
        ["idOrganization", idOrganization],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 398 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Transfer an Organization to an Enterprise.
     * Transfer an organization to an enterprise.
    
     NOTE: For enterprises that have opted in to user management via AdminHub, this endpoint will result in the organization being added to the enterprise asynchronously. A 200 response only indicates receipt of the request, it does not indicate successful addition to the enterprise.
     */
    export async function main(
      auth: Trello,
      id: string,
      idOrganization: string | undefined
    ) {
      const url = new URL(
        `https://api.trello.com/1/enterprises/${id}/organizations`
      );
      for (const [k, v] of [
        ["idOrganization", idOrganization],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 953 days ago