Edits history of script submission #3252 for ' Create a task (asana)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Asana = {
      token: string;
    };
    /**
     * Create a task
     * Creating a new task is as easy as POSTing to the `/tasks` endpoint with a
    data block containing the fields you’d like to set on the task. Any
    unspecified fields will take on default values.
    
    Every task is required to be created in a specific workspace, and this
    workspace cannot be changed once set. The workspace need not be set
    explicitly if you specify `projects` or a `parent` task instead.
     */
    export async function main(
      auth: Asana,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      body: {
        data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
          name?: string;
          resource_subtype?: "default_task" | "milestone" | "section" | "approval";
          [k: string]: unknown;
        }) & {
          actual_time_minutes?: number;
          approval_status?:
            | "pending"
            | "approved"
            | "rejected"
            | "changes_requested";
          assignee_status?: "today" | "upcoming" | "later" | "new" | "inbox";
          completed?: boolean;
          completed_at?: string;
          completed_by?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          } & { name?: string; [k: string]: unknown };
          created_at?: string;
          dependencies?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          dependents?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          due_at?: string;
          due_on?: string;
          external?: { data?: string; gid?: string; [k: string]: unknown };
          hearted?: boolean;
          hearts?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          html_notes?: string;
          is_rendered_as_separator?: boolean;
          liked?: boolean;
          likes?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          memberships?: {
            project?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            section?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          modified_at?: string;
          name?: string;
          notes?: string;
          num_hearts?: number;
          num_likes?: number;
          num_subtasks?: number;
          start_at?: string;
          start_on?: string;
          [k: string]: unknown;
        }) & {
          assignee?: string;
          assignee_section?: string;
          custom_fields?: { [k: string]: string };
          followers?: string[];
          parent?: string;
          projects?: string[];
          tags?: string[];
          workspace?: string;
          [k: string]: unknown;
        };
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://app.asana.com/api/1.0/tasks`);
      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: "POST",
        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 369 days ago

  • nativets
    type Asana = {
      token: string;
    };
    /**
     * Create a task
     * Creating a new task is as easy as POSTing to the `/tasks` endpoint with a
    data block containing the fields you’d like to set on the task. Any
    unspecified fields will take on default values.
    
    Every task is required to be created in a specific workspace, and this
    workspace cannot be changed once set. The workspace need not be set
    explicitly if you specify `projects` or a `parent` task instead.
     */
    export async function main(
      auth: Asana,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      body: {
        data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
          name?: string;
          resource_subtype?: "default_task" | "milestone" | "section" | "approval";
          [k: string]: unknown;
        }) & {
          actual_time_minutes?: number;
          approval_status?:
            | "pending"
            | "approved"
            | "rejected"
            | "changes_requested";
          assignee_status?: "today" | "upcoming" | "later" | "new" | "inbox";
          completed?: boolean;
          completed_at?: string;
          completed_by?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          } & { name?: string; [k: string]: unknown };
          created_at?: string;
          dependencies?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          dependents?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          due_at?: string;
          due_on?: string;
          external?: { data?: string; gid?: string; [k: string]: unknown };
          hearted?: boolean;
          hearts?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          html_notes?: string;
          is_rendered_as_separator?: boolean;
          liked?: boolean;
          likes?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          memberships?: {
            project?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            section?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          modified_at?: string;
          name?: string;
          notes?: string;
          num_hearts?: number;
          num_likes?: number;
          num_subtasks?: number;
          start_at?: string;
          start_on?: string;
          [k: string]: unknown;
        }) & {
          assignee?: string;
          assignee_section?: string;
          custom_fields?: { [k: string]: string };
          followers?: string[];
          parent?: string;
          projects?: string[];
          tags?: string[];
          workspace?: string;
          [k: string]: unknown;
        };
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://app.asana.com/api/1.0/tasks`);
      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: "POST",
        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;
    };
    /**
     * Create a task
     * Creating a new task is as easy as POSTing to the `/tasks` endpoint with a
    data block containing the fields you’d like to set on the task. Any
    unspecified fields will take on default values.
    
    Every task is required to be created in a specific workspace, and this
    workspace cannot be changed once set. The workspace need not be set
    explicitly if you specify `projects` or a `parent` task instead.
     */
    export async function main(
      auth: Asana,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      body: {
        data?: (({ gid?: string; resource_type?: string; [k: string]: unknown } & {
          name?: string;
          resource_subtype?: "default_task" | "milestone" | "section" | "approval";
          [k: string]: unknown;
        }) & {
          actual_time_minutes?: number;
          approval_status?:
            | "pending"
            | "approved"
            | "rejected"
            | "changes_requested";
          assignee_status?: "today" | "upcoming" | "later" | "new" | "inbox";
          completed?: boolean;
          completed_at?: string;
          completed_by?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          } & { name?: string; [k: string]: unknown };
          created_at?: string;
          dependencies?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          dependents?: {
            gid?: string;
            resource_type?: string;
            [k: string]: unknown;
          }[];
          due_at?: string;
          due_on?: string;
          external?: { data?: string; gid?: string; [k: string]: unknown };
          hearted?: boolean;
          hearts?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          html_notes?: string;
          is_rendered_as_separator?: boolean;
          liked?: boolean;
          likes?: {
            gid?: string;
            user?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          memberships?: {
            project?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            section?: {
              gid?: string;
              resource_type?: string;
              [k: string]: unknown;
            } & { name?: string; [k: string]: unknown };
            [k: string]: unknown;
          }[];
          modified_at?: string;
          name?: string;
          notes?: string;
          num_hearts?: number;
          num_likes?: number;
          num_subtasks?: number;
          start_at?: string;
          start_on?: string;
          [k: string]: unknown;
        }) & {
          assignee?: string;
          assignee_section?: string;
          custom_fields?: { [k: string]: string };
          followers?: string[];
          parent?: string;
          projects?: string[];
          tags?: string[];
          workspace?: string;
          [k: string]: unknown;
        };
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://app.asana.com/api/1.0/tasks`);
      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: "POST",
        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