npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zeroq-sdk

v2.2.6

Published

SDK que abstrae las tareas mas comunes de comunicacion con la API de ZeroQ

Downloads

375

Readme

#Herramienta para simplificar la interacción con la API de ZeroQ.

Instalacion

Puede importarse como un módulo de npm de la siguiente forma:

npm install --save zeroq-sdk # o yarn add zeroq-sdk

También se puede importar directamente en el HTML:


<!-- para importar una versión en específico -->
<script src="https://cdn.zeroq.cl/sdk/zeroq-sdk-v1.1.6.js"></script>

<!-- para importar la última versión -->
<script src="https://cdn.zeroq.cl/sdk/zeroq-sdk-latest.js"></script>

Proceso de obtención de tickets

Para obtener un ticket, el usuario debe haber seleccionado:

  1. Una oficina
  2. Una línea (o trámite) dentro de esa oficina

Obtener el listado de oficinas

import ZeroQ from "zeroq-sdk";

// En el caso del bundle: const zq = new ZeroQ.default({token:"1234"});

const zq = new ZeroQ({ token:"1234" });

// o por medio de vanilla
//<script src="https://cdn.zeroq.cl/sdk/zeroq-sdk-v1.1.4.js"></script>
const zeq= new ZeroQ.default({ token:"1234" })

// Obtiene todas las oficinas
const offices: Promise<Array<Office>> = zq.getOffices()

Ejemplo de filtrar una oficina

const offices = await getOffices();
const aguasAndinasOffice = offices.filter(o => o.officeSlug === "aguas-andinas")

El arreglo de oficinas puede ser mapeado a una lista de elementos HTML entre los que el usuario podrá elegir (como referencia, ver las oficinas en https://zeroq.cl/search?category=demos)

Cada oficina cuenta con un método getLines() para obtener un arreglo de líneas.

const lines: Array<Line> = office.getLines();

Crear un ticket

El ticket siempre estará vinculado a una línea. Al llamar al método pickTicket(), se obtiene un ticket para dicha línea:

line.pickTicket({
    onSuccess(t) { console.log("ticket was picked", t) },
    onCall(t) { console.log("ticket was called", t) },
    onError(e)  { console.error("an error occurred", e) }
});

Internamente, la librería espera que se gatille el evento de confirmación de un ticket, lo que es representado en el código por una función callback que se ejecuta cuando se recibe este evento.

Es importante diferenciar, tanto para tickets como para reservas, los eventos de creación y confirmación:

  • Creación: la API en la nube reconoce la intención de un usuario de obtener un ticket en una oficina y guarda este registro en su base de datos. En este momento, el ticket todavía no es válido para ser atendido.

  • Confirmación: la API se comunica exitosamente con el local y este guarda un ticket o reserva para ser atendido.

// Obtiene las reservas del usuario
const reservations: Promise:<Array<Reservation>> = zq.getUserReservations();

// Obtiene las líneas (trámites) de la oficina
const lines: Array<Line> = office.getLines();

// Se suscribe a los eventos de creación de ticket, error y llamada
// del ticket
line.pickTicket({
    onSuccess(t) { console.log("ticket was picked", t) },
    onCall(t) { console.log("ticket was called", t) },
    onError(e)  { console.error("an error occurred", e) }
});

// Obtiene los bloques horarios
const blocks: Array<TimeBlock> = line.getTimeBlocks(new Date())

// Efectúa una reserva y se suscribe
blocks[0].reserve({
    onSuccess(t) { console.log("ticket was picked", t) },
    onCall(t) { console.log("ticket was called", t) },
    onError(e)  { console.error("an error occurred", e) }
});

Ejecutar ejemplo

  1. git clone https://github.com/rafael180496/example-sdk-call.git
  2. npm install
  3. npm start

Consumir Bundle Local

  1. npm install -g http-server
  2. cd dist/
  3. http-server ./
  4. <script src="http://127.0.0.1:8080/bundle.js" type="text/javascript"></script>