Socket
Socket
Sign inDemoInstall

service-cloud-client

Package Overview
Dependencies
47
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

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)


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 12 Nov 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc