Edits history of script submission #2904 for ' Update a Webhook created by Token (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a Webhook created by Token
     * Update a Webhook created by Token
     */
    export async function main(
      auth: Trello,
      token: string,
      idWebhook: string,
      description: string | undefined,
      callbackURL: string | undefined,
      idModel: string | undefined
    ) {
      const url = new URL(
        `https://api.trello.com/1/tokens/${token}/webhooks/${idWebhook}`
      );
      for (const [k, v] of [
        ["description", description],
        ["callbackURL", callbackURL],
        ["idModel", idModel],
        ["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.text();
    }
    

    Submitted by hugo697 398 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a Webhook created by Token
     * Update a Webhook created by Token
     */
    export async function main(
      auth: Trello,
      token: string,
      idWebhook: string,
      description: string | undefined,
      callbackURL: string | undefined,
      idModel: string | undefined
    ) {
      const url = new URL(
        `https://api.trello.com/1/tokens/${token}/webhooks/${idWebhook}`
      );
      for (const [k, v] of [
        ["description", description],
        ["callbackURL", callbackURL],
        ["idModel", idModel],
        ["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.text();
    }
    

    Submitted by hugo697 953 days ago