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

vcp-service-client

v1.0.2

Published

RICOH Visual Communication Platform service client for javascript

Downloads

24

Readme

vcp-service-client

npm version Dependency Status

DESCRIPTION

RICOH Visual Communication Platform service client for javascript

install

$ npm install vcp-service-client

API

configuration params

var params = {
  client_id:     'your client id',
  client_secret: 'your client secret',
  username:      'your cid',
  password:      'your password',
  scope:         ['list', 'of', 'granted', 'scope'], // see list on src/scopes.js
  grant_type:    'password' // fixed value
};

create instance

create instance with Auth URI Endpoint and configuration params.

// create instance
var client = new VCPClient('https://auth.ucs.ricoh.com', params);

auth()

call auth API and save authentication result in instance. return Promise. need to call this onece, before calling other api.

// login
client.auth()
      .then(function() {
        // result will saved into instance
        // but usually no need to access directory.
        console.log(client.authInfo);
      });

accountInfo()

call account info API and return Promise.

client.accountInfo()
      .then(function(accountInfo) {
        console.log(accountInfo);
      });

userInfo()

call user info API and return Promise.

client.userInfo()
      .then(function(userInfo) {
        console.log(userInfo);
      });

information()

call infomation API and return Promise.

client.information()
      .then(function(information) {
        console.log(information);
      });

getRoster()

call roster API and get all roster info and return Promise.

client.getRoster()
      .then(function(rosters) {
        console.log(rosters);
      });

call roster API with cid, get roster info of given cid and return Promise.

var cid = 'xxxxxx';
client.getRoster(cid)
      .then(function(roster) {
        console.log(roster);
      });

addRoster()

call roster API and send roster request and return Promise.

var cid = 'xxxxxx';
var options = {
  name: 'A',
  name_kana: 'えー',
  sender_name: 'B',
  sender_name_kana: 'びー'
};

client.addRoster(cid, options)
      .then((result) => {
        console.log(result);
      }).catch();

updateRoster()

call roster API and send update request and return Promise.

var cid = 'xxxxxx';
var options = {
  type: 'subscribed', // or 'unsubscribed'
  name: 'A',
  name_kana: 'えー'
};

client.updateRoster(cid, options)
      .then(function(result) {
        console.log(result);
      });

deleteRoster()

call roster API and send delete request and return Promise.

var cid = 'xxxxxx';

client.deleteRoster(cid)
      .then(function(result) {
        console.log(result);
      });

logUpload()

call logupload API and upload logdata, return Promsie

var log = 'this is log data which you wanna upload';
var filename = 'mylogfilename'; // this will be name of saved file at log server
var timeout = 5000; // (default 10000 ms)


client.logUpload(log, filename, timeout)
      .then(function() {
        console.log('upload finished');
      })

discovery()

call a discovery API with directory specified SCOPE value, and return Promise.

var scope = require('src/scopes').SCOPES;

// this is really equivalant to client.infomation()
client.discovery(scope.INFORMATION_URI)
      .then(function(result) {
        console.log(result);
      });


// multiple scope
client.discovery([scopes.USERINFO_QUERY, scopes.INFORMATION_URI])
      .then(function(result) {
        console.log(result);
      });

Example

call auth & user info api.

in browser

<script src="build/browser/bundle.min.js"></script>
<script>
var client = new VCPClient('https://auth.ucs.ricoh.com', config);

// call this first
client.auth().then(function() {
  console.log('auth success');
});

document.getElementById('#userinfo')
        .addEventListener('click', function() {
          // call after auth
          client.userInfo().then(function(info) {
            cosnole.log(info);
          });
        });
</script>

in server

var VCPClient = require('build/src').VCPClient;

var client = new VCPClient('https://auth.ucs.ricoh.com', config);

client.auth().then(function() {
  return client.userInfo();
}).then(function(info) {
  console.log(info);
});

Proxy support

request via proxy in node.js need to add vcp-service-client-proxy

var Proxy = require('vcp-service-client-proxy');
var VCPClient = require('vcp-service-client').VCPClient;

var proxy = Proxy({ http: 'http://proxy.com', https: 'https://proxy.com' });
//  proxy = Proxy(); default arguments is process.env.HTTP(s)_PROXY

var params = {
  client_id: client_id,
  client_secret: client_secret,
  ...
  proxy: proxy // add proxy
};

var client = new VCPClient(endpoint, params);
client.auth().then(function() {
  ...
});

in browser usage, set correct value to browser not modify code.

Canceling requests

all promise from request API are cancelable.

for example, you can cancel logupload with calling cancel() method.

var log = 'this is log data which you wanna upload';
var filename = 'mylogfilename'; // this will be name of saved file at log server
var timeout = 5000; // (default 10000 ms)

var uploadPromise = client.logUpload(log, filename, timeout)
      .then(function() {
        console.log('upload finished');
      })
      .catch(function() {
        console.error('upload timeouted, aborted, or failed');
      })
      .finally(function() {
        if (uploadPromise.isCancelled()) {
          console.log('cancelled');
        }
      });

document.getElementById('uploadcancel')
      .addEventListener('click', function() {
        uploadPromise.cancel();
      });

how to build yourself

$ git clone https://github.com/ricohvcp/vcp-service-client
$ npm install
$ npm run build
  • source for node.js will be in build/src directory
  • source for browser will be in build/browser directory

test

fill the config/config.template.js with your value. and rename it to config/config.js

and then run test task

$ npm test

or you can run test on browser via karma from this task.

$ npm run test-browser

change target browser from karma.conf.js

tasks

all tasks could run from npm command.

## install npm dependencies
$ npm install

## build all files in build/
$ npm run build

## clean the build, tmp, lib, and npm-debug.log
$ npm run clean

## remove all build and dependencies
$ npm run clean-all

## check js style and config files
$ npm run lint

## run test on server
$ npm test

## run test on browser and get coverage
$ npm run test-browser

LICENSE

MIT