Edits history of script submission #3840 for ' Create a Satisfaction Rating (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Create a Satisfaction Rating
     * Creates a CSAT rating for a solved ticket, or for a ticket that was previously
    solved and then reopened.
    
    Only the end user listed as the ticket requester can create a satisfaction rating for the ticket.
    
    #### Allowed For
    
    * End user who requested the ticket
    
    The end user must be a verified user.
    
     */
    export async function main(auth: Zendesk, ticket_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/satisfaction_rating`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 377 days ago

  • nativets
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Create a Satisfaction Rating
     * Creates a CSAT rating for a solved ticket, or for a ticket that was previously
    solved and then reopened.
    
    Only the end user listed as the ticket requester can create a satisfaction rating for the ticket.
    
    #### Allowed For
    
    * End user who requested the ticket
    
    The end user must be a verified user.
    
     */
    export async function main(auth: Zendesk, ticket_id: string) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/satisfaction_rating`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 923 days ago