Code Monkey home page Code Monkey logo

fuel-node-rest's Introduction

Fuel REST Client (for Node.js) Build Status

This library allows users access to ExactTarget's REST API at a low level.

Initialization

new FuelRest( options ) - Initialization

API

  • apiRequest( options, callback )
    • options - see request modules options
    • options.auth - will be passed into getAccessToken inside Fuel Auth
    • options.uri - can either be a full url or a path that is appended to options.origin used at initialization (url.resolve)
    • options.retry - boolean value representing whether or not to retry request (and request new token) on 401 invalid token response. default: false
    • callback - executed after task is completed. required
  • get | post | put | patch | delete( options, callback )
    • options - see apiRequest options
    • options.retry - see above for description. default: true
    • callback - see apiRequest options
    • Request method will be overwritten by these methods. It will be set to same value as the name of the method used

Setting up the client

var FuelRest = require( 'fuel-rest' );
var options  = {
    auth: {
        // options you want passed when Fuel Auth is initialized
        clientId: 'clientId'
        , clientSecret: 'clientSecret'
    }
    , origin: 'https://alternate.rest.endpoint.com' // default --> https://www.exacttargetapis.com
};

var RestClient = new FuelRest( options );

Examples

var options = {
    uri: '/platform/v1/endpoints'
    headers: {}
    // other request options
};

RestClient.get( options, function( err, response ) {
    if( err ) {
        // error here
        console.log( error );
    }

    // will be delivered with 200, 400, 401, 500, etc status codes
    // response.body === payload from response
    // response.res === full response from request client
    console.log( response );
});

ChangeLog

  • 0.7.1 - 2014-09-09 - removed unneeded "!!"
  • 0.7.0 - 2014-08-29 (public release, 1st npm version)
    • request retry on 401 invalid token response
    • created helpers file for certain functions
    • updated error delivering/throwing
  • 0.6.0 - 2014-08-26 - added patch method
  • 0.5.0 - 2014-08-26 - API overhaul (apiRequest + all http methods) - breaking
  • 0.4.0 - 2014-08-25 - changed object initialization - breaking
  • 0.3.0 - 2014-08-20
    • added ability to use initialized fuel auth
    • updated travis ci config
    • added license
  • 0.2.0 - 2014-08-09 - removed event emitter - breaking
  • 0.1.0 - 2014-08-07
    • initial module
    • initial unit tests

fuel-node-rest's People

Contributors

vernak2539 avatar kellyjandrews avatar

Watchers

James Cloos avatar  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.