Socket
Socket
Sign inDemoInstall

node-webservice

Package Overview
Dependencies
4
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-webservice

Webservice helper for api requests


Version published
Maintainers
1
Created

Readme

Source

node-webservice

Webservice helper for api requests

Installation

Install via npm:

$ npm install node-webservice

Documentation

SOAP

Usage

const Webservice = require('node-webservice').SOAP;

const webservice = new Webservice(options<Object>);

webservice.execute(Service<Class>, params<Object>) => Promise;
Constructor

options object will be pass as argument for Service constructor

execute
  • Service: see below for explaination
  • params: object will be pass as argument for Service method buildRequest (require service key containing client path in soap object)

HTTP

Usage

const Webservice = require('node-webservice').HTTP;

const webservice = new Webservice(options<Object>);

webservice.execute(Service<Class>, params<Object>) => Promise;
Constructor

options object will be pass as argument for Service constructor

execute
  • Service: see below for explaination
  • params: object will be pass as argument for Service method buildRequest

Service Class

First argument for webservice execute function

Skeleton

class MyService {

  /**
   * Initialize the operation
   *
   * @param {Object} options
   */
  constructor(options) {
    // do your stuff
  }

  /**
   * Build the JSON request
   *
   * @param {Object} params Request query params
   * @return {Promise/undefined}
   */
  buildRequest(params) {
    // do your stuff
  }

  /**
   * Get the JSON request
   *
   * @return {Object} JSON request
   */
  getRequest() {
    // do your stuff
  }


  /**
   * Parse webservice response
   *
   * @param {String} response XML or JSON response from the webservice
   * @param {Object} headers headers Object response from the webservice (Only present for HTTP request)
   * @return {???} your parse response
   */
  getResponse(response, headers) {
    // do your stuff
  }

  /**
   * Parse webservice error
   *
   * @param  {Object} error
   * @return {???} your parse error
   */
  getError(error) {
    // do your stuff
  }

  /**
   * Return service URL
   *
   * @return {String} URL
   */
  getURL() {
    return 'https://google.com';
  }
}

Examples

See examples

Contributing

This project is a work in progress and subject to API changes, please feel free to contribute

Keywords

FAQs

Last updated on 08 Jan 2019

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