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) {
});
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 ()
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 test
Contributors
Vincenzo Merolla
Credits
Shout out to Matt Zabriskie for easing the build of this module with axios.
License
MIT