vcp-service-client
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 instancevar client = '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.
// loginclient ;
accountInfo()
call account info API and return Promise.
client ;
userInfo()
call user info API and return Promise.
client ;
information()
call infomation API and return Promise.
client ;
getRoster()
call roster API and get all roster info and return Promise.
client ;
call roster API with cid, get roster info of given cid and return Promise.
var cid = 'xxxxxx';client ;
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 ;
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 ;
deleteRoster()
call roster API and send delete request and return Promise.
var cid = 'xxxxxx'; client ;
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 servervar timeout = 5000; // (default 10000 ms) client
discovery()
call a discovery API with directory specified SCOPE
value, and return Promise.
var scope = SCOPES; // this is really equivalant to client.infomation()client ; // multiple scopeclient ;
Example
call auth & user info api.
in browser
in server
var VCPClient = VCPClient; var client = 'https://auth.ucs.ricoh.com' config; client;
Proxy support
request via proxy in node.js need to add vcp-service-client-proxy
var Proxy = ;var VCPClient = 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 = endpoint params;client;
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 servervar timeout = 5000; // (default 10000 ms) var uploadPromise = client ; document ;
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