Edits history of script submission #3146 for ' Create a Webhook (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Create a Webhook
     * Create a new webhook.
     */
    export async function main(
      auth: Trello,
      description: string | undefined,
      callbackURL: string | undefined,
      idModel: string | undefined,
      active: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/webhooks/`);
      for (const [k, v] of [
        ["description", description],
        ["callbackURL", callbackURL],
        ["idModel", idModel],
        ["active", active],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        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 399 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Create a Webhook
     * Create a new webhook.
     */
    export async function main(
      auth: Trello,
      description: string | undefined,
      callbackURL: string | undefined,
      idModel: string | undefined,
      active: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/webhooks/`);
      for (const [k, v] of [
        ["description", description],
        ["callbackURL", callbackURL],
        ["idModel", idModel],
        ["active", active],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        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