0.0.32 • Published 9 years ago

eden-rest v0.0.32

Weekly downloads
82
License
-
Repository
github
Last release
9 years ago

#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'
0.0.32

9 years ago

0.0.31

9 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.12

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago