<commit_before>remedy-rest
==============
[![Coverage Status](https://coveralls.io/repos/github/mvollset/remedy-rest/badge.svg?branch=master)](https://coveralls.io/github/mvollset/remedy-rest?branch=master)

Node.js rest client for ARS

## Installation
 `npm install remedy-rest`

##Usage

```js
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,
        allowGuestuser: false
});

```

##Quick example
Lists all mailboxes in AR System Email Mailbox Configuration
```js
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: "AR System Email Mailbox Configuration" //AR Schema 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["Mailbox Name"]);
                    }
                }
                });
    }
    });
```

##Search example
Find user Demo in the User schema.
```js
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
Find user Demo in the User schema.
```js
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)
                }
                });
    }
    });
```
## Tests
Import def file located in the defs folder and run:
 `npm test`


## Contributing
<commit_msg>Beautified examples.<commit_after>remedy-rest
==============
[![Coverage Status](https://coveralls.io/repos/github/mvollset/remedy-rest/badge.svg?branch=master)](https://coveralls.io/github/mvollset/remedy-rest?branch=master)

Node.js rest client for ARS

## Installation
 `npm install remedy-rest`

##Usage

```js
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,
        allowGuestuser: false
});

```

##Quick example
Lists all mailboxes in AR System Email Mailbox Configuration
```js
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: "AR System Email Mailbox Configuration" //AR Schema 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["Mailbox Name"]);
                }
            }
        });
    }
});
```

##Search example
Find user Demo in the User schema.
```js
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
Find user Demo in the User schema.
```js
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)
            }
        });
    }
});
```
## Tests
Import def file located in the defs folder and run:
 `npm test`


## Contributing

{'fraction_non_alphanumeric': 0.13200649878147847, 'fraction_numerical': 0.00785269428648795, 'mean_word_length': 1.5472413793103448, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '551840', 'n_tokens_mistral': 2133, 'n_tokens_neox': 2014, 'n_words': 543}