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

seniorvu-sdk

v3.0.1

Published

JS wrapper SDK for the SeniorVu web API

Downloads

48

Readme

Build Status Coverage Status Dependency Status XO code style

Table of Contents generated with DocToc

seniorvu-sdk

JavaScript wrapper for the SeniorVu web API

srvu.communities()
  .get()
  .then(communities => {
    console.log(communities);
  });

Install

npm install --save seniorvu-sdk

In your code:

import SeniorVu from 'seniorvu-sdk';

// or

const SeniorVu = require('seniorvu-sdk');

Usage

Create a new instance of the SDK:

const srvu = new SeniorVu();

Configuration

Configuration options can either be passed to the constructor or to the config() method:

const srvu = new SeniorVu({
  apiKey: 'foobar'
});

srvu.config({
  apiKey: 'new-api-key'
});

Other Options

  • baseUrl: Set baseUrl for the api
  • token: Set bearer token manually

Authentication

In order to access private information, you must supply an apiKey, username/password, or single-use token to the authenticate() method.

By default, authenticate() will use options already passed in the constructor or to config(). You can override these by passing an object to the method.

authenticate() returns a promise the token result. A bearer token is stored in the instance for further requests.

// Use already-configured options
srvu.authenticate();

// API key
srvu.authenticate({
  apiKey: 'api-key-here'
});

// Email and password
srvu.authenticate({
  email: '[email protected]',
  password: 'secret'
});

// One-time token
srvu.authenticate({
  oneTimeToken: 'one-time-token-here'
});

Fetching Data

This SDK works by chaining method calls in order to build the URL to call at the API. Then a final "verb" method is called to execute the request.

The verb method returns a promise with the results of the call;

For example, to fetch back a list of communities you would call:

srvu.communities().get()
.then(communities => {
  // communities available here
})
.catch(err => {
  // Any error that hapens
});

Parameters passed to methods are used as identifiers, so this will fetch the community with id 123:

srvu.communities(123).get();

// And this will fetch one of its purchased leads
srvu.communities(123).purchasedLeads(456).get();

Parameters

Query parameters can be passed as an object to the final method call, or to the action call if it is a get:

srvu.communities(123).purchasedLeads({ sortBy: 'lastName' }).get();

srvu.communities(123).purchasedLeads().get({ sortBy: 'lastName' });

All possible parameters are listed in the SeniorVu API docs.

Common Parameters

Many endpoints allow paging using limit and offset parameters:

// Get the second 20 communities
srvu.communities().get({ limit: 20, offset: 20 });

Writing data

The verb methods that write data are .put(), .post(), and .delete(), as you might expect. Pass the new data to the verb method.

To update a community:

srvu.communities(123).put({
  name: 'Some Fancy New Name'
});

To create a new lead

srvu.leads().post({
  firstName: 'Some',
  lastName: 'Guy',
  dob: '1955-5-5',
});

To delete a community room

srvu.communities(123).rooms(456).delete();

List of Valid Paths

[
  "/claimRequests",
  "/communities",
  "/communities/predict",
  "/communities/proximity",
  "/communities/{communityId}",
  "/communities/{communityId}/address",
  "/communities/{communityId}/amenities",
  "/communities/{communityId}/appointments",
  "/communities/{communityId}/archivedLeads",
  "/communities/{communityId}/archivedLeads/{archivedLeadId}",
  "/communities/{communityId}/assets",
  "/communities/{communityId}/assets/awsSettings",
  "/communities/{communityId}/assets/image",
  "/communities/{communityId}/assets/video",
  "/communities/{communityId}/assets/{assetId}",
  "/communities/{communityId}/cartItems",
  "/communities/{communityId}/cartItems/{cartItemId}",
  "/communities/{communityId}/hours",
  "/communities/{communityId}/hours/{hourId}",
  "/communities/{communityId}/leads",
  "/communities/{communityId}/neighborhoods",
  "/communities/{communityId}/payment",
  "/communities/{communityId}/purchasedLeads",
  "/communities/{communityId}/purchasedLeads/{purchasedLeadId}",
  "/communities/{communityId}/purchasedLeads/{purchasedLeadId}/carers",
  "/communities/{communityId}/purchasedLeads/{purchasedLeadId}/carers/{carerId}",
  "/communities/{communityId}/purchasedLeads/{purchasedLeadId}/events",
  "/communities/{communityId}/purchasedLeads/{purchasedLeadId}/events/{eventId}",
  "/communities/{communityId}/reviews",
  "/communities/{communityId}/reviews/{reviewId}",
  "/communities/{communityId}/rooms",
  "/communities/{communityId}/rooms/{roomId}",
  "/communities/{communityId}/rooms/{roomId}/image",
  "/communities/{communityId}/rooms/{roomId}/upload",
  "/leads",
  "/leads/batchCreate",
  "/leads/deleteCreated",
  "/leads/upload",
  "/users",
  "/users/forgotPassword",
  "/users/me",
  "/users/reset/{token}",
  "/users/{userId}",
  "/users/{userId}/password",
  "/auth/login",
  "/auth/registration",
]

Development

Committing changes

Run npm (run) start to check that linting with XO and tests with ava pass.

Also, make sure you run npm run build and npm run toc before committing changes. A pre-commit hook helps.

Testing

NOTE: the tests run against the transpiled version, so if you use ava manually be sure that your changes are transpiled.

Run npm (run) test to run tests with ava.

Coverage

# Run sirv in another terminal window
npx sirv ./coverage

# Build and run tests+coverage on changes
npm run cover:watch

Linting

Run npm run lint to run linter with XO.

Releasing

@sindresorhus's np package is great for doing releases. Just install it globally and run np in your directory. Choose the option you want; voila, you're done.

TODO

  • [ ] Re-authenticate when token expires.