Miss any of our Open RFC calls?Watch the recordings here! »

offerpop

0.1.0 • Public • Published

Offerpop

This module is a simple, isomorphic JS library to interact with Offerpop's REST APIs. It can be used both in the browser using a bundler like Browserify or Webpack or on the server using Node.

Code Example

var Ugc = require('offerpop').Ugc;
var ugc = new Ugc('OFFERPOP_ACCESS_TOKEN');
 
ugc
  .getById('37152902')
  .then(function (response) {
    // do stuff
  });

Motivation

I built this library so that communication with Offerpop's Content API and Conversion Unit API could be abstracted out and easily used on the browser and server side.

Installation

npm install --save offerpop

API Reference

The module exports two classes whose instance methods return an axios Promise.

new Ugc(String accessToken)

getById (String id [,Object params])

Type Parameter Description
String id id of the user generated content
Object params query params of the GET request

getCollection (String id [, Object params, Boolean collectAllPages])

Type Parameter Description
String id id of the collection
Object params query params of the GET request
Boolean collectAllPages boolean to decide whether to fetch the whole collection

new ActiateUnit(String accessToken)

getById (String id)

Type Parameter Description
String id id of the activate unit

getAll ()

new Content(String accessToken)

getItems (Object params)

Type Parameter Description
Object params query params of the GET request

Tests

To run the tests for this repo you'll need to setup an .env file with the following environment variable.

OFFERPOP_ACCESS_TOKEN=*** YOUR ACCESS TOKEN HERE ***

Then, run the following command.

npm run test-dev

Contributors

Vincenzo Merolla

Credits

Shout out to Matt Zabriskie for easing the build of this module with axios.

License

MIT

Install

npm i offerpop

DownloadsWeekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar