Edits history of script submission #3920 for ' Delete Identity (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Delete Identity
     * Deletes the identity for a given user.
    In certain cases, a phone number associated with an identity is still visible on the user profile after the identity has been deleted via API. You can remove the phone number from the user profile by updating the `phone` attribute of the user to an empty string. See Update User via API for details and examples.
    
    #### Allowed For
    * Agents
    
     */
    export async function main(
      auth: Zendesk,
      user_id: string,
      user_identity_id: string
    ) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/identities/${user_identity_id}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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.text();
    }
    

    Submitted by hugo697 377 days ago

  • nativets
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Delete Identity
     * Deletes the identity for a given user.
    In certain cases, a phone number associated with an identity is still visible on the user profile after the identity has been deleted via API. You can remove the phone number from the user profile by updating the `phone` attribute of the user to an empty string. See Update User via API for details and examples.
    
    #### Allowed For
    * Agents
    
     */
    export async function main(
      auth: Zendesk,
      user_id: string,
      user_identity_id: string
    ) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/identities/${user_identity_id}`
      );
    
      const response = await fetch(url, {
        method: "DELETE",
        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.text();
    }
    

    Submitted by hugo697 923 days ago