Giter Site home page Giter Site logo

remedy-rest's Introduction

innovationsuite-rest

Coverage Status

Node.js rest client for Innovation suite and Remedy ARS

Installation

npm install innovationsuite-rest

##Usage

var remedy=require('innovationsuite-rest');
var client=remedy({
        username: "Demo",
        password: "password",
        host: "developer1234.innovate.bmc.com",//Server where the rest api is running usually the AR server
        port: "443",//Port where the rest api is exposed.
        https: true,
        allowGuestuser: false
});

##Quick example Lists all mailboxes in AR System Email Mailbox Configuration

var remedy = require('innovationsuite-rest');
var client = remedy({
    username: "Demo",
    password: "password",
   host: "developer1234.innovate.bmc.com",//Server where the rest api is running usually the AR server
        port: "443",//Port where the rest api is exposed.
        https: true,
   });

client.login(function(err, callback) {
    if (err) {
        console.log(err);
    } else {
        client.get({
            path: {
                schema: "org.ars.lib:recorddef" //AR Schema name/Innovation suite record definition
            }
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                for (var i = 0; i < data.entries.length; i++) {
                    console.log(data.entries[i].value["Mailbox Name"]);
                }
            }
        });
    }
});

##Search example Find user Demo in the User schema.

var remedy = require('remedy-rest');
var client = remedy({
    username: "Demo",
    password: "password",
    host: "remedy01.test.local", //Server where the rest api is running, usually the AR server
    port: "8008", //Port where the rest api is exposed.
    https: false
});

client.login(function(err, callback) {
    if (err) {
        console.log(err);
    } else {
        client.get({
            path: {
                schema: "User" //AR Schema name
            },
            parameters: {
                q: "'Login Name'=\"Demo\"",
                fields: ["Login Name"]
            }
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                for (var i = 0; i < data.entries.length; i++) {
                    console.log(data.entries[i].value["Login Name"]);
                }
            }
        });
    }
});

##Post example Post an entry to a form.

var remedy = require('remedy-rest');
var client = remedy({
    username: "Demo",
    password: "password",
    host: "remedy01.test.local", //Server where the rest api is running, usually the AR server
    port: "8008", //Port where the rest api is exposed.
    https: false
});

client.login(function(err, callback) {
    if (err) {
        console.log(err);
    } else {
        client.post({
            path: {
                schema: "Simple Form" //AR Schema name
            },
            data: {
                values: {
                    "Submitter": "Allen",
                    "Short Description": "testing 123"
                }
            }
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                console.log(data.entryId)
            }
        });
    }
});

##Put example Update an entry

var remedy = require('remedy-rest');
var client = remedy({
    username: "Demo",
    password: "password",
    host: "remedy01.test.local", //Server where the rest api is running, usually the AR server
    port: "8008", //Port where the rest api is exposed.
    https: false
});

client.login(function(err, callback) {
    if (err) {
        console.log(err);
    } else {
        client.put({
            path: {
                schema: "Simple Form", //AR Schema name
                id:"0000000000000001"
            },
            data: {
                values: {
                    "Short Description": "Updated Description"
                }
            }
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                console.log(data)
            }
        });
    }
});

##Post example with attachments Update an entry

var remedy = require('remedy-rest');
var client = remedy({
    username: "Demo",
    password: "password",
    host: "remedy01.test.local", //Server where the rest api is running, usually the AR server
    port: "8008", //Port where the rest api is exposed.
    https: false
});

client.login(function(err, callback) {
    if (err) {
        console.log(err);
    } else {
        client.post({
            path: {
                schema: "Simple Form" //AR Schema name
               
            },
            data: {
                values: {
                    "Short Description": "With attachment",
                    "Status":0,
                    "Attachment_2": "1.txt",
                    "Attachment_1": "2.txt"
                },
                attachments: {
                        "Attachment_2": {
                            path: "./test/testdata/2.txt"
                        },
                        "Attachment_1": {
                            path: "./test/testdata/1.txt"
                        }
                    }
            }
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                console.log(data.entryId)
            }
        });
    }
});

##Complete config options

  • username
  • password
  • host
  • port
  • allowGuestuser true of false defaults to false
  • proxy_config object
proxy_config:{
   host:'proxy.local',
   port:3333
}
  • clientTypeId This will be added in http headers as "X-AR-Client-Type"
  • rpcQueue Setting this will add the "X-AR-RPC-Queue" header. And AR server requests will be routed to this queue

Tests

Import def file located in the defs folder and run: npm test

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

remedy-rest's People

Contributors

gramlin avatar mvollset avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.