Edits history of script submission #22304 for ' List Documents (docusign)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Documents
     * List documents belonging to an envelope.
     */
    export async function main(
      auth: RT.Docusign,
      envelope_id: string,
      include_metadata: boolean | undefined,
    ) {
      const url = new URL(
        `${auth.base_uri}/restapi/v2.1/accounts/${auth.account_id}/envelopes/${envelope_id}/documents`,
      )
      if (include_metadata !== undefined) {
        url.searchParams.append("include_metadata", String(include_metadata))
      }
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 22 days ago