Edits history of script submission #3126 for ' Update Custom Field item on Card (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update Custom Field item on Card
     * Setting, updating, and removing the value for a Custom Field on a card. For more details on updating custom fields check out the Getting Started With Custom Fields
     */
    export async function main(
      auth: Trello,
      idCard: string,
      idCustomField: string,
      body:
        | {
            value?: {
              text?: string;
              checked?: boolean;
              date?: string;
              number?: number;
              [k: string]: unknown;
            };
            [k: string]: unknown;
          }
        | { idValue?: string; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.trello.com/1/cards/${idCard}/customField/${idCustomField}/item`
      );
      for (const [k, v] of [
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: undefined,
        },
        body: JSON.stringify(body),
      });
      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 Custom Field item on Card
     * Setting, updating, and removing the value for a Custom Field on a card. For more details on updating custom fields check out the Getting Started With Custom Fields
     */
    export async function main(
      auth: Trello,
      idCard: string,
      idCustomField: string,
      body:
        | {
            value?: {
              text?: string;
              checked?: boolean;
              date?: string;
              number?: number;
              [k: string]: unknown;
            };
            [k: string]: unknown;
          }
        | { idValue?: string; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.trello.com/1/cards/${idCard}/customField/${idCustomField}/item`
      );
      for (const [k, v] of [
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: undefined,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 826 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update Custom Field item on Card
     * Setting, updating, and removing the value for a Custom Field on a card. For more details on updating custom fields check out the [Getting Started With Custom Fields](/cloud/trello/guides/rest-api/getting-started-with-custom-fields/)
     */
    export async function main(
      auth: Trello,
      idCard: string,
      idCustomField: string,
      body:
        | {
            value?: {
              text?: string;
              checked?: boolean;
              date?: string;
              number?: number;
              [k: string]: unknown;
            };
            [k: string]: unknown;
          }
        | { idValue?: string; [k: string]: unknown }
    ) {
      const url = new URL(
        `https://api.trello.com/1/cards/${idCard}/customField/${idCustomField}/item`
      );
      for (const [k, v] of [
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: undefined,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 953 days ago