Edits history of script submission #3178 for ' Update a story (asana)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Asana = {
      token: string;
    };
    /**
     * Update a story
     * Updates the story and returns the full record for the updated story. Only comment stories can have their text updated, and only comment stories and attachment stories can be pinned. Only one of `text` and `html_text` can be specified.
     */
    export async function main(
      auth: Asana,
      story_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      body: {
        data?: { gid?: string; resource_type?: string; [k: string]: unknown } & {
          created_at?: string;
          html_text?: string;
          is_pinned?: boolean;
          resource_subtype?: string;
          sticker_name?:
            | "green_checkmark"
            | "people_dancing"
            | "dancing_unicorn"
            | "heart"
            | "party_popper"
            | "people_waving_flags"
            | "splashing_narwhal"
            | "trophy"
            | "yeti_riding_unicorn"
            | "celebrating_people"
            | "determined_climbers"
            | "phoenix_spreading_love";
          text?: string;
          [k: string]: unknown;
        };
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://app.asana.com/api/1.0/stories/${story_gid}`);
      for (const [k, v] of [
        ["opt_pretty", opt_pretty],
        ["opt_fields", opt_fields],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 383 days ago

  • nativets
    type Asana = {
      token: string;
    };
    /**
     * Update a story
     * Updates the story and returns the full record for the updated story. Only comment stories can have their text updated, and only comment stories and attachment stories can be pinned. Only one of `text` and `html_text` can be specified.
     */
    export async function main(
      auth: Asana,
      story_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      body: {
        data?: { gid?: string; resource_type?: string; [k: string]: unknown } & {
          created_at?: string;
          html_text?: string;
          is_pinned?: boolean;
          resource_subtype?: string;
          sticker_name?:
            | "green_checkmark"
            | "people_dancing"
            | "dancing_unicorn"
            | "heart"
            | "party_popper"
            | "people_waving_flags"
            | "splashing_narwhal"
            | "trophy"
            | "yeti_riding_unicorn"
            | "celebrating_people"
            | "determined_climbers"
            | "phoenix_spreading_love";
          text?: string;
          [k: string]: unknown;
        };
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://app.asana.com/api/1.0/stories/${story_gid}`);
      for (const [k, v] of [
        ["opt_pretty", opt_pretty],
        ["opt_fields", opt_fields],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 937 days ago