Edits history of script submission #3267 for ' Delete a project status (asana)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Asana = {
      token: string;
    };
    /**
     * Delete a project status
     * *Deprecated: new integrations should prefer the `/status_updates/{status_gid}` route.*
    
    Deletes a specific, existing project status update.
    
    Returns an empty data record.
     */
    export async function main(
      auth: Asana,
      project_status_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined
    ) {
      const url = new URL(
        `https://app.asana.com/api/1.0/project_statuses/${project_status_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: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      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;
    };
    /**
     * Delete a project status
     * *Deprecated: new integrations should prefer the `/status_updates/{status_gid}` route.*
    
    Deletes a specific, existing project status update.
    
    Returns an empty data record.
     */
    export async function main(
      auth: Asana,
      project_status_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined
    ) {
      const url = new URL(
        `https://app.asana.com/api/1.0/project_statuses/${project_status_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: "DELETE",
        headers: {
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 937 days ago