You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

service-cloud-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

service-cloud-client

Allows to call actions of services in the service cloud (service-cloud-service)

1.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Service Cloud - Client

Allow to call Service Cloud services (instances of service-cloud-service) actions.

Usage

Let's say there is a serivce called hello-world in the service cloud (service-cloud-service) and this service has an action called say which produces a message with the sentence Hello World! depending on the language given in the options of the action.

This action can be called 3 different ways :

const client = require('service-cloud-client');

const serviceName = 'hello-world'; // Name of the service
const actionName = 'say'; // Name of the action of the service
const data = { // Options of the action
    language: 'fr'
};
const remote = 'http://localhost:1900'; // Entry point of the service cloud

// Direct call
client.ServiceCloudClient.call(serviceName, actionName, remote, data, (e, result) => {
    if(e)
        return console.error(e);

    console.log(result.message);
});

// Call with instance
const helloWorld = new client.ServiceCloudClient(serviceName, remote);
helloWorld.call(actionName, data, (e, result) => {
    if(e)
        return console.error(e);

    console.log(result.message);
});

// Call with expanded methods (methods dynamically added to the object from the information of the remote service)
const helloWorldExpanded = new client.ServiceCloudClient(serviceName, remote);
helloWorldExpanded.expandActions((e) => {
    if(e)
        return console.error(e);
        
    helloWorldExpanded.say(data, (e, result) => {
        if(e)
            return console.error(e);
    
        console.log(result.message);
    });
});

Keywords

service

FAQs

Package last updated on 12 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts