Edits history of script submission #3020 for ' Get signupUrl for Enterprise (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Get signupUrl for Enterprise
     * Get the signup URL for an enterprise.
     */
    export async function main(
      auth: Trello,
      id: string,
      authenticate: string | undefined,
      confirmationAccepted: string | undefined,
      returnUrl: string | undefined,
      tosAccepted: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/enterprises/${id}/signupUrl`);
      for (const [k, v] of [
        ["authenticate", authenticate],
        ["confirmationAccepted", confirmationAccepted],
        ["returnUrl", returnUrl],
        ["tosAccepted", tosAccepted],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        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;
    };
    /**
     * Get signupUrl for Enterprise
     * Get the signup URL for an enterprise.
     */
    export async function main(
      auth: Trello,
      id: string,
      authenticate: string | undefined,
      confirmationAccepted: string | undefined,
      returnUrl: string | undefined,
      tosAccepted: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/enterprises/${id}/signupUrl`);
      for (const [k, v] of [
        ["authenticate", authenticate],
        ["confirmationAccepted", confirmationAccepted],
        ["returnUrl", returnUrl],
        ["tosAccepted", tosAccepted],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        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