Edits history of script submission #3945 for ' Count Organizations (zendesk)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Zendesk = {
      username: string;
      password: string;
      subdomain: string;
    };
    /**
     * Count Organizations
     * Returns an approximate count of organizations. If the count exceeds
    100,000, it is updated every 24 hours.
    
    The `refreshed_at` property of the `count` object is a timestamp that indicates
    when the count was last updated.
    
    When the count exceeds 100,000, the `refreshed_at` property may
    occasionally be null. This indicates that the count is being
    updated in the background and the `value` property of the `count` object is limited to
    100,000 until the update is complete.
    
    #### Allowed For
    
    * Agents
    
     */
    export async function main(auth: Zendesk) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/organizations/count`
      );
    
      const response = await fetch(url, {
        method: "GET",
        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;
    };
    /**
     * Count Organizations
     * Returns an approximate count of organizations. If the count exceeds
    100,000, it is updated every 24 hours.
    
    The `refreshed_at` property of the `count` object is a timestamp that indicates
    when the count was last updated.
    
    When the count exceeds 100,000, the `refreshed_at` property may
    occasionally be null. This indicates that the count is being
    updated in the background and the `value` property of the `count` object is limited to
    100,000 until the update is complete.
    
    #### Allowed For
    
    * Agents
    
     */
    export async function main(auth: Zendesk) {
      const url = new URL(
        `https://${auth.subdomain}.zendesk.com/api/v2/organizations/count`
      );
    
      const response = await fetch(url, {
        method: "GET",
        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