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

nowjs-client

v0.1.5

Published

JS API that interacts with ZBox Now!

Downloads

7

Readme

NowJs Client

This is a library to use in your front-end app to interact with the ZBox Now! API

Download & Install

You have different ways of downloading and installing the library

Npm

In your project just install the library with npm

npm install nowjs-client

Bower

In your project just install the library with npm

bower install nowjs-client

Download from GitHub

Download the .tar.gz from GitHub releases uncompress it and copy it somewhere in your project.

https://github.com/ZBoxApp/nowjs-client/releases/download/v0.1.5/nowjs-client-v0.1.5.tar.gz

Download from S3 or use it as a CDN

Download the js file from Amazon S3 or reference it directly in your project from:

https://s3-sa-east-1.amazonaws.com/zbox-now/nowjs-client/nowjs-client-v0.1.5.min.js

Or download the .tar.gz

https://s3-sa-east-1.amazonaws.com/zbox-now/nowjs-client/nowjs-client-v0.1.5.tar.gz

Usage

In your HTML file reference the plugin

    <script src="<path-to-the-js-file/nowjs-client-v0.1.5.min.js"></script>

API

When referencing the library in your project the window object will have another object called zbox.

To use the library API you need to first initialize it.

initialize(opts)

zbox.initialize(object)

opts must have set the following properties:

  • client_id: The client ID provided by the ZBox Now! platform.
  • client_secret: The client Secret provided by the ZBox Now! platform.
  • username: The username which you want to appear in ZBox Now! when posting a new message.
  • icon_url: The URL of an .png image to use as an icon or avatar for the user when posting a new message in ZBox Now!.

After you have initialize your API you will be able to use the following:

Channels

All access to the API related to channels lives inside the object

zbox.channels

getAll(string, function)

zbox.channels.getAll(teamName, callback)

Returns all the channels available for a team.

  • teamName: The name of the team
  • callback(error, channels): A callback function to be called with the result of getting all the channels for a team
    • error: Object
      {
        status: "Number with the status code",
        message: "String with error details"
      }
    • channels: Array of Objects
      [{
        id: "String with the id of the channel",
        type: "String channel or group",
        display_name: "String with the name of the channel as it appears to the users",
        name: "String with the name of the channel to use as an identifier"
      }]

getMembers(teamName, channelId, limit, callback)

zbox.channels.getMembers(string, string, number, function)

Returns the members for the specified team channel.

  • teamName: The name of the team
  • channelId: The id of the channel to get the members from.
  • limit: The amount of members to return. If set to 0 or less it will return all the members.
  • callback(error, members): A callback function to be called with the result of getting the channel members.
    • error: Object
       {
         status: "Number with the status code",
         message: "String with error details"
       }
    • members: Object
      {
        id: 'String with the id of the channel queried as string',
        members_count: "Number with the amount of memebrs in the channel",
        members: [{
            email: "String with member email address",
            id: "String with member user id",
            nickname: "String with member nickname (only present if it has one)",
            roles: "String with the role of the member (only present if it has one)",
            username: "String with member username"
        }]
      }

Users

All access to the API related to users lives inside the object

zbox.users

getAll(teamName, callback)

zbox.users.getAll(string, function)

Returns all the users available for a team.

  • teamName: The name of the team
  • callback(error, users): A callback function to be called with the result of getting all the users for a team
    • error: Object
      {
        status: "Number with the status code",
        message: "String with error details"
      }
    • users: Array of Objects
      [{
        id: "String with the user id",
        email: "String with the user email address",
        first_name: "String with the user first name (only present if it has been set)",
        last_name: "String with the user first name (only present if it has been set)",
        nickname: "String with the user nickname (only present if it has been set)",
        locale: "String with the user preferred locale",
        username: "String with the username"
      }]
getStatuses(teamName, usersId, callback)

zbox.users.getStatuses(string, array, function)

Return the status for the specified users. Status can be: online, away or offline.

  • teamName: The name of the team
  • usersId: Array with the id of every user from which to get the status
  • callback(error, statuses): A callback function to be called with the result of getting all the users statuses
    • error: Object
      {
          status: "Number with the status code",
          message: "String with error details"
      }
    • statuses: Object
      {
        key1: "String with status",
        key2: "String with status"
      }
      key1, key2, etc.. corresponds to each of the userIds used in the array that match an user id in the team.

Messages

Send messages to a Channel in ZBox Now! using the API. There are two kind of messages that can be sent, a post to a specific channel or an ephemeral post to a specific user.

Ephemeral posts are messages that do not persists

All access to the API related to messages lives inside the object

zbox.messages

send(token, channelName, message, callback)

zbox.messages.send(string, string, string, function)

  • token: The token to send messages which was granted by the incoming webhook
  • channelName: The identifier name of the channel. If not channelName is set then it will post to the default Channel.
  • message: The message to be sent (markdown supported)
  • callback(error): A callback function to be called when the message is sent. if it was sent successfully then error is null
    • error: Object
      {
          status: "Number with the status code",
          message: "String with error details"
      }

sendEphemeral(token, channelName, userId, message, callback)

zbox.messages.sendEphemeral(string, string, string, string, function)

  • token: The token to send messages which was granted by the incoming webhook
  • channelName: The identifier name of the channel. If not channelName is set then it will post to the default Channel.
  • userId: The id of the user to send the message to
  • message: The message to be sent (markdown supported)
  • callback(error): A callback function to be called when the message is sent. if it was sent successfully then error is null
    • error: Object
      {
          status: "Number with the status code",
          message: "String with error details"
      }