Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fuel-rest

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fuel-rest

Node library for performing REST API calls to Salesforce Marketing Cloud (formerly ExactTarget).

  • 2.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-34.48%
Maintainers
2
Weekly downloads
 
Created
Source

Fuel REST Client (for Node.js) Build Status

This repo used to be located at https://github.com/exacttarget/Fuel-Node-REST

This library allows users access to the Salesforce Marketing Cloud (formerly ExactTarget) REST API at a low level.

npm install fuel-rest --save

Initialization

new FuelRest(options) - Initialization

  • options.auth
  • options.origin or options.restEndpoint
  • options.headers
    • Required: no
    • Type: Object
    • set headers that apply to all REST requests (not auth requests)

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.
      • if no callback is passed, you'll need to use the promise interface
  • 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

###Callbacks v. Promises

While future versions will disallow using callbacks and promises together, at the moment it is possible to do. This will lead to unexpected behavior, and you should only one; callbacks OR promises.

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(err);
    }

    // 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);
});

// or with promises
RestClient
    .get(options)
    .then(function(response) {
        // 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);
    })
    .catch(function(err) {
        // error here
        console.log(err);
    });
});

Contributors

Contributing

We welcome all contributions and issues! There's only one way to make this better, and that's by using it. If you would like to contribute, please checkout our guidelines!

ChangeLog

  • See tags/release page for release notes after 0.7.2
  • 0.7.2 - 2014-10-16 - account for content-type header not being present on API response
  • 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

FAQs

Package last updated on 17 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc