eden-rest

0.0.32 • Public • Published

Rest

DESCRIPTION

Build Status

General

Installation

npm install eden-rest

Usage

var rest = require('eden-rest');

Methods


setAuthentication

 this setAuthentication( 'yourname@yourdomain.com','yourpassword' );

Sets authentication

Parameters

  1. 'yourname@yourdomain.com' - string (username)

  2. 'yourpassword' - string (password)

Returns

this

Example

Code
var username = 'yourname@yourdomain.com';
var password = 'yourpassword';
rest().setAuthentication(username, password);
typeof result;
Outputs
'object'

setBody

 this setBody( 'id=123&trim_user=false' );

Sets the request body

Parameters

  1. 'id=123&trim_user=false' - string

Returns

this

Example

Code
rest().setBody('id=123&trim_user=false');
typeof response;
Outputs
'string'

setQueryBody

 this setQueryBody( {id: '123', trim_user: false} );

Sets the request body from an object to a string query

Parameters

  1. {id: '123', trim_user: false} - object

Returns

this

Example

Code
rest().setQueryBody({id: '123', trim_user: false});
Outputs
'object'

setJsonBody

 this setJsonBody({id: '123', trim_user: false});

Sets the request body from an object to JSON

Parameters

  1. {id: '123', trim_user: false} - object

Returns

this

Example

Code
rest().setJsonBody({id: '123', trim_user: false});
typeof response;
Outputs
'object'

setHeaders

 this setHeaders('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json', 'http://tinyurl.com/zhy5');

Sets the headers hash

Parameters

  1. string|object

  2. mixed

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setHeaders(url , 'http://tinyurl.com/zhy5');
Outputs
'string'

setHost

 this setHost('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Sets the URL host

Parameters

  1. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
var result = rest().setHost(url);
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

setMethod

 this setMethod('post');

Sets the method IE GET, POST, PUT, DELETE

Parameters

  1. 'post' - string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post');
Outputs
'object'

setPath

 this setPath('https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Sets the url path

Parameters

  1. 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setPath(url);
Outputs
'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json'

setPort

 this setPort(3306);

Sets the port

Parameters

  1. 3306 - int (port number)

Returns

this

Example

Code
var port = 3306;
rest().setPort(port);
Outputs
'3306'

setUrl

 this setUrl('https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Disects URL

Parameters

  1. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string (url)

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setUrl(url);
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

useSSL

 this useSSL('https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json');

Use HTTPS

Parameters

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().useSSL(url);
typeof response;
Outputs
'string'

getResponse

 this getResponse(function, string);

Sends off the request

Parameters

  1. function(error, response) - function

  2. 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json' - string

Returns

this

Example

Code
var url = 'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest().setUrl(url);
rest().getResponse(function(error, response));
Outputs
'https://api.twitter.com/1.1/statuses/retweet/241259202004267009.json'

getJsonResponse

 this getJsonResponse(Function, String);

Sends off the request

Parameters

  1. function

  2. string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post')
.setBody('id=123&trim_user=false')
.getJsonResponse(function(error, response,meta))
Outputs
'object'

getQueryResponse

 this getQueryResponse(Function, String);

Sends off the request

Parameters

  1. function

  2. string

Returns

this

Example

Code
var url = 'https://apiu.twitter.com/1.1/statuses/retweet/241259202004267009.json';
rest()
.setUrl(url)
.setMethod('post')
.setQueryBody({id: '123', trim_user: false})
.getQueryResponse(function(error, response));
typeof response;
Outputs
'object'

Readme

Keywords

Package Sidebar

Install

npm i eden-rest

Weekly Downloads

24

Version

0.0.32

License

none

Last publish

Collaborators

  • archive_donotuse